-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
46 lines (33 loc) · 1.25 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// const { ApolloServer } = require('apollo-server-express')
// const express = require('express')
const { ApolloServer } = require('apollo-server')
require('dotenv').config()
const { sequelize } = require('./models')
// console.log("this is the current working directory ", __dirname)
const resolvers = require('./graphql/resolvers')
const typeDefs = require('./graphql/typeDefs')
const contextMiddleware = require('./util/contextMiddleware')
const server = new ApolloServer({
typeDefs,
resolvers,
context: contextMiddleware,
})
// const app = express()
// server.applyMiddleware({app})
// app.use(express.static("public"))
// app.listen({port:4000}, () => {
// console.log(`🚀 Server ready at http://localhost:4000/`)
// console.log(`🚀 Susbscription ready at ws://localhost:4000/graphql`)
// sequelize
// .authenticate()
// .then(() => console.log('Database connected!!'))
// .catch((err) => console.log(err))
// })
server.listen({port:process.env.PORT || 4000}).then(({ url, subscriptionsUrl }) => {
console.log(`🚀 Server ready at ${url}`)
console.log(`🚀 Susbscription ready at ${subscriptionsUrl}`)
sequelize
.authenticate()
.then(() => console.log('Database connected!!'))
.catch((err) => console.log(err))
})