-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
808 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import express from 'express'; | ||
import alerts from './routers/alerts'; | ||
import users from './routers/users'; | ||
|
||
export default class Server { | ||
private _application: express.Application; | ||
|
||
constructor() { | ||
this._application = express(); | ||
this.setupTopMiddlewares(); | ||
this.setupRouters(); | ||
this.setupBottomMiddlewares(); | ||
} | ||
|
||
get application() { | ||
return this._application; | ||
} | ||
|
||
private setupTopMiddlewares() { | ||
this._application.use(express.json()); | ||
} | ||
|
||
private setupRouters() { | ||
this._application.use('/users', users); | ||
this._application.use('/alerts', alerts); | ||
} | ||
|
||
private setupBottomMiddlewares() { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
this._application.use((error: Error, _request: express.Request, response: express.Response, _next: express.NextFunction) => { | ||
console.log(error); | ||
|
||
return response.status(500).json({ message: 'Internal Server Error' }); | ||
}); | ||
} | ||
} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Request, Response, Router } from 'express'; | ||
|
||
const router = Router(); | ||
// const alertService = new AlertService(new PgAlertRepository()); | ||
|
||
router.post('/', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
router.delete('/:id', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Request, Response, Router } from 'express'; | ||
|
||
const router = Router(); | ||
// const userService = new UserService(new PgUserRepository(), new BcryptEncryptor()); | ||
|
||
router.post('/', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
router.get('/:id', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
router.get('', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
router.put('/:id', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
router.delete('/:id', (_request: Request, response: Response) => { | ||
return response.status(204).json(); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|