How to separate routes from app #266
-
There is any way to do that like in express app? var express = require('express')
var router = express.Router()
// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
console.log('Time: ', Date.now())
next()
})
// define the home page route
router.get('/', function (req, res) {
res.send('Birds home page')
})
// define the about route
router.get('/about', function (req, res) {
res.send('About birds')
})
module.exports = router then import in main app var birds = require('./birds')
// ...
app.use('/birds', birds) |
Beta Was this translation helpful? Give feedback.
Answered by
talentlessguy
Jun 16, 2021
Replies: 1 comment 1 reply
-
hello, in tinyhttp you should use subapps instead e.g. const subApp = new App()
app.use(subApp) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lucascebertin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello, in tinyhttp you should use subapps instead
e.g.