GitShow/developit/resource-router-middleware
developit

resource-router-middleware

:bicyclist: Express REST resources as middleware mountable anywhere

by developit
expressjavascriptmiddlewarerestrest-api
Star on GitHubForkWebsitenpm

JavaScript

123 stars17 forks5 contributorsQuiet · 7y agoSince 2015BSD-3-Clause

Meet the team

See all 5 on GitHub →
developit
developit19 contributions
fadeenk
fadeenk2 contributions
nikrich
nikrich1 contribution
gitter-badger
gitter-badger1 contribution

Languages

View on GitHub →
JavaScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

2 of 6 standards met

Community profile →
42
✓README✓License○Contributing○Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Quiet · 1 in progress · Last activity 7y ago
See all on GitHub →
arifmahmudrana
Nested resource useOpenIssue

Can it be use for nested resource? e.g like Laravel https://laravel.com/docs/5.1/controllers#restful-nested-resources. If I have route like how will I use your package?

arifmahmudrana · 7y ago
nuxy
Avoid /:undefined when resource `id` is not definedOpenPR

Currently, when the is undefined the router always defaults to vs The latter result accounts for request methods without the need for the URI fragment.

nuxy · 7y ago
serain
Testing exampleOpenIssue

Can you give an example of running a test case for for example (with or any other testing framework)

serain · 7y ago

Recent fixes

View closed PRs →
iSimar
Ability to have specific middleware for specific resource controllersMergedPR

Overview Currently all the keys are just functions (ie. create, read). You can have a case where auth is required for creating a resource but not reading it. You can't add middleware to specific controllers. The old usage would still work, where create is a function. Example:

iSimar · 5y ago
jokerrider007
Multer .single() doesn't work ?ClosedIssue

import resource from 'resource-router-middleware'; import multer from 'multer'; let uploads = multer({ dest: 'uploads/' }); export default resource({ middleware: [ uploads.single('avatar'); ], // then use it in a route: create({ body, files }, res) { console.log(files); res.json(body); } }); (Reference from #6) I'm trying to use uploads.single() my parameter and form name has matched but my console.log(files); return undefined. How can I Accept a single file with the name fieldname?

jokerrider007 · 7y ago
nuxy
Support cases where URI resource (:id) is not requiredClosedIssue

Feature request There are cases where the user may not need to preload resource data by and just perform the action (ex: DELETE, PATCH, PUT) on the resource itself. A good example of this is a call to a database using a defined (non-public) token. Use example Now, this could be handled by creating a separate router middleware specific to this use-case. But in the effort to consolidate routes for a given , while taking advantage of actions and injection provided by this library, it would be nice if it supported both scenarios. Code update Currently, this expression prevents the route from being loaded when the resource doesn't exist. A simple solution to this would be to make this value optional and rely on to determine whether this value should be defined (as it does already) and how it should be handled. Let me know your thoughts on this?

nuxy · 7y ago
Structured data for AI agents

Repository: developit/resource-router-middleware. Description: :bicyclist: Express REST resources as middleware mountable anywhere Stars: 123, Forks: 17. Primary language: JavaScript. Languages: JavaScript (100%). License: BSD-3-Clause. Homepage: http://npm.im/resource-router-middleware Topics: express, javascript, middleware, rest, rest-api. Open PRs: 1, open issues: 8. Last activity: 7y ago. Community health: 42%. Top contributors: developit, fadeenk, nikrich, gitter-badger.

·@ofershap

Replace github.com with gitshow.dev