2.0.21 • Published 22 days ago

@visulima/crud v2.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

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



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

2.0.21

22 days ago

2.0.20

1 month ago

2.0.19

1 month ago

2.0.18

1 month ago

2.0.17

2 months ago

2.0.15

2 months ago

2.0.16

2 months ago

2.0.14

2 months ago

2.0.13

3 months ago

2.0.12

4 months ago

2.0.11

5 months ago

2.0.3

7 months ago

2.0.2

8 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.7

6 months ago

2.0.6

6 months ago

2.0.9

5 months ago

2.0.10

5 months ago

2.0.8

6 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.11

12 months ago

1.0.12

11 months ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago