Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
larvitbase-api
Advanced tools
REST http API base framework based on larvitbase
npm i larvitbase-api
In the file index.js:
const Api = require('larvitbase-api');
let api;
api = new Api({
'baseOptions': {'httpOptions': 8001}, // sent to larvitbase
'routerOptions': {}, // sent to larvitrouter
'reqParserOptions': {}, // sent to larvitReqParser
});
api.start(function (err) {}); // callback
// Exposed stuff
//api.base - larvitbase instance
//api.options - the options sent in when instanciated
//api.apiVersions - resolved versions of the API (subfolders to controllers folder)
//api.stop() // close httpServer
Then just start the file from shell:
node index.js
This will provide the following:
Will print your apps README.md when the browser targets http://localhost:8001/
Will run controllers in your apps "controllers/X.X"-folder (or node_module/xxx/controllers/X.X, see larvitfs for details on the virtual filesystem the routing module uses for this). For example /foo will run the controller controllers/1.2/foo.js, given that 1.2 is the latest version. For details about how to write controllers, see larvitbase.
It is also possible to request a specific version fo the API. Consider:
More detailed examples on controllers in node modules
If any controller exists, in any version in the local app, that controller will have priority over all node modules. If a specific version is requested, that version is all that will be searched for in modules. To find a controller in a module of a specific version this version must be present in the local app, even if the directory is empty.
For example, when folder structure that looks like this:
app |__ controllers |__ node_modules |__ dependency |__ controllers |__ v1.0 |__ bar.js
Requests for /bar and /v1.0/bar will return a 404. However, if we create a v1.0 directory in our apps controllers directory (see below), bar.js will be successfully resolved.
app |__ controllers | |__ v1.0 |__ node_modules |__ dependency |__ controllers |__ v1.0 |__ bar.js
Likewise, if any version of the api exists in the local app, unversioned controllers in modules will not be resolved.
We are using semver where we do the following:
Will write everything stored in res.data as JSON directly to the browser as application/json (except for the README.md, that is sent as text/markdown).
FAQs
API framework based on larvitbase
The npm package larvitbase-api receives a total of 73 weekly downloads. As such, larvitbase-api popularity was classified as not popular.
We found that larvitbase-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.