brennancheung / express-remove-route Goto Github PK
View Code? Open in Web Editor NEWDelete a route in express at runtime.
License: MIT License
Delete a route in express at runtime.
License: MIT License
The following 3 lines removes endpoints:
function deleteUserRouter(endpoint: string) {
app.stack = app.stack.filter((app) => app.route.path !== `/${endpoint}`);
}
Why have a whole package to do this
Looks like, after making code changes, the package.json wasn't updated so, if I npm install …
I still get old code
1.if a uri not exist,but use removeRoute(app,uri),it will remove last routers,so i think you should to
check idx > 0,
idx = stack.indexOf(route);
stack.splice(idx, 1);
当mock数据更新时,我们用这个库来动态删除路由。
因为直接引入这个库会报错,于是copy一份到本地,然后改写。
问题:更新mock文件时,动态删除路由失败。mock数据不能更新。
解决方法:
改写后的完整代码:https://gist.github.com/hughfenghen/a79d6182db2bfc029f222b7dd0e48bb4
The package.json doesn't list any dependencies, but there are dependencies.
Hi!
The error happened after executing the removeRoute a second time using a different path. (version 0.1.1)
TypeError: Cannot read property 'route' of null
at removeRoute (/git/documentcloud-ui/node_modules/express-remove-route/index.js:5:18)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.