Возможно, вам нужно добавить express зависимость в ваш пакет json и экспортировать функцию xrouter.
Я использовал этот пример для проверки express маршрутизации
package.json
{
"name": "sample-http",
"version": "0.0.1",
"dependencies": {
"express": "^4.16.4"
}
}
index.js
const express = require('express');
const app = express();
var router = express.Router()
// a middleware function with no mount path. This code is executed for every request to the router
router.use(function (req, res, next) {
console.log('Time:', Date.now())
next()
})
// a middleware sub-stack shows request info for any type of HTTP request to the /user/:id path
router.use('/user/:id', function (req, res, next) {
console.log('Request URL:', req.originalUrl)
next()
}, function (req, res, next) {
console.log('Request Type:', req.method)
next()
})
// a middleware sub-stack that handles GET requests to the /user/:id path
router.get('/user/:id', function (req, res, next) {
// if the user ID is 0, skip to the next router
if (req.params.id === '0') next('route')
// otherwise pass control to the next middleware function in this stack
else next()
}, function (req, res, next) {
// render a regular page
res.send('regular')
})
// handler for the /user/:id path, which renders a special page
router.get('/user/:id', function (req, res, next) {
console.log(req.params.id)
res.send('special')
})
// mount the router on the app
app.use('/', router)
exports.xrouter = app;
функция, которую вам нужно вызвать - xrouter