⬆️ update some preferences and remove unnecesary files
parent
eee3600940
commit
a77af3d32f
@ -1,8 +0,0 @@
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
// import morgan from 'morgan';
|
||||
import routes from './router.js';
|
||||
const app = express();
|
||||
// app.use(cors(), morgan('dev'));
|
||||
app.use('/', routes);
|
||||
export default app;
|
@ -1,28 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const maskScrapingHeaders = {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
|
||||
};
|
||||
|
||||
const url = 'https://monoschinos2.com';
|
||||
|
||||
export const api = {
|
||||
home: `${url}`,
|
||||
all: (id) => `${url}/animes?p=${id}`,
|
||||
emision: (id) => `${url}/emision?p=${id}`,
|
||||
calendar: `${url}/calendario`,
|
||||
search: (id, page) => `${url}/buscar?q=${id.replace(/\s/g, '+')}&p=${page}`,
|
||||
anime: (id) => `${url}/anime/${id}`,
|
||||
episode: (id) => `${url}/ver/${id}`,
|
||||
gender: (id) => `${url}/genero/${id}`,
|
||||
filter: ({ categoria, fecha, genero, letra, pagina }) =>
|
||||
`${url}/animes?categoria=${categoria}&genero=${genero}&fecha=${fecha}&letra=${letra}&p=${pagina}`,
|
||||
};
|
||||
export function attr(html, selector, attribute = 'src') {
|
||||
return html.querySelector(selector)?.attributes[attribute];
|
||||
}
|
||||
|
||||
export function get(url) {
|
||||
return axios.get(url, { headers: { ...maskScrapingHeaders } });
|
||||
}
|
@ -1,7 +1,13 @@
|
||||
import app from './app.js';
|
||||
const port = process.env.PORT || 5000;
|
||||
import express from 'express'
|
||||
import routes from './router'
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use('/', routes)
|
||||
|
||||
const port = process.env.PORT || 5000
|
||||
|
||||
app.listen(port, () => {
|
||||
console.clear();
|
||||
console.info(`API Running on: ${port} ============================`);
|
||||
});
|
||||
console.clear()
|
||||
console.info(`API Running on: ${port} ============================`)
|
||||
})
|
||||
|
@ -1,61 +0,0 @@
|
||||
import { Router } from 'express';
|
||||
const routes = Router();
|
||||
|
||||
import {
|
||||
getEmision,
|
||||
getLastest,
|
||||
getCalendar,
|
||||
getAnimes,
|
||||
filterBy,
|
||||
searchAnime,
|
||||
getEpisode,
|
||||
getAnime,
|
||||
} from './controllers/index.js';
|
||||
|
||||
routes.get('/', (_, res) => {
|
||||
res.json({
|
||||
message: 'API Works',
|
||||
author: 'Carlos Burelo',
|
||||
repository: 'https://github.com/carlos-burelo/monoschinos-api-v2',
|
||||
endpoints: {
|
||||
lastest: '/lastest',
|
||||
emision: '/emision',
|
||||
calendar: '/week',
|
||||
getAnimeByID: '/anime/:id',
|
||||
getAnimesByPage: '/all',
|
||||
getEpisodeByID: '/ver/:id',
|
||||
searchAnimeByID: '/search/:id',
|
||||
filterBy: {
|
||||
path: '/filterBy',
|
||||
querys: ['categoria', 'fecha', 'genero', 'letra', 'pagina'],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
routes.get('/lastest', (req, res) => {
|
||||
getLastest(req, res);
|
||||
});
|
||||
routes.get('/emision', (req, res) => {
|
||||
getEmision(req, res);
|
||||
});
|
||||
routes.get('/week', (req, res) => {
|
||||
getCalendar(req, res);
|
||||
});
|
||||
routes.get('/all', (req, res) => {
|
||||
getAnimes(req, res);
|
||||
});
|
||||
routes.get('/filterBy', (req, res) => {
|
||||
filterBy(req, res);
|
||||
});
|
||||
routes.get('/search/:id', (req, res) => {
|
||||
searchAnime(req, res);
|
||||
});
|
||||
routes.get('/ver/:id', (req, res) => {
|
||||
getEpisode(req, res);
|
||||
});
|
||||
routes.get('/anime/:id', (req, res) => {
|
||||
getAnime(req, res);
|
||||
});
|
||||
|
||||
export default routes;
|
@ -0,0 +1,45 @@
|
||||
import { Router } from 'express'
|
||||
import {
|
||||
getAll,
|
||||
getLastest,
|
||||
getCalendar,
|
||||
getEmision,
|
||||
getAnime,
|
||||
searchAnime,
|
||||
getEpisode,
|
||||
filterBy,
|
||||
} from './controllers'
|
||||
|
||||
const routes = Router()
|
||||
|
||||
routes.get('/', (_, res) => {
|
||||
res.json({
|
||||
message: 'API Works',
|
||||
author: 'Carlos Burelo',
|
||||
repository: 'https://github.com/carlos-burelo/monoschinos-api-v2',
|
||||
endpoints: {
|
||||
lastest: '/lastest',
|
||||
emision: '/emision',
|
||||
calendar: '/week',
|
||||
getAnimeByID: '/anime/:id',
|
||||
getAnimesByPage: '/all',
|
||||
getEpisodeByID: '/ver/:id',
|
||||
searchAnimeByID: '/search/:id',
|
||||
filterBy: {
|
||||
path: '/filterBy',
|
||||
querys: ['categoria', 'fecha', 'genero', 'letra', 'pagina'],
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
routes.get('/all', getAll)
|
||||
routes.get('/lastest', getLastest)
|
||||
routes.get('/week', getCalendar)
|
||||
routes.get('/emision', getEmision)
|
||||
routes.get('/anime/:id', getAnime)
|
||||
routes.get('/search/:id', searchAnime)
|
||||
routes.get('/ver/:id', getEpisode)
|
||||
routes.get('/filterBy', filterBy)
|
||||
|
||||
export default routes
|
Loading…
Reference in New Issue