-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
38 lines (33 loc) · 1.01 KB
/
index.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
import * as fastify from "fastify";
import * as fastifyBlipp from "fastify-blipp";
import {Server, IncomingMessage, ServerResponse} from "http";
import cors = require("cors");
import controllers from './src/WebApi/index'
import persistence from './src/Core/Infrastracture/Persistence/applicationDbContext'
import services from './src/Core/Domain/serviceCollections'
const server: fastify.FastifyInstance<
Server,
IncomingMessage,
ServerResponse> = fastify();
server.use(cors())
server.register(fastifyBlipp);
server.register(persistence) // registering persistence
server.register(services) // registering services
server.register(controllers);
const start = async () => {
try {
await server.listen(3000, 'localhost');
server.blipp();
} catch (err) {
console.log(err);
server.log.error(err);
process.exit(1);
}
};
process.on("uncaughtException", error => {
console.error(error);
});
process.on("unhandledRejection", error => {
console.error(error);
});
start();