Framework Usage
ResourcesJS returns plain objects. Use your framework’s normal response API.
Express
Section titled “Express”app.get("/users/:id", async (_request, response) => { const user = await service.find(); response.json(UserResource.make(user));});Fastify
Section titled “Fastify”fastify.get("/users/:id", async () => { const user = await service.find(); return UserResource.make(user);});app.get("/users/:id", async (context) => { const user = await service.find(); return context.json(UserResource.make(user));});NestJS
Section titled “NestJS”@Controller("users")export class UserController { @Get(":id") async show() { const user = await this.service.find(); return UserResource.make(user); }}Elysia
Section titled “Elysia”new Elysia().get("/users/:id", async () => { const user = await service.find(); return UserResource.make(user);});Elysia’s Node adapter expects a global Web Crypto implementation. Node 20 and
newer provide it globally. On Node 18, initialize it from node:crypto before
loading Elysia.
AdonisJS
Section titled “AdonisJS”export default class UsersController { async show() { const user = await service.find(); return UserResource.make(user); }}The package test suite verifies compatibility examples for Express 5, Fastify 4, Hono 4, NestJS 10, Elysia 1.4, and AdonisJS 6.2.x.