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

1.3.1 • Public • Published

Installation

npm install @ahas/mikro-crud
# or
yarn add @ahas/mikro-crud

Usage

import { Module } from "@nestjs/common";
import { CrudModule } from "@ahas/mikro-crud";

@Module({
    CrudModule.forFeature({
        entity: User,
        path: "users",
        name: "user",
    })
})
export class UserApiModule {}

Controller

CrudModule will generate 5 crud endpoints automatically.

HTTP Method Request URL Controller method
GET /api/users/ search
GET /api/users/:id get
POST /api/users create
PATCH /api/users/:id update
DELETE /api/users/:id delete

Request body and response

search

[GET] /api/users

Response

{
    items: [
        {
            id: 1,
            nickname: "ahas"
        }
    ],
    count: 0
}

get

[GET] /api/users/1

Response

{
    user: {
        id: 1,
        nickname: "ahas"
    }
}

create

[POST] /api/users

Request body

{
    user: {
        nickname: "alchemist"
    }
}

Response

{
    id: 2
}

update

[PATCH] /api/users/2

Request body

{
    user: {
        nickname: "goto"
    }
}

Readme

Keywords

Package Sidebar

Install

npm i @ahas/mikro-crud

Weekly Downloads

0

Version

1.3.1

License

MIT

Unpacked Size

93.2 kB

Total Files

78

Last publish

Collaborators

  • ahas226