1.5.22
What's Changed
- Use
getServiceRouter(Application)
method to get an instance of service router running for the given express application. Use this operation if you want to customize the stack of service by adding new functionality e.g. customize router to have a default$top
query option.
import { getServiceRouter } from '@themost/express';
// ...
// initialize app
// ...
const router = getServiceRouter(app);
const addRoute = express.Router();
// add a middleware before /:entitySet and set default $top query option
addRoute.get('/:entitySet', function customMiddleware(req, res, next) {
if (Object.prototype.hasOwnProperty.call(req.query, '$top') === false) {
Object.assign(req.query, { $top: 100 });
}
return next();
});
router.stack.unshift(...addRoute.stack);