![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
express-resource-router
Advanced tools
Simple and semantic restful resource routing for Express
npm install --save express-resource-router
The API is simple - when you require the module, you will be returned the express.Router()
function with eight
new methods appended:
resource
- allows for autoloading of the resource being describedindex
- sets up a '/' get routenew
- sets up a '/new' get routecreate
- sets up a '/' post routeshow
- sets up a '/:id' get routeedit
- sets up a '/:id/edit' get routeupdate
- sets up a '/:id' put routedestroy
- sets up a '/:id' delete route// lets assume this is routes/posts.js
var router = require('express-resource-router');
router.resource(function(id, setResource) {
// the third argument is optional - it sets req.post
// in this case, but req.resource is the default
setResource(null, Post.find(id), 'post');
});
router.index(function(req, res) {
res.render('posts/index', { posts: Post.all() });
});
router.new(function(req, res) {
res.render('posts/new', { post: new Post() });
});
router.create(function(req, res) {
var post = Post.create(/* post params */);
res.redirect(linkTo(post));
});
router.show(function(req, res) {
// without the third parameter above in router.resource(...),
// we would use req.resource
res.render('posts/show', { post: req.post });
});
router.edit(function(req, res) {
res.render('posts/edit', { post: req.post });
});
router.update(function(req, res) {
req.post.update(/* post params */);
res.redirect('back');
});
router.destroy(function(req, res) {
req.post.delete();
res.redirect('/posts');
});
module.exports = router;
Then in your application file...
var app = require('express')();
app.use('/posts', require('./routes/posts'));
And you're good to go.
Right now, I need to write tests for this. If you want to, have at it. Fork and PR, baby.
FAQs
Simple and semantic restful resource routing for Express
The npm package express-resource-router receives a total of 1 weekly downloads. As such, express-resource-router popularity was classified as not popular.
We found that express-resource-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.