-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathserver.ts
More file actions
33 lines (27 loc) · 763 Bytes
/
server.ts
File metadata and controls
33 lines (27 loc) · 763 Bytes
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
import Express, { Application } from 'express';
import Cors from 'cors';
import Routes from './api/Routes';
class Server {
private application: Application
private port: number | string
constructor() {
this.port = process.env.PORT || 3300;
this.application = Express();
this.plugins();
this.routes();
}
private plugins(): void {
this.application.use(Express.urlencoded({ extended: true }));
this.application.use(Express.json());
this.application.use(Cors());
}
private routes(): void {
this.application.use(Routes);
}
public run(): void {
this.application.listen(this.port, () => {
console.log(`Server listening on http://localhost:${this.port}`);
});
}
}
export default new Server().run();