Move router to controller

This commit is contained in:
Douglas Barone 2023-06-19 15:57:18 -04:00
parent aa0305d1cb
commit 220fc48b35
4 changed files with 11 additions and 13 deletions

View File

@ -1,7 +1,9 @@
import { Request, Response } from 'express'
import { Request, Response, Router } from 'express'
import { AuthenticationService } from '../services/AuthenticationService.js'
export class LoginController {
const router = Router()
class LoginController {
static async login(req: Request, res: Response) {
const { username, password } = req.body
@ -18,3 +20,7 @@ export class LoginController {
}
}
}
router.post('/', LoginController.login)
export default router

View File

@ -1,8 +0,0 @@
import { LoginController } from '../controllers/LoginController.js'
import { Router } from 'express'
const router = Router()
router.post('/', LoginController.login)
export default router

View File

@ -4,7 +4,7 @@ import bodyParser from 'body-parser'
import { injectUserMiddleware } from './middleware/injectUserMiddleware.js'
import { authMiddleware } from './middleware/authMiddleware.js'
import LoginRouter from './routers/LoginRouter.js'
import LoginRouter from './controllers/LoginController.js'
export const app = express()

View File

@ -14,8 +14,8 @@
"target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
"experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */