-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
33 lines (27 loc) · 771 Bytes
/
index.ts
File metadata and controls
33 lines (27 loc) · 771 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 "@total-typescript/ts-reset";
import express from "express";
import path from "path";
import cookieParser from "cookie-parser";
import logger from "morgan";
import { graphqlHTTP } from "express-graphql";
import { application } from "./gql-application";
const app = express();
const port = 4000;
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
const execute = application.createExecution();
const schema = application.schema;
app.use(
"/graphql",
graphqlHTTP({
schema,
customExecuteFn: execute,
graphiql: true
})
);
app.listen(port, () => {
console.log(`Running a server at http://localhost:${port}`);
});