
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
express-toybox
Advanced tools
My Own Extra Stuff for Express.
$ npm install express-toybox
$ git clone http://github.com/iolo/express-toybox.git
$ cd express-toybox
$ npm install
$ grunt docs
$ open build/doxx/index.html
$ export DEBUG='*'
$ node example/app.js
$ open http://localhost:3333
var express = require('express-toybox')(require('express'));
//var express = require('express-toybox')();
express.toybox.utils.collectQueryParams(req);
or
var express = require('express'),
expressToybox = require('express-toybox');
expressToybox.utils.collectQueryParams(req);
//express.toybox.utils.collectQueryParams(req);
var fs = require('fs');
app.get('/foo', function (req, res, next) {
fs.readFile('file.txt', res.sendCallbackFn(next));
});
var FS = require('q-io/fs');
app.get('/bar', function (req, res, next) {
res.sendLater(FS.readFile('file.txt'), next);
});
express()...use(express.toybox.cors(config))...
{
TBW: ...
}
express()...use(express.toybox.logger(config))...
{
file:'path-to-log-file',
format:'morgan-format',
morgan-options...
}
{
debug:'debug-namespace',
format:'morgan-format',
morgan-debug-options...
}
express()...use(express.toybox.session(config))...
{express-session-options...}
{
store:{
module:'store-module-name',
store-module-options...
},
express-session-options...
}
express()...useResource(path, resource-module)...
useResource('/posts/:id', {
// get /posts
index: function (req, res) { ... },
// post /posts
create: ...
// get /posts/123
show: function (req, res) { assert(req.param('id') == 123)... }
// put /posts/123
update: ...
// delete /posts/123
destroy: ...
...
});
send custom http 404 error with json/html/text by accept header in request.
express()...use(express.toybox.error404(config))...
{
code: custom-error-code,
message:'custom-error-message',
template: 'lodash-micro-template-string-for-404-error-page',
view:'path-view-template'
...
}
send custom http error with json/html/text by accept header in request.
express()...use(express.toybox.error500(config))...
{
status: custom-status-code,
code: custom-error-code,
mappings:{'err.name':{err-response-body...}, 'err.code': {err-response-body...}, ...},
stack:true/false,
template: 'lodash-micro-template-string-for-error-page',
view:'path-view-template',
...
}
express()...useCommonMiddlewares(config)...
or
var app = express();
...
express.toybox.common.configureMiddlewares(app, config);
...
{
logger: {logger-config...},
compress: {compress-config...},
cookieParser: {cookieParser-config...},
methodOverride: {methodOverride-config...},
cors: {cors-config...},
session: {session-config...},
csrf: {csrf-config...},
multipart: {multipart-config...},
urlencoded: {urlencoded-config...},
json: {json-config...},
text: {text-config...},
raw: {raw-config...},
...
}
{
TBW: ...
}
{
TBW: ...
}
{
TBW: ...
}
{
TBW: ...
}
multipart/form-data
request.{
TBW: ...
}
application/x-www-form-urlencoded
request.{
TBW: ...
}
application/json
request.{
TBW: ...
}
plain/text
request.{
TBW: ...
}
application/octet-stream
request.{
TBW: ...
}
express()...useCommonRoutes(config)...
or
var app = express();
...
express.toybox.common.configureRoutes(app, config);
//expressToybox.common.configureRoutes(app, config);
...
{
root: path-to-directory,
statics: {statics-config...},
resources: {resources-config...},
errors: {errors-config...},
...
}
{
'url-path': 'path-to-static-content-directory'
...
}
{
'url-path': 'resource-module-name'
...
}
{
'404': {error404-config...},
'500': {error500-config...},
...
}
may the source be with you...
FAQs
My Own Extra Stuff for Express
We found that express-toybox 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.