UP api -> ts
This commit is contained in:
parent
ae2aa8c120
commit
e14d405ca2
2
app.ts
2
app.ts
@ -24,7 +24,7 @@ app.use(express.urlencoded({ extended: false }));
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
import mainRouter from './routes/main';
|
||||
var apiRouter = require('./routes/api/apiRouter');
|
||||
import apiRouter from './routes/api/apiRouter';
|
||||
|
||||
app.use('/', mainRouter);
|
||||
app.use('/api', apiRouter);
|
||||
|
@ -1,18 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
var mediaRouter = require('./mediaRouter');
|
||||
var gameRouter = require('./gameRouter');
|
||||
var cashTransactionRouter = require('./cashTransactionRouter');
|
||||
|
||||
router.use('/games', gameRouter);
|
||||
router.use('/movies', mediaRouter);
|
||||
router.use('/series', mediaRouter);
|
||||
router.use('/cash', checkAuthenticated, cashTransactionRouter);
|
||||
|
||||
router.get('/', function (req, res, next) {
|
||||
res.status(200).json({ message: 'API is working' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
19
routes/api/apiRouter.ts
Normal file
19
routes/api/apiRouter.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import express, { type Request, type Response } from "express";
|
||||
const router = express.Router();
|
||||
|
||||
import checkAuthenticated from '../../miscellaneous/checkAuthenticated';
|
||||
|
||||
import mediaRouter from './mediaRouter';
|
||||
import gameRouter from './gameRouter';
|
||||
import cashTransactionRouter from './cashTransactionRouter';
|
||||
|
||||
router.use('/games', gameRouter);
|
||||
router.use('/movies', mediaRouter);
|
||||
router.use('/series', mediaRouter);
|
||||
router.use('/cash', checkAuthenticated, cashTransactionRouter);
|
||||
|
||||
router.get('/', function (req: Request, res: Response) {
|
||||
res.status(200).json({ message: 'API is working' });
|
||||
});
|
||||
|
||||
export default router;
|
@ -1,11 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const cashTransaction = require('../../controllers/cashTransactionController.js')
|
||||
|
||||
router.post('/list', cashTransaction.list);
|
||||
|
||||
router.post('/', cashTransaction.create);
|
||||
|
||||
router.delete('/', cashTransaction.delete);
|
||||
|
||||
module.exports = router;
|
11
routes/api/cashTransactionRouter.ts
Normal file
11
routes/api/cashTransactionRouter.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import cashTransaction from '../../controllers/cashTransactionController.js';
|
||||
|
||||
router.post('/list', cashTransaction.list);
|
||||
|
||||
router.post('/', cashTransaction.create);
|
||||
|
||||
router.delete('/', cashTransaction.delete);
|
||||
|
||||
export default router;
|
@ -1,12 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var gameController = require('../../controllers/gameController.js');
|
||||
var checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
router.get('/', gameController.list);
|
||||
|
||||
router.post('/', checkAuthenticated, gameController.create);
|
||||
|
||||
router.delete('/', checkAuthenticated, gameController.remove);
|
||||
|
||||
module.exports = router;
|
12
routes/api/gameRouter.ts
Normal file
12
routes/api/gameRouter.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import express from "express";
|
||||
var router = express.Router();
|
||||
import gameController from '../../controllers/gameController.js';
|
||||
import checkAuthenticated from '../../miscellaneous/checkAuthenticated';
|
||||
|
||||
router.get('/', gameController.list);
|
||||
|
||||
router.post('/', checkAuthenticated, gameController.create);
|
||||
|
||||
router.delete('/', checkAuthenticated, gameController.remove);
|
||||
|
||||
export default router;
|
@ -1,12 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var mediaController = require('../../controllers/mediaController.js');
|
||||
var checkAuthenticated = require('../../miscellaneous/checkAuthenticated.js').default;
|
||||
|
||||
router.get('/', mediaController.list);
|
||||
|
||||
router.post('/', checkAuthenticated, mediaController.create);
|
||||
|
||||
router.delete('/', checkAuthenticated, mediaController.remove);
|
||||
|
||||
module.exports = router;
|
13
routes/api/mediaRouter.ts
Normal file
13
routes/api/mediaRouter.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import express from "express";
|
||||
import mediaController from '../../controllers/mediaController.js';
|
||||
import checkAuthenticated from '../../miscellaneous/checkAuthenticated';
|
||||
|
||||
var router = express.Router();
|
||||
|
||||
router.get('/', mediaController.list);
|
||||
|
||||
router.post('/', checkAuthenticated, mediaController.create);
|
||||
|
||||
router.delete('/', checkAuthenticated, mediaController.remove);
|
||||
|
||||
export default router;
|
Loading…
x
Reference in New Issue
Block a user