
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
express-toss
Advanced tools
Makes express router handlers aware of promises. Brings more clear dataflow to handlers.
Makes express router handlers aware of promises. Brings more clear dataflow to express handlers.
toss.method
Transforms (rq) => Promise
function to (rq, rs) => void
function for use inside Express' handlers.
import tosser from 'express-toss'
var toss = tosser({ debug: true })
express.get('/resource', toss.method(rq =>
{
return db.query().then(transform) /* … */
}))
— return value is used as response body with status 200 and adequate mime. MIME would be determined automatically by express (application/json
in case of Object
, text/html
in case of string
, learn more).
import tosser from 'express-toss'
var toss = tosser({ debug: true })
express.get('/resource', toss.method(rq =>
{
throw new TypeError
}))
— sync throws or promise rejections will convert into 500s with specific JSON body. If debug = true
body is detailed, if debug = false
it is like a simple internal-ish error.
Resp()
import tosser from 'express-toss'
import Resp from 'express-toss/Resp'
var toss = tosser({ debug: true })
express.get('/resource', toss.method(rq =>
{
// use `Resp` to fine-control response
return Resp(200, 'text/html', html)
// can be used for 400s
return Resp(400, { server: error })
}))
— Resp([status], [mime], body)
is applied to express' response. Resp
can be sync-returned or used inside promise.
Wrong()
import tosser from 'express-toss'
import Wrong from 'express-toss/Wrong'
var toss = tosser({ debug: true })
// use Wrong to create protocol-level errors
// Wrong(code) creates constructor for `code` error
var NotPermitted = Wrong('permission_required')
var NotFound = Wrong('user_not_found', { status: 404 })
express.get('/resource', toss.method(rq =>
{
// throwing or returning `Wrong` to fine-control response
throw NotPermitted()
// details can be supplied
throw NotFound({ username: 'username' })
}))
— Wrong(code, [options])
creates new specific error factory. Calling that factory creates error instance. This instance can be throwed/rejected or sync-returned to indicate error situation.
FlowType definitions included.
ISC © Strider, 2017 — 2019.
FAQs
Makes express router handlers aware of promises. Brings more clear dataflow to handlers.
The npm package express-toss receives a total of 0 weekly downloads. As such, express-toss popularity was classified as not popular.
We found that express-toss 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.