-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (27 loc) · 716 Bytes
/
index.js
File metadata and controls
33 lines (27 loc) · 716 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
const express = require('express');
const path = require('path');
const {graphqlHTTP} = require('express-graphql');
const sequelize = require('./utils/database');
const schema = require('./graphql/schema');
const resolver = require('./graphql/resolver');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.json());
app.use(graphqlHTTP({
schema: schema,
rootValue: resolver,
graphiql: true,
}));
app.use((req, res, next) => {
res.sendFile('/index.html');
});
async function start() {
try {
await sequelize.sync();
app.listen(PORT);
} catch (e) {
console.log(e);
}
}
start();