
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.
fastify-autoroute
Advanced tools
Next.js file routing for Fastify.
If you're familiar with Next.js, you know how awesome the routing is. If not, have a look on their documentation :)
AutoRoute gives you exactly the same routing (except for optional catch all routes, they can't be done in Fastify or they're inherently supported, je sais pas π€·ββοΈ).
yarn add fastify-autoroute
# or
npm i fastify-autoroute
Add AutoRoute as a plugin to Fastify:
import { FastifyPlugin } from "fastify";
import { join } from "path";
import fastifyAutoRoute from "fastify-autoroute";
const app: FastifyPlugin = function (fastify, opts, next): void {
fastify.register(fastifyAutoRoute, {
autoRouteDir: join(__dirname, "routes"),
});
next();
};
export default app;
/pages
.I tried explaining this, but instead here is an example
For the following directory:
ββββroutes
β ββββusers
β β ββββ[id]
β β β ββββindex.get.ts
β β β ββββindex.delete.ts
β β β ββββname.get.ts
β β β ββββemail.get.ts
β β ββββindex.post.ts
β ββββteams
β β ββββ[...slug].get.ts
β ββββindex.get.ts
You will get the following Fastify routes:
GET /
POST /users
GET /users/name
GET /users/email
GET /users/:id
DELETE /users/:id
GET /teams/*
Note. the method all
is expanded into all the methods supported by Fastify.
So, name.all.ts
is expanded into
GET /name
POST /name
PUT /name
...
The default export is passed as a handler
to fastify.route()
. All other named exports are bassed as options to fastify.route()
too.
export const schema = {};
export const onRequest = [];
export default async (request: FastifyRequest, reply: FastifyReply) => {
return { ok: true };
};
In order to access Fastify and its decorators, you can use the following structure:
export default (fastify: FastifyInstance) => async (
request: FastifyRequest,
reply: FastifyReply
) => {
return {
config: fastify.config,
};
};
The same structure applies when accessing Fastify from inside onRequest
:
export const onRequest = [
(fastify) => async (request, reply) => {
// your content
return;
},
];
Currently, accessing Fastify from inside other hooks is not supported.
Imed Adel (Twitter)
MIT
FAQs
> Next.js file routing for Fastify.
The npm package fastify-autoroute receives a total of 5 weekly downloads. As such, fastify-autoroute popularity was classified as not popular.
We found that fastify-autoroute 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.