
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@uscreen.de/fastify-mongo-crud
Advanced tools
Tiny mongodb decorator providing CRUD-style DB-methods
Tiny mongodb decorator providing CRUD-style DB-methods
$ pnpm add @uscreen.de/fastify-mongo-crud
Adding @uscreen.de/fastify-mongo-crud
also adds fastify-mongodb
as direct dependency.
Note: You still need to register
mongodb
prior tocrud
as seen in example below. This is due to encapsulation of fastify plugins assuming you will want to resuse samefastify.mongo
accross your application.
Setup within a plugins/mongo.js
file:
import fp from 'fastify-plugin'
import mongodb from '@fastify/mongodb'
import crud from '@uscreen.de/fastify-mongo-crud'
export default fp((fastify, opts, next) => {
/**
* 1) setup mongodb connection
*/
fastify.register(mongodb, { url: opts.mongoUri })
/**
* 2) setup CRUD factory
*/
fastify.register(crud)
/**
* 3) proceed
*/
next()
})
Usage within a services/accounts.js
file:
/**
* let's write a classic CRUD service
*/
export default (fastify, opts, next) => {
const accounts = fastify.crud('accounts')
/**
* plug in some appropiate authentication
* middleware - of course!
*
* plus: add schemas to routes.
*/
/**
* create
*/
fastify.post('/accounts', async (req) => {
return { account: await accounts.create(req.body) }
})
/**
* read
*/
fastify.get('/accounts/:id', async (req) => {
return { account: await accounts.read(req.params.id) }
})
/**
* update
*/
fastify.put('/accounts/:id', async (req) => {
return { account: await accounts.update(req.params.id, req.body) }
})
/**
* delete
*/
fastify.delete('/accounts/:id', async (req) => {
return { account: await accounts.delete(req.params.id) }
})
/**
* list
*/
fastify.get('/accounts', async () => {
return { accounts: await accounts.list() }
})
next()
}
fastify.mongo
from within this module, if not installed in parentLicensed under MIT.
Published, Supported and Sponsored by u|screen
FAQs
Tiny mongodb decorator providing CRUD-style DB-methods
We found that @uscreen.de/fastify-mongo-crud demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.