generated from tsedio/tsed-example-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.ts
48 lines (41 loc) · 1.04 KB
/
Server.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
41
42
43
44
45
46
47
48
import "@tsed/ajv";
import {PlatformApplication} from "@tsed/common";
import {Configuration, Inject} from "@tsed/di";
import "@tsed/platform-express"; // /!\ keep this import
import bodyParser from "body-parser";
import compress from "compression";
import cookieParser from "cookie-parser";
import cors from "cors";
import methodOverride from "method-override";
import "./v2/modules/graphql/GraphQLModule";
import "./v1/modules/graphql/GraphQLModule";
export const rootDir = __dirname;
@Configuration({
rootDir,
acceptMimes: ["application/json"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
mount: {},
exclude: [
"**/*.spec.ts"
]
})
export class Server {
@Inject()
app: PlatformApplication;
@Configuration()
settings: Configuration;
$beforeRoutesInit(): void {
this.app
.use(cors())
.use(cookieParser())
.use(compress({}))
.use(methodOverride())
.use(bodyParser.json())
.use(bodyParser.urlencoded({
extended: true
}));
}
$afterRoutesInit() {
}
}