diff --git a/controllers/gameController.ts b/controllers/gameController.ts index d996ed2..b413577 100644 --- a/controllers/gameController.ts +++ b/controllers/gameController.ts @@ -28,9 +28,9 @@ export default { const uri = "https://id.twitch.tv/oauth2/token?client_id=" + userFound.twitch_client_id + "&client_secret=" + userFound.twitch_client_secret + "&grant_type=client_credentials"; var response = await fetch(uri, { method: 'POST' }); - var mData = await response.json(); + const mData = await response.json(); - var mheaders = { + const mheaders = { 'Accept': 'application/json', 'Client-ID': userFound.twitch_client_id, 'Authorization': 'Bearer ' + mData.access_token @@ -51,9 +51,9 @@ export default { return res.status(404).json({ message: 'wrong code' }); } - var date = new Date(gameData[0].first_release_date * 1000); + const date = new Date(gameData[0].first_release_date * 1000); const options: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'short', year: 'numeric' } - var dateStr = date.toLocaleDateString(undefined, options); + const dateStr = date.toLocaleDateString(undefined, options); response = await fetch( @@ -83,7 +83,7 @@ export default { }, remove: async function (req: Request, res: Response) { - var id = req.body.code; + const id = req.body.code; try { const movie = await GameModel.findOneAndDelete({ code: id }); diff --git a/controllers/mediaController.ts b/controllers/mediaController.ts index 299125a..a7c4034 100644 --- a/controllers/mediaController.ts +++ b/controllers/mediaController.ts @@ -65,7 +65,7 @@ export default { * mediaController.delete() */ remove: async function (req: Request, res: Response) { - var id = req.body.code; + const id = req.body.code; try { diff --git a/miscellaneous/checkAuthenticated.ts b/miscellaneous/checkAuthenticated.ts index 9545479..ba22534 100644 --- a/miscellaneous/checkAuthenticated.ts +++ b/miscellaneous/checkAuthenticated.ts @@ -1,4 +1,4 @@ -import { type Express, type NextFunction, type Request, type Response } from "express"; +import { type NextFunction, type Request, type Response } from "express"; import UserModel from '../models/userModel'; diff --git a/routes/api/apiRouter.ts b/routes/api/apiRouter.ts index e5b4de5..87710a6 100644 --- a/routes/api/apiRouter.ts +++ b/routes/api/apiRouter.ts @@ -1,12 +1,11 @@ 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'; +const router = express.Router(); + router.use('/games', gameRouter); router.use('/movies', mediaRouter); router.use('/series', mediaRouter); diff --git a/routes/api/cashTransactionRouter.ts b/routes/api/cashTransactionRouter.ts index 7e25c48..26546b8 100644 --- a/routes/api/cashTransactionRouter.ts +++ b/routes/api/cashTransactionRouter.ts @@ -1,7 +1,8 @@ import express from "express"; -const router = express.Router(); import cashTransaction from '../../controllers/cashTransactionController'; +const router = express.Router(); + router.post('/list', cashTransaction.list); router.post('/', cashTransaction.create); diff --git a/routes/api/gameRouter.ts b/routes/api/gameRouter.ts index d242f2c..785ae98 100644 --- a/routes/api/gameRouter.ts +++ b/routes/api/gameRouter.ts @@ -1,8 +1,9 @@ import express from "express"; -var router = express.Router(); import gameController from '../../controllers/gameController'; import checkAuthenticated from '../../miscellaneous/checkAuthenticated'; +const router = express.Router(); + router.get('/', gameController.list); router.post('/', checkAuthenticated, gameController.create); diff --git a/routes/api/mediaRouter.ts b/routes/api/mediaRouter.ts index ed167ee..4a5a069 100644 --- a/routes/api/mediaRouter.ts +++ b/routes/api/mediaRouter.ts @@ -2,7 +2,7 @@ import express from "express"; import mediaController from '../../controllers/mediaController.js'; import checkAuthenticated from '../../miscellaneous/checkAuthenticated'; -var router = express.Router(); +const router = express.Router(); router.get('/', mediaController.list); diff --git a/routes/main.ts b/routes/main.ts index 85c3a1e..d177129 100644 --- a/routes/main.ts +++ b/routes/main.ts @@ -1,8 +1,8 @@ import express, { type Request, type Response } from "express"; -const router = express.Router(); - import userData from './userKnowledge.json'; +const router = express.Router(); + /* GET home page. */ router.get('/', function (req: Request, res: Response) { const project = userData.project; diff --git a/routes/user.ts b/routes/user.ts index 1d1242c..63b4c17 100644 --- a/routes/user.ts +++ b/routes/user.ts @@ -1,9 +1,9 @@ import express, { type Request, type Response } from "express"; -var router = express.Router(); import userController from '../controllers/userController'; - import checkAuthenticated from '../miscellaneous/checkAuthenticated'; +const router = express.Router(); + /* GET home page. */ router.get('/', function (req: Request, res: Response) { res.render('user', { title: 'Register' });