Skip to content

loopback4/loopback-component-crud

Repository files navigation

loopback-component-crud

checks npm latest npm next license FOSSA Status

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:

  • Authentication
  • Authorization
  • Validation
  • Nested Create
  • Nested Update

Installation

Use the package manager npm to install loopback-component-crud.

npm i --save loopback-component-crud

Usage

Follow these steps to add CRUD extension to your loopback4 application:

  • Add CRUDComponent to your application (bind model-api-builder)

    // application.ts
    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);
        }
    }
  • Add CRUD config files to src/model-endpoints

    // 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;

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

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

FOSSA Status

About

Loopback component crud generic application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •