0.0.14 • Published 12 days ago
@fatpig0416/core-crm v0.0.14
CRM-core
This is a core module for CRM which works with NestJs application
Environments
node: v16.13.2
npm: v8.1.2
yarn: v1.22.18
Prerequisites
You should have the following peer dependencies installed in your project
Installing
$ npm i @fatpig0416/core-crm
$ yarn add @fatpig0416/core-crm
Usage
In app.module.ts
import { CoreModule } from '@fatpig0416/core-crm'
Import CoreModule
:
@Module({
imports:[
...
CoreModule.forRoot(opts)
]
})
When you define your custom controller, you can extend CoreController
, which provides ACL, AuthGuard
by default
import { CoreController } from '@fatpig0416/core-crm'
@Controller('controller-name')
@AccessSubject('access-subject')
export class YourController extends CoreController {
constructor(readonly service: YourService) {
super(service)
}
}
# controller-name: relevant to route prefix
# access-subject: access scope of the module, it decides whether current user has permission for this controller or not.
# This works with @Access decorator comes from CoreModule
You can also override the method or create a new one.
During the definition of the method, you can assign an access
action so that you can restrict the user's access to the method.
import { Access } from '@fatpig0416/core-crm'
... ...
@Post()
@Access('create')
create(@Body() payload: any) {
... ...
}
# Or you can skip default access restriction or skip auth check
import { GrantAccess, SkipAuth } from '@fatpig0416/core-crm'
... ...
@SkipAuth()
@GrantAccess()
@Post()
create(@Body() payload: any) {
... ...
}