-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
39 lines (32 loc) · 1.06 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
39
import * as dotenv from "dotenv";
import "reflect-metadata";
dotenv.config();
import { buildSchema } from "type-graphql";
import mongoose from "mongoose";
import { ApolloServer, } from "apollo-server";
// modules
import { resolvers } from "./gql/resolvers";
// config
const PORT = process.env.PORT || 5000;
const bootstrap = async () => {
const schema = await buildSchema({ resolvers });
const server = new ApolloServer({
schema,
playground: true,
context: ({ req }) => ({ req }),
tracing: true,
});
mongoose
.connect("mongodb://localhost:27017/iconicTodo", {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
})
.then(() => {
return server.listen({ port: PORT });
})
.then((res) => {
return console.log("gql server online 🎉");
});
};
bootstrap()