Visulima crud is built on top of
OpenAPI (Swagger) specification, node-rate-limiter-flexible, @visulima/connect
With a more intuitive API for creating HTTP API endpoints.
Daniel Bannert's open source work is supported by the community on GitHub Sponsors
npm install @visulima/crud prisma @prisma/client
yarn add @visulima/crud prisma @prisma/client
pnpm add @visulima/crud prisma @prisma/client
To use the @visulima/crud
package, you need to have a Prisma schema.
// pages/api/[...crud].ts
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";
import { PrismaAdapter } from "@visulima/crud";
import { nodeHandler } from "@visulima/crud/next";
import type { User, Post, Prisma } from "@prisma/client";
import { prisma } from "../../lib/prisma-client";
const prismaAdapter = new PrismaAdapter<User | Post, Prisma.ModelName>({
prismaClient: prisma,
});
export default async (request, response) => {
const handler = await nodeHandler<User | Post, any, NextApiRequest, NextApiResponse, Prisma.ModelName>(prismaAdapter);
await handler(request, response);
};
To use it with api-platform connect
you need to install the @visulima/api-platform
package.
// pages/api/[...crud].ts
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";
import { createNodeRouter } from "@visulima/api-platform";
import { PrismaAdapter } from "@visulima/crud";
import { nodeHandler } from "@visulima/crud/next";
import type { User, Post, Prisma } from "@prisma/client";
import { prisma } from "../../lib/prisma-client";
const prismaAdapter = new PrismaAdapter<User | Post, Prisma.ModelName>({
prismaClient: prisma,
});
const router = createNodeRouter<NextApiRequest, NextApiResponse>().all(async (request, response) => {
const handler = await nodeHandler<User | Post, any, NextApiRequest, NextApiResponse, Prisma.ModelName>(prismaAdapter);
await handler(request, response);
});
export default router.handler();
Libraries in this ecosystem make the best effort to track Node.js’ release schedule. Here’s a post on why we think this is important.
If you would like to help take a look at the list of issues and check our Contributing guild.
Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
The visulima crud is open-sourced software licensed under the MIT