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.
sails-controller-driven-routing
Advanced tools
A routing configuration similar to blueprint that reads the routes from the controller so everything is kept in one place
A routing configuration similar to blueprint that reads the routes from the controller so everything is kept in one place
It relies on blueprints validating your configuration (because I didn't want to copy/paste), but you could maybe disable blueprints entirely in production if you're feeling courageous and don't need any of its helpers.
n
accessible pointsrouting.js
switch()
at the top of each exposed method.$ npm instal sails-controller-driven-routing
Your controller can now look like the following:
MyController.js
module.exports = {
_config: {
actions: false, //disable built in blueprints
shortcuts: false, //disable built in blueprints
rest: false, //disable built in blueprints
explicitRoutes: {
'OPTIONS /hello/world': 'mycontroller.world'
},
exposedMethods: [
'foobar'
]
},
world: function(res, req) {
return res.ok("hello");
},
foobar: function(res, req) {
return res.ok("bar");
},
foobarPost: function(res, req) {
return res.ok("par");
},
};
Now:
OPTIONS /hello/world
will respond with hello
GET/POST/DELETE/OPTIONS/PUT/etc /mycontroller/foobar
will respond with bar
POST /mycontroller/foobar
will respond with par
You can also specify a prefix
that'll work the same way as blueprints ones do which will override the 'mycontroller' segment of the url for the exposedMethods
section.
Hopefully this will prove useful to someone else, pull requests welcome if you want to tidy it up a bit :)
FAQs
A routing configuration similar to blueprint that reads the routes from the controller so everything is kept in one place
The npm package sails-controller-driven-routing receives a total of 11 weekly downloads. As such, sails-controller-driven-routing popularity was classified as not popular.
We found that sails-controller-driven-routing 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.