-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (25 loc) · 767 Bytes
/
app.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
const express = require('express')
const cors = require('cors')
const { graphqlHTTP } = require('express-graphql')
require('./src/models')
require('./src/util/db').connectToDB
const { PORT } = require('./src/util/config')
const { movieSchema } = require('./src/schema/movie_schema')
const { movieResolvers } = require('./src/schema/movie_resolvers')
require('./src/models')
const app = express()
app.use(cors())
app.use(express.json())
app.use('/graphql', graphqlHTTP({
schema: movieSchema,
rootValue: movieResolvers,
graphiql: true,
}))
// Health check for github actions CD
app.get('/health', (_, res) => {
res.status(200).end()
})
const server = app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`)
})
module.exports = { server }