Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- const express = require('express'),
- config = require('./config'),
- https = require('https'),
- app = express(),
- port = config.port,
- bodyParser = require('body-parser'),
- cors = require('cors');
- //route mapping
- const login = require('./app/routes/login'),
- assignments = require('./app/routes/assignments'),
- timeSheet = require('./app/routes/timeSheet'),
- testMSPS = require('./app/routes/testMSPS')
- //prevent cross-origin-conflict
- // app.use((req, res, next) => {
- // res.header("Access-Control-Allow-Origin", "*")
- // res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
- // res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token")
- // res.header("Access-Control-Allow-Credentials", true);
- // next()
- // })
- app.use(cors());
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({ extended: false }));
- //Utilize the given middleware handle to the given route, defaulting to /.
- app.use('/login', login)
- app.use('/assignments', assignments)
- app.use('/testMSPS', testMSPS)
- //app.use('/timeSheet', timeSheet)
- // let server = https.createServer({
- // key: fs.readFileSync('privkey.pem', 'ascii')
- // , cert: fs.readFileSync('fullchain.pem', 'ascii') // a PEM containing the SERVER and ALL INTERMEDIATES
- // })
- // const server = https.createServer(options, app).listen(port, function () {
- // console.log(`...server is listening on port:${port}...`)
- // })
- app.listen(port, function () {
- console.log(`...server is listening on port:${port}...`)
- })
Advertisement
Add Comment
Please, Sign In to add comment