Visulima crud
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.
[][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
Daniel Bannert's open source work is supported by the community on GitHub Sponsors
Features
Installation
npm install @visulima/crud prisma @prisma/clientyarn add @visulima/crud prisma @prisma/clientpnpm add @visulima/crud prisma @prisma/clientUsage
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();Supported Node.js Versions
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.
Contributing
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.
Credits
License
The visulima crud is open-sourced software licensed under the [MIT][license-url]
[typescript-url]: https://www.typescriptlang.org/ "TypeScript" "typescript" [license-image]: https://img.shields.io/npm/l/@visulima/crud?color=blueviolet&style=for-the-badge [license-url]: LICENSE.md "license" [npm-image]: https://img.shields.io/npm/v/@visulima/crud/latest.svg?style=for-the-badge&logo=npm [npm-url]: https://www.npmjs.com/package/@visulima/crud/v/latest "npm"