loopback-component-crud
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
npm i --save loopback-component-crud
Usage
Follow these steps to add CRUD
extension to your loopback4 application
- Add
CRUDComponent
to your application (bindmodel-api-builder
) - 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)