Last active
December 13, 2017 17:53
-
-
Save nomoney4me/09ee2db70ce1fdbdfd87594630ed03eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
module.exports = function() { | |
return function(req, res, next) { | |
console.log('middleware') | |
next() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
const express = require('express') | |
, app = express() | |
, path = require('path') | |
, session = require('express-session') | |
let port = 3080; | |
app.use(session({ | |
secret: process.env.SECRET_KEY, | |
resave: false, | |
saveUninitialized: true, | |
cookie: { | |
//maxAge: 10000, | |
secure: false | |
} | |
})) | |
let requireLogin = require('./controllers/adLogin.js'); | |
app.use(express.static(path.join(__dirname, 'views'))) | |
app.use('/', require('./publicRoutes.js')()); | |
app.use('/api', requireLogin, require('./secureRoutes.js')()); | |
console.log('listening on port: '+port) | |
app.listen(port) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
const express = require('express') | |
, secureRouter = express.Router() | |
module.exports = () => { | |
secureRouter.get('/secure1', (req, res) => { | |
var json = { | |
foo1:'bar1' | |
} | |
if(req.params.id) json.id = req.params.id | |
res.json(json) | |
}); | |
secureRouter.get('/secure2', (req, res) => { | |
var json = { | |
foo2:'bar2' | |
} | |
res.json(json) | |
}); | |
return secureRouter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment