-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (19 loc) · 823 Bytes
/
server.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
const express = require("express");
const cors = require("cors");
const dotenv = require("dotenv");
const { ApolloServer } = require("apollo-server-express");
const { typeDefs, resolvers } = require("./model/graphqlSchema/schema");
const path = require('path')
const server = new ApolloServer({ typeDefs, resolvers });
const app = express();
server.applyMiddleware({ app });
dotenv.config({ path: "./config/.env" });
var PORT = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
const publicDirectoryPath = path.join(__dirname, '/server/public')
app.use(express.static(publicDirectoryPath))
app.listen(PORT, () =>
console.log(`🚀 Server ready at http://localhost:${PORT} | GraphQL Server: http://localhost:${PORT}${server.graphqlPath}`)
);