
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@borisovg/expressus
Advanced tools
A small, fast, Express-like Node.js web framework.
npm install --save @borisov/expressus
const { App, middleware } = require('@borisovg/expressus');
const { createServer } = require('http');
const app = new App();
const server = createServer(app.router);
server.listen(8080);
// simple GET route
app.get('/foo', function (req, res) {
res.end('OK');
});
// GET route with params (e.g. /foo/bar/baz)
app.get('/foo/:a/:b', function (req, res) {
console.log(req.params);
res.end('OK');
});
// JSON POST route
app.use(middleware.json());
app.post('/foo', function (req, res) {
console.log(req.body);
res.json({ result: 'OK' });
});
When using any of the included middleware, or if you add custom middleware that modifies the request or response object passed to the handler you can pass additional type information to the generic App
class.
import { App, middleware } from '@borisovg/expressus';
import type { JsonRequest, JsonResponse, QueryRequest } from '@borisovg/expressus';
const app = new App<JsonRequest & QueryRequest, JsonResponse>();
const server = createServer(app.router);
server.listen(8080);
app.use(middleware.json());
app.use(middleware.query());
app.get('/foo/:bar', function (req, res) {
// req.body, req.params.bar, req.query and res.json will be typed
});
framework.App()
- application constructorapp.get(route, callback)
- register GET handlerapp.delete(route, callback)
- register DELETE handlerapp.patch(route, callback)
- register PATCH handlerapp.post(route, callback)
- register POST handlerapp.put(route, callback)
- register PUT handlerapp.remove_all_handlers()
- remove all handlersapp.remove_middleware(fn)
- remove middleware functionapp.router(req, res)
- router function (use as request callback for HTTP server)app.use(fn)
- register middleware functionreq.params.name
to "bar"req.params.name
to "bar" and set req.splat
to "anything/else"req.route
Refer to the http-hash package for more information.
A middleware function has the signature (req, res, next)
, with next
being a function that will run the next middleware in the chain.
Middleware functions are run in the order they were attached.
Some basic middleware is included in the framework.
This middleware will load the request body and attach it to req.body
as a buffer.
app.use(middleware.body());
This middleware will parse req.body
form data and replace req.body
with the result.
app.use(middleware.form());
This middleware will parse req.body
JSON data and replace req.body
with the result.
It will also add a res.json(data)
convenience method.
app.use(middleware.json());
This middleware will load parse the request query string and attach it to req.query
.
app.use(middleware.query());
This middleware is a very simple static content server, aimed for use during development. In production, consider fronting your app with a real HTTP server (e.g. Nginx) for superior performance.
if (process.env.NODE_ENV !== 'production') {
app.use(middleware.static({ path: './public' }));
}
FAQs
A small, fast, Express-like Node.js web framework.
We found that @borisovg/expressus 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.