-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (39 loc) · 1.03 KB
/
index.js
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
45
46
47
48
49
const { ApolloServer } = require("apollo-server-express");
const express = require("express");
const sequelize = require("./util/database");
const { graphqlUploadExpress } = require("graphql-upload");
// const User = require("./model/user");
const resolvers = require("./graphql/resolvers");
const typeDefs = require("./graphql/typeDefs");
const contextMiddleware = require("./util/contextMiddleware");
const startServer = async () => {
const server = new ApolloServer({
typeDefs,
resolvers,
context: contextMiddleware,
uploads: false,
});
await server.start();
const app = express();
app.use(
graphqlUploadExpress({
maxFileSize: 30000000,
maxFiles: 20,
})
);
sequelize
.sync()
.then((result) => {
console.log("Synced");
})
.catch((err) => {
console.log("Err");
});
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
server.applyMiddleware({ app });
console.log("Success at " + PORT);
});
};
startServer();
//http://localhost:4000/graphql