![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.
restless-api
Advanced tools
(RESTful) APIs for the highly impatient: Just write a public-facing API spec in JSON, and let this do the Express routing for you. Not as cool as Swagger but a LOT simpler.
Under development
restless-api takes a JSON spec of your APIs like you would send your user (no code inside it) and handles all the Express routing
the goal has been to be as-simple-as-possible at all decision points, but there is support for model/controller breakdown and dependency injection if you want it
Available on NPM @ https://www.npmjs.org/package/restless-api
restless-api
to your project: npm install --save restless-api
links
: user-facing API spec (NO CODE, literally ready to send your user)nouns
: contains a reference to a module (or optionally a controller and model) for each noun(Run node examples/app.js
to try it!)
var restlessApi = require('../index.js');
var apiRouter = restlessApi({
"links": {
/* each key in 'links' is a REST noun from 'nouns' at end */
"user": {
"index": {
"url": "/users",
"method": "GET",
"desc": "Show a list of users"
},
"read": {
"url": "/users/:id",
"method": "GET",
"desc": "Get a user by ID"
},
"create": {
"url": "/users",
"method": "POST",
"desc": "Add a new user"
},
"update": {
"url": "/users/:id",
"method": "PUT/POST",
"desc": "Update an existing user with ID=:id"
}
/* each key in a given noun denotes a REST endpoint (url+method)
and will be routed to the callback in the noun module associated with the same key.
for example, 'update' above will invoke the function 'update' in 'lib/users.js' -
because that is the module associated with the noun in 'nouns' below
*/
}
},
"nouns": {
"user": {
"model": require("./lib/userModel.js"),
"controller": require("./lib/userController.js")
}
/*
- Addl nouns:
You can add more nouns here
- Nouns can be specified with a single file:
"products": require("./lib/products.js")
- Or you can specify a model and controller separately, e.g.:
"products": {
"model": require("./lib/productModel.js"),
"controller": require("./lib/productController.js")
}
- The callbacks in the 'controller' module will be invoked with the model dependency injected
*/
}
});
// The routes above are relative; restless-api returns an express.Router object
// which you can mount wherever you want
// e.g. "/api":
express.use("/api", apiRouter);
express.listen(3000);
console.log("Listening on port 3000!");
./lib/userController.js
might be:module.exports = {
index: function index(req, res, User) {
// ...
},
read: function read(req. res, User) {
// ...
},
//...
};
user
argument is the user model
(this example used one unified model+controller for user noun, but if they were separate this would be the controller and it would get the model ref there)FAQs
(RESTful) APIs for the highly impatient: Just write a public-facing API spec in JSON, and let this do the Express routing for you. Not as cool as Swagger but a LOT simpler.
We found that restless-api 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.