ardyhim

Untitled

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