🤖 Adding routes deprecated in the routes.ts

pull/33/head
capitanwesler 4 years ago
parent 6325d31cc1
commit b4cde8964e

@ -29,6 +29,11 @@
"name": "Darkangeel",
"url": "https://github.com/Darkangeel-hd",
"reason": "System administration authority (SYSADM)"
},
{
"name": "Capitanwesler",
"url": "https://github.com/capitanwesler",
"reason": "Backend and Frontend developer"
}
],
"engines": {

@ -1,4 +1,4 @@
import { Router, Request, Response } from 'express';
import { Router, Request, Response, NextFunction } from 'express';
import AnimeController from './controllers/AnimeController';
import DirectoryController from './controllers/DirectoryController';
import UtilsController from './controllers/UtilsController';
@ -111,4 +111,28 @@ routes.get('/api/v4/artists/:id?', utilsController.getArtist);
routes.get('/api/v4/destAnimePlatforms', utilsController.getDestAnimePlatforms);
routes.get('/api/v4/platforms/:id?', utilsController.getPlatforms);
/* Routes to handling the v3 deprecated */
// routes.get('/api/v3/*', (req: Request, res: Response, next: NextFunction) => {
// res.status(302).redirect('/api/v2');
// });
// routes.get('/api/v3', (req: Request, res: Response, next: NextFunction) => {
// res.status(200).json({
// message:
// 'Sorry, version v3 is not avaiable, if you want to see content go to v4',
// });
// });
/* Routes to handling the v2 deprecated */
routes.get('/api/v2/*', (req: Request, res: Response, next: NextFunction) => {
res.status(302).redirect('/api/v2');
});
routes.get('/api/v2', (req: Request, res: Response, next: NextFunction) => {
res.status(200).json({
message:
'Sorry, version v2 is not avaiable, if you want to see content go to v4',
});
});
export default routes;

@ -8,6 +8,7 @@ import {
// createConnectionRedis,
} from './database/connection';
import routes from './routes';
import { Server } from 'node:http';
const app: Application = express();
@ -34,4 +35,13 @@ app.use(errorHandler);
is going to listen in the server.
ex: PORT=3000.
*/
app.listen(process.env.PORT_LISTEN || 3000);
const server: Server = app.listen(process.env.PORT_LISTEN || 3000);
function shutdown(): void {
server.close();
process.exit();
}
process.on('SIGINT', shutdown);
process.on('SIGQUIT', shutdown);
process.on('SIGTERM', shutdown);

Loading…
Cancel
Save