@visulima/crud
TypeScript icon, indicating that this package has built-in type declarations

2.0.21 • Public • Published

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-image npm-image license-image


Daniel Bannert's open source work is supported by the community on GitHub Sponsors


Features

Installation

npm install @visulima/crud prisma @prisma/client
yarn add @visulima/crud prisma @prisma/client
pnpm add @visulima/crud prisma @prisma/client

Usage

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

/@visulima/crud/

    Package Sidebar

    Install

    npm i @visulima/crud

    Weekly Downloads

    237

    Version

    2.0.21

    License

    MIT

    Unpacked Size

    394 kB

    Total Files

    22

    Last publish

    Collaborators

    • prisis