Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
3,943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import express from 'express'
  2. import path from 'path'
  3. import chalk from 'chalk'
  4. import bodyParser from 'body-parser'
  5. import { graphqlExpress } from 'apollo-server-express'
  6.  
  7. import schema from './graphql/schema'
  8. import config from './config'
  9.  
  10. const app = express()
  11.  
  12. app.use('/', express.static(path.resolve(__dirname, '/../public')))
  13.  
  14. app.get('/', (req, res) => {
  15. res.send({
  16. message: 'Hi Shiv, To get access please find the credentials with given query'
  17. })
  18. })
  19.  
  20. app.use('/graphql', bodyParser.json(), graphqlExpress({
  21. schema
  22. }))
  23.  
  24.  
  25. app.listen(config.PORT, () => {
  26. const log = console.log
  27. log('\n')
  28. log(chalk.bgGreen.black(`Server listening on http://localhost:${config.PORT}/ ..`))
  29. log('\n')
  30.  
  31. log(`${chalk.blue('/graphql')} - endpoint for queries`)
  32. log('\n')
  33. })
  34.  
  35. export default app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement