-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (31 loc) · 1.12 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
require('dotenv').config();
const { apolloServer } = require('./src/server/server');
const express = require('express');
const path = require('path');
const cors = require('cors');
const { createServer } = require('http');
// const { graphqlUploadExpress } = require('graphql-upload');
const appRoutes = require('./src/server/router/router');
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 4000;
const app = express();
app.use(express.static(path.join(__dirname, 'public/uploads')));
app.use(cors());
app.use(bodyParser.json());
// app.use(
// '/graphql',
// graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
// // graphqlHTTP({ schema })
// );
app.use("/graphql", appRoutes);
apolloServer.applyMiddleware({ app });
const httpServer = createServer(app);
apolloServer.installSubscriptionHandlers(httpServer, {
options: {
reconnect: true,
}
});
httpServer.listen({ port: PORT }, () => {
console.log(`🚀 Server ready at http://localhost:${PORT}${apolloServer.graphqlPath}`)
console.log(`🚀 Subscriptions ready at ws://localhost:${PORT}${apolloServer.subscriptionsPath}`)
})