diff --git a/app.ts b/app.ts index 21bbd85..fca2c21 100644 --- a/app.ts +++ b/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); diff --git a/routes/api/apiRouter.js b/routes/api/apiRouter.js deleted file mode 100644 index d742c64..0000000 --- a/routes/api/apiRouter.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/routes/api/apiRouter.ts b/routes/api/apiRouter.ts new file mode 100644 index 0000000..e5b4de5 --- /dev/null +++ b/routes/api/apiRouter.ts @@ -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; \ No newline at end of file diff --git a/routes/api/cashTransactionRouter.js b/routes/api/cashTransactionRouter.js deleted file mode 100644 index f203d30..0000000 --- a/routes/api/cashTransactionRouter.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/routes/api/cashTransactionRouter.ts b/routes/api/cashTransactionRouter.ts new file mode 100644 index 0000000..dd8ac25 --- /dev/null +++ b/routes/api/cashTransactionRouter.ts @@ -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; \ No newline at end of file diff --git a/routes/api/gameRouter.js b/routes/api/gameRouter.js deleted file mode 100644 index b28d482..0000000 --- a/routes/api/gameRouter.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/routes/api/gameRouter.ts b/routes/api/gameRouter.ts new file mode 100644 index 0000000..36feaab --- /dev/null +++ b/routes/api/gameRouter.ts @@ -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; \ No newline at end of file diff --git a/routes/api/mediaRouter.js b/routes/api/mediaRouter.js deleted file mode 100644 index dccd67a..0000000 --- a/routes/api/mediaRouter.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/routes/api/mediaRouter.ts b/routes/api/mediaRouter.ts new file mode 100644 index 0000000..ed167ee --- /dev/null +++ b/routes/api/mediaRouter.ts @@ -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; \ No newline at end of file