-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.ts
44 lines (35 loc) · 972 Bytes
/
app.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
import { config } from 'dotenv';
import { use, schema, settings, server } from 'nexus';
import { prisma } from 'nexus-plugin-prisma';
import { PrismaClient } from 'nexus-plugin-prisma/client';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
import * as helmet from 'helmet';
import * as compression from 'compression';
config();
import { ContextInit } from './services/Context';
import { ResourceCheckMiddleware } from './middleware/resource-check';
const prismaClient = new PrismaClient();
use(
prisma({
client: {
instance: prismaClient,
},
})
);
schema.addToContext(request => {
return ContextInit({
request,
db: prismaClient,
});
});
settings.change({
logger: {
pretty: true,
},
});
server.express.use(bodyParser.json());
server.express.use(cors());
server.express.use(helmet());
server.express.use(compression());
schema.middleware(ResourceCheckMiddleware);