Last active
December 13, 2017 17:50
-
-
Save nomoney4me/6a8d1c503c139833e7a09b7ec13c9411 to your computer and use it in GitHub Desktop.
Sample routes for nodejs
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
const express = require('express') | |
, app = express(); | |
let port = 3080; | |
app.use('/', require('./publicRoutes.js')()); | |
app.use('/api', require('./secureRoutes.js')()); | |
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
const express = require('express') | |
, publicRouter = express.Router(); | |
module.exports = () => { | |
publicRouter.get('/frontpage', (req, res) => { | |
res.render('frontpage1.html') | |
}); | |
publicRouter.get('/frontpage2', (req, res) => { | |
res.render('frontpage2.html') | |
}); | |
return publicRouterl; | |
} |
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
const express = require('express') | |
, secureRouter = express.Router(); | |
module.exports = () => { | |
secureRouter.get('/secure1', (req, res) => { | |
res.json('secure1.json') | |
}); | |
secureRouter.get('/secure2', (req, res) => { | |
res.json('secure2.json') | |
}); | |
return secureRouter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment