Skip to content

Commit

Permalink
fix 404
Browse files Browse the repository at this point in the history
  • Loading branch information
febryardiansyah committed Jul 26, 2020
1 parent b8b8e71 commit a812acb
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/node_modules/
.vercel
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Manga API
# Manga API
Restful API Manga bahasa Indonesia built with ❤️ and node.js

## Usage
# Usage
1. Clone this repository
```bash
git clone https://github.com/febryardiansyah/manga-api.git
Expand All @@ -13,5 +13,29 @@ Restful API Manga bahasa Indonesia built with ❤️ and node.js
```
4. visit http://localhost:3000/api
## Routes
lazy af rn, i'll add later lmao 😬
# Documentation
__API__ __PATH__ = http://localhost:3000/api
__ApI__ Version = `v1.0`
## Get All Manga
Get Latest Manga Update
```bash
/manga/page/[pageNumber]
```
Returns
```
bash
{
manga_list: [
{
title: "My Wife is a Demon Queen ",
thumb: "https://i0.wp.com/komiku.co.id/wp-content/uploads/Manhua-My-Wife-is-a-Demon-Queen.jpg?resize=450,235&quality=60",
type: "Manhua",
updated_on: "2 jam lalu Berwarna",
endpoint: "my-wife-is-a-demon-queen/",
chapter: "Chapter 212"
},
]
```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const chapter = require('./routers/chapter')
const cors = require('cors')

app.use(cors())
app.use('/api',manga,require('./routers/handleError'))
app.use('/api',require('./routers/handleError').router,manga)
app.use(express.static('./public'))
app.use('/api/chapter',chapter)
app.listen(PORT, function () {
Expand Down
14 changes: 10 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Home</title>
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<h1>Selamat Datang di MangaMint Api</h1>
<p>Jangan lupa bernafas ya xiixixiix 😭</p>
<nav>
<ul>
<li><a href="https://github.com/febryardiansyah/manga-api">Github</a></li>
<li><a href="https://instagram.com/febry_ardiansyah24">Instagram</a></li>
<li><a href="https://www.facebook.com/febry.ardiansyah.792/">Facebook</a></li>
</ul>
</nav>
<script src="index.js"></script>
</body>
</html>
6 changes: 0 additions & 6 deletions public/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
'use strict';
const e = React.createElement;
const App = require('./app')

const domContainer = document.querySelector('#root');
ReactDOM.render(e(App), domContainer);
31 changes: 31 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
html {
display: table;
margin: auto;
}
body{
height: 100%;
background-color: #E8505B;
margin: 0;
color: white;
}
nav ul{
margin:0;
padding:0;
display:flex;
justify-content:space-between;
text-align: center;
}
nav li{
list-style: none;
padding:1em 0;
}
nav li a{
color: white;
font-weight: bold;
opacity: 0.5;
text-decoration:none ;
transition:0.3s;
}
nav li a:hover{
opacity: 1;
}
8 changes: 7 additions & 1 deletion routers/handleError.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ router.get('/', function (req, res){
res.send('Welcome to Manga-API')
})

module.exports = router
const on404 =(req,res) => {
res.status(404).json({
manga_list:[]
})
}

module.exports = {router,on404}
13 changes: 9 additions & 4 deletions routers/manga.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const router = require('express').Router()
const cheerio = require('cheerio')
const baseUrl = require('../constants/urls')
const { default: Axios } = require('axios')
const on404 = require('./handleError').on404
const replaceMangaPage = 'https://komiku.co.id/manga/'

//manga popular ----Ignore this for now --------
Expand Down Expand Up @@ -73,7 +74,8 @@ router.get('/manga/page/:pagenumber',(req,res,next)=>{

res.status(200).json({manga_list})
}).catch(error => {
res.send(error)
on404(req,res)
console.log(err.message)
})
})

Expand Down Expand Up @@ -137,7 +139,8 @@ router.get('/genres/:slug/:pagenumber',(req,res,next)=>{
})
res.json({manga_list})
}).catch(err =>{
res.send(err)
on404(req,res)
console.log(err.message)
})
})

Expand All @@ -160,7 +163,8 @@ router.get('/manga/popular/:pagenumber',function(req,res,next) {
})
res.json({manga_list})
}).catch(err=>{
res.send(err)
on404(req,res)
console.log(err.message)
})
})

Expand Down Expand Up @@ -213,7 +217,8 @@ function getManhuaManhwa(req,res,type) {

res.status(200).json({manga_list})
}).catch(err =>{
res.send(err)
on404(req,res)
console.log(err.message)
})
}

Expand Down

0 comments on commit a812acb

Please sign in to comment.