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

1.5.4 • Public • Published

loopback-component-crud

Travis (.org) branch npm npm bundle size GitHub

Creating CRUD endpoints in any application is a repetitive and futile task.

Using this extension you can generate a configurable CRUD endpoints with these features:

  1. Authentication
  2. Authorization
  3. Validation
  4. Nested Create
  5. Nested Update

Installation

npm i --save loopback-component-crud

Usage

Follow these steps to add CRUD extension to your loopback4 application

  1. Add CRUDComponent to your application (bind model-api-builder)
  2. Add CRUD config files to src/model-endpoints

Now, let's try:


Step 1 (CRUD Component)

Edit your application.ts file:

import { CRUDComponent } from "loopback-component-crud";

export class TestApplication extends BootMixin(
    ServiceMixin(RepositoryMixin(RestApplication))
) {
    constructor(options: ApplicationConfig = {}) {
        super(options);

        // Add crud component
        this.component(CRUDComponent);
    }
}

Step 2 (Model Endpoint)

Now, you can generate your CRUD endpoints by creating src/model-endpoints/mymodel.rest-config.ts:

import { CRUDApiConfig } from "loopback-component-crud";
import { MyModel } from "../models";

module.exports = {
    model: MyModel,
    pattern: "CRUD",
    dataSource: "MyDataSource",
    basePath: "/mymodel",
    create: {},
    read: {},
    update: {},
    delete: {},
} as CRUDApiConfig;

Contributors

License

This project is licensed under the MIT license.
Copyright (c) KoLiBer (koliberr136a1@gmail.com)

Package Sidebar

Install

npm i @yshing/loopback-component-crud

Weekly Downloads

0

Version

1.5.4

License

MIT

Unpacked Size

61.7 kB

Total Files

32

Last publish

Collaborators

  • yshing