ardyhim

Untitled

Dec 11th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2.  
  3. const express = require('express'),
  4.       config = require('./config'),
  5.       https = require('https'),
  6.       app = express(),
  7.       port = config.port,
  8.       bodyParser = require('body-parser'),
  9.       cors = require('cors');
  10.  
  11. //route mapping
  12. const login = require('./app/routes/login'),
  13.       assignments = require('./app/routes/assignments'),
  14.       timeSheet = require('./app/routes/timeSheet'),
  15.       testMSPS = require('./app/routes/testMSPS')
  16.  
  17. //prevent cross-origin-conflict
  18. // app.use((req, res, next) => {
  19. //   res.header("Access-Control-Allow-Origin", "*")
  20. //   res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
  21. //   res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token")
  22. //   res.header("Access-Control-Allow-Credentials", true);
  23. //   next()
  24. // })
  25. app.use(cors());
  26. app.use(bodyParser.json());
  27. app.use(bodyParser.urlencoded({ extended: false }));
  28.  
  29. //Utilize the given middleware handle to the given route, defaulting to /.
  30. app.use('/login', login)
  31. app.use('/assignments', assignments)
  32. app.use('/testMSPS', testMSPS)
  33. //app.use('/timeSheet', timeSheet)
  34.  
  35.  
  36. // let server  = https.createServer({
  37. //   key: fs.readFileSync('privkey.pem', 'ascii')
  38. // , cert: fs.readFileSync('fullchain.pem', 'ascii') // a PEM containing the SERVER and ALL INTERMEDIATES
  39. // })
  40. // const server = https.createServer(options, app).listen(port, function () {
  41. //   console.log(`...server is listening on port:${port}...`)
  42. // })
  43. app.listen(port, function () {
  44.   console.log(`...server is listening on port:${port}...`)
  45. })
Advertisement
Add Comment
Please, Sign In to add comment