Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@foodsy-app/fastify-typebox
Advanced tools
Plugin for Fastify to prevent having to write duplicate type definitions for schemas
Plugin for Fastify to prevent having to write duplicate type definitions for schemas.
@foodsy-app/fastify-typebox
uses typebox, to compose JSON schemas.
Important!
This plugin uses patch-package to comment existing type declarations for request methods in node_modules/fastify/types/instance.d.ts
since TypeScript does not allow to overwrite declarations. If you notice any problems, please post a issue.
npm i @foodsy-app/fastify-typebox @sinclair/typebox
# Or if you are using Yarn
yarn add @foodsy-app/fastify-typebox @sinclair/typebox
Add it to your project using register
and you are done!
import fastify from "fastify";
fastify.register(require("@foodsy-app/fastify-typebox"));
This plugin exposes a new method on the FastifyInstance
called typeboxSchema
Notice: Please refer to the typebox repository for a overview of the typebox API.
import { Type } from "@sinclair/typebox";
// Available request methods are
// .get, .head, .post, .put, .delete, .options, .patch and .all
server.get(
"/secret-route/:id",
{
schema: server.typeboxSchema({
// You can also type querystring, headers and response
params: Type.Object({
id: Type.String(),
}),
body: Type.Object({
user: Type.Object({
name: Type.String(),
age: Type.Number({ minimum: 18 }),
}),
}),
}),
},
(request, reply) => {
// `id` is inferred as string | undefined
const id = request.params?.id;
// `user` is inferred as the object we described!
const user = request.body?.user;
}
);
FAQs
Plugin for Fastify to prevent having to write duplicate type definitions for schemas
We found that @foodsy-app/fastify-typebox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.