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
Use the package manager npm to install loopback-component-crud
.
npm i --save loopback-component-crud
Follow these steps to add CRUD
extension to your loopback4 application:
-
Add
CRUDComponent
to your application (bindmodel-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;
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.
This project is licensed under the MIT.
Copyright (c) KoLiBer (koliberr136a1@gmail.com)