
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
jsonapi-fastify
Advanced tools
npm install jsonapi-fastify
Inspired by projects such as jagql-framework and jsonapi-server, jsonapi-fastify allows developers to stand up a {json:api}
compliant API server quickly and easily. As the name implies, jsonapi-fastify uses fastify to handle request routing and configuration.
This framework solves the challenges of json:api without coupling us to any one ORM solution. Every other module out there is either tightly coupled to a database implementation, tracking an old version of the json:api spec, or is merely a helper library for a small feature. If you're building an API and your use case only involves reading and writing to a data store... well count yourself lucky. For everyone else, this framework provides the flexibility to provide a complex API without being confined to any one technology.
A config driven approach to building an API enables:
Ultimately, the only things users of this framework need to care about are:
handler
to:
create
a resourcedelete
a resourcesearch
for multiple resourcesfind
a specific resourceupdate
a specific resourcejsonapi-fastify
and powers the core test suite.const { jsonapiFastify, define, MemoryHandler } = require("jsonapi-fastify");
const { nanoid } = require("nanoid");
const server = jsonapiFastify({
openapi: {
info: {
version: "1.0.0",
title: "test server",
description: "a jsonapi server",
contact: {
url: "https://jsonapi.org",
email: "support@jsonapi.org",
},
license: {
name: "MIT",
url: "https://jsonapi.org/license",
},
},
},
definitions: [
define((schema) => ({
resource: "people",
idGenerator: () => nanoid(),
handler: MemoryHandler(),
fields: {
firstname: schema.attribute(),
lastname: schema.attribute(),
articles: schema.belongsToOne({
resource: "articles",
as: "author",
}),
},
examples: [
{
id: "42",
type: "people",
firstname: "John",
lastname: "Doe",
},
{
id: "24",
type: "people",
firstname: "Jane",
lastname: "Doe",
},
{
id: "22",
type: "people",
firstname: "Billy",
lastname: "Idol",
},
],
defaultPageSize: 100,
})),
],
});
server.listen(3000, (err, address) => {
if (err) {
console.error(err);
} else {
console.log(`Ready at address ${address}!`);
}
});
# serverless.yml
provider:
name: aws
stage: dev
functions:
handler: src/handler.main
environment:
STAGE: ${self:provider.stage}
events:
- http:
method: any
path: api/{proxy+}
// src/handler.js
import awsLambdaFastify from "aws-lambda-fastify";
import { jsonapiFastify, define, MemoryHandler } from "jsonapi-fastify";
import { nanoid } from "nanoid";
const app = jsonapiFastify({
urlPrefixAlias: `https://api.example.com/${process.env.STAGE}`,
prefix: "/api",
openapi: {
info: {
version: "1.0.0",
title: "test server",
description: "a jsonapi server",
contact: {
url: "https://jsonapi.org",
email: "support@jsonapi.org",
},
license: {
name: "MIT",
url: "https://jsonapi.org/license",
},
},
},
definitions: [
define((schema) => ({
resource: "people",
idGenerator: () => nanoid(),
handler: MemoryHandler(),
fields: {
firstname: schema.attribute({
description: "The person's first name",
type: (z) => z.string(),
}),
lastname: schema.attribute({
description: "The person's last name",
type: (z) => z.string(),
}),
articles: schema.belongsToOne({
resource: "articles",
as: "author",
}),
},
examples: [
{
id: "42",
type: "people",
firstname: "John",
lastname: "Doe",
},
],
defaultPageSize: 100,
})),
],
});
export const main = awsLambdaFastify(app);
FAQs
A node JSON:API server, powered by fastify
The npm package jsonapi-fastify receives a total of 0 weekly downloads. As such, jsonapi-fastify popularity was classified as not popular.
We found that jsonapi-fastify 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
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.