-
Notifications
You must be signed in to change notification settings - Fork 1
/
startUp.ts
40 lines (32 loc) · 1.07 KB
/
startUp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as express from 'express'
import * as bodyParser from 'body-parser'
import Database from './infra/db'
import NewController from './controller/newController'
class StartUp {
public app: express.Application;
private _db: Database;
private bodyParser;
constructor() {
this.app = express();
this._db = new Database();
this._db.createConnection();
this.middler();
this.routes();
}
middler() {
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({ extended: false }));
}
routes() {
this.app.route('/').get((req, res) => {
res.send({ versao: '0.0.1' })
})
// new
this.app.route("/api/v1/news").get(NewController.get);
this.app.route("/api/v1/news/:id").get(NewController.getById);
this.app.route("/api/v1/news").post(NewController.create);
this.app.route("/api/v1/news/:id").put(NewController.update);
this.app.route("/api/v1/news/:id").delete(NewController.delete);
}
}
export default new StartUp();