Resource configuration
You can configure your resource to your needs by adding context to @HttpResource()
and @FirestoreResource() resource decorators.
For example, you may need to specify a different path to your resource depending on the operation. This can be done by using the syntax in the following example.
@HttpResource({ path: '/libraries', update: '/library', }) export class Library { }
For each operation execution, NgxRepository will look for a specific context attached to the operation
for the resource.
If no specific context is found, the default context
(here the path) will be used.
The available configuration is different depending on the type of resource and the targeted operation.
The targetable operations are the following :
findByIdfindOnefindAllcreateupdatepatchdeletereadwrite
Response type
Define a specific response type (different from the resource) using responseType
context parameter.
@HttpResource({
path: '/libraries',
write: {
responseType: () => WriteLibraryDto
}
})
export class Library {
}
Path
Define a specific path for an operation using path context parameter. Passing a string
directly as an operation
context is also possible to define the path context parameter.
⚠️ This context parameter is only available for
@HttpResource()@HttpResource({ path: '/libraries', create: { path: '/create-a-library' }, update: '/update-a-library' }) export class Library { }
Page response processor
Define a specific page response processor using
pageResponseProcessor context parameter.
⚠️ This context parameter is only available for
findAlloperation and@HttpResource()@HttpResource({ path: '/libraries', findAll: { pageResponseProcessor: MyPageResponseProcessor } }) export class Library { }
Global configuration
It is also possible to add some global configuration by adding it directly in the
forRoot() method of your driver module import.