Abstract Class: BaseACLRoute<T>
Defined in: service-core/src/security/BaseACLRoute.ts:55
The BaseACLRoute class provides a base set of endpoints for managing Access Control List records.
Exposed endpoints:
| Name | HTTP Method | What it does |
|---|---|---|
count | HEAD / | Counts the number of ACLs matching the provided set of criteria in the request's query parameters. Returns the count as the value of the Content-Length header. |
create | POST / | Adds one or more new ACLs to the datasource. |
delete | DELETE /:id | Removes an existing ACL from the datasource. |
exists | HEAD /:id | Checks if the ACL with the given ID exists in the datasource. Sets Content-Length header to 1 if the ACL exists, otherwise 0. |
find | GET / | Returns all ACLs matching the provided set of criteria in the request's query parameters. |
findById | GET /:id | Returns a single ACL with a specified unique identifier. |
truncate | DELETE / | Removes all ACLs from the datasource. |
update | PUT /:id | Modifies an existing ACL in the datasource. |
updateBulk | PUT / | Modifies multiple existing ACLs in the datasource. |
updateProperty | PUT /:id/:property | Modifies an single property of the given name of an existing ACL in the datasource. |
!!Note!! that the BaseACLRoute is not automatically registered with a server by default. You must create
your own class that extends BaseACLRoute and apply the desired base path with @Route().
Examples
import { AccessControlListMongo, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
const { Model, Route } = RouteDecorators;
@Model(AccessControlListMongo)
@Route("/acls")
export class ACLRoute extends BaseACLRoute<AccessControlListMongo> {}
import { AccessControlListSQL, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
const { Model, Route } = RouteDecorators;
@Model(AccessControlListSQL)
@Route("/acls")
export class ACLRoute extends BaseACLRoute<AccessControlListSQL> {}
Extends
CRUDRoute<T>
Type Parameters
T
T extends AccessControlList
Constructors
Constructor
new BaseACLRoute<
T>():BaseACLRoute<T>
Returns
BaseACLRoute<T>
Inherited from
Properties
_objectFactory?
protectedoptional_objectFactory?:ObjectFactory
Defined in: service-core/src/routes/ModelRoute.ts:120
Inherited from
aclUtils?
protectedoptionalaclUtils?:ACLUtils
Defined in: service-core/src/routes/ModelRoute.ts:123
Inherited from
config?
protectedoptionalconfig?:any
Defined in: service-core/src/routes/ModelRoute.ts:127
The global application configuration.
Inherited from
defaultACLUid
protecteddefaultACLUid:string=""
Defined in: service-core/src/routes/ModelRoute.ts:130
The unique identifier of the default ACL for the model type.
Inherited from
logger
protectedlogger:any
Defined in: service-core/src/routes/ModelRoute.ts:133
Inherited from
notificationUtils?
protectedoptionalnotificationUtils?:NotificationUtils
Defined in: service-core/src/routes/ModelRoute.ts:136
Inherited from
repoUtils?
protectedoptionalrepoUtils?:RepoUtils<T>
Defined in: service-core/src/routes/ModelRoute.ts:142
The repository utility class to use for common operations.
Inherited from
repoUtilsClass
protectedreadonlyrepoUtilsClass:any=RepoUtils
Defined in: service-core/src/routes/CRUDRoute.ts:55
The class of the RepoUtils to use when instantiating the utility.
Inherited from
trackChanges
protectedtrackChanges:number=0
Defined in: service-core/src/routes/ModelRoute.ts:148
The number of previous document versions to store in the database. A negative value indicates storing all
versions, a value of 0 stores no versions.
Inherited from
trustedRoles
protectedtrustedRoles:string[]
Defined in: service-core/src/routes/ModelRoute.ts:151
Inherited from
Accessors
modelClass
Get Signature
get modelClass():
any
Defined in: service-core/src/routes/ModelRoute.ts:156
The class type of the model this route is associated with.
Returns
any
Inherited from
Methods
checkNotDefault()
protectedcheckNotDefault(id):void
Defined in: service-core/src/security/BaseACLRoute.ts:74
The default_<uid> records are regenerated from code on every server startup (see
ACLUtils.saveDefaultACL) and exist solely to seed the user-editable override record. They must never be
deleted or modified directly, even by an administrator, since doing so would have no lasting effect and would
only cause confusion.
Parameters
id
string
Returns
void
checkPerms()
protectedcheckPerms(params,user):Promise<void>
Defined in: service-core/src/security/BaseACLRoute.ts:56
Parameters
params
any
user
JWTUser
Returns
Promise<void>
checkPermsBulk()
protectedcheckPermsBulk(objs,user):void
Defined in: service-core/src/security/BaseACLRoute.ts:85
Bulk updates have no :id URI parameter to check a per-record permission against, so unlike checkPerms
we can't fall back to a per-record FULL permission check here. Require a trusted role for every bulk
update instead, and disallow touching any default_<uid> record (see checkNotDefault).
Parameters
objs
UpdateObject<T>[]
user
JWTUser
Returns
void
count()
count(
params,query,res,user?):Promise<any>
Defined in: service-core/src/security/BaseACLRoute.ts:98
Parameters
params
any
query
any
res
user?
JWTUser
Returns
Promise<any>
Overrides
create()
create(
obj,req,user?):Promise<T|T[]>
Defined in: service-core/src/security/BaseACLRoute.ts:108
Parameters
obj
T | T[]
req
user?
JWTUser
Returns
Promise<T | T[]>
Overrides
delete()
delete(
id,version,purge,req,user?):Promise<void>
Defined in: service-core/src/security/BaseACLRoute.ts:113
Parameters
id
string
version
string | undefined
purge
string | undefined
req
user?
JWTUser
Returns
Promise<void>
Overrides
doBulkCreate()
protecteddoBulkCreate(objs,options):Promise<T[]>
Defined in: service-core/src/routes/ModelRoute.ts:253
Attempts to store a collection of objects provided in options.req.body into the datasource. Upon success, sets the newly persisted
object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the
client.
Parameters
objs
Partial<T>[]
The object(s) to store in the database.
options
The options to process the request using.
Returns
Promise<T[]>
Inherited from
doBulkUpdate()
protecteddoBulkUpdate(objs,options):Promise<T[]>
Defined in: service-core/src/routes/ModelRoute.ts:500
Attempts to modify a collection of existing data model objects.
Parameters
objs
UpdateObject<T>[]
The object(s) to bulk update in the database.
options
The options to process the request using.
Returns
Promise<T[]>
Inherited from
doCount()
protecteddoCount(options):Promise<HttpResponse>
Defined in: service-core/src/routes/ModelRoute.ts:188
Attempts to retrieve the number of data model objects matching the given set of criteria as specified in the
request query. Any results that have been found are set to the content-length header of the res argument.
Parameters
options
The options to process the request using.
Returns
Promise<HttpResponse>
Inherited from
doCreate()
protecteddoCreate(obj,options):Promise<T|T[]>
Defined in: service-core/src/routes/ModelRoute.ts:283
Attempts to store one or more objects provided in options.req.body into the datasource. Upon success, sets the newly persisted
object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the
client.
Parameters
obj
Partial<T> | Partial<T>[]
The object(s) to store in the database.
options
The options to process the request using.
Returns
Promise<T | T[]>
Inherited from
doCreateObject()
protecteddoCreateObject(obj,options):Promise<T>
Defined in: service-core/src/routes/ModelRoute.ts:223
Attempts to store an object provided in options.req.body into the datasource. Upon success, sets the newly persisted
object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the
client.
Parameters
obj
Partial<T>
The object to store in the database.
options
The options to process the request using.
Returns
Promise<T>
Inherited from
doDelete()
protecteddoDelete(id,options):Promise<void>
Defined in: service-core/src/routes/ModelRoute.ts:312
Attempts to delete an existing data model object with a given unique identifier encoded by the URI parameter
id.
Parameters
id
string
The unique identifier of the object to delete.
options
The options to process the request using.
Returns
Promise<void>
Inherited from
doExists()
protecteddoExists(id,options):Promise<any>
Defined in: service-core/src/routes/ModelRoute.ts:365
Attempts to determine if an existing object with the given unique identifier exists.
Parameters
id
string
The unique identifier of the object to verify exists.
options
The options to process the request using.
Returns
Promise<any>
Inherited from
doFind()
protecteddoFind(options):Promise<T[]>
Defined in: service-core/src/routes/ModelRoute.ts:403
Attempts to retrieve all data model objects matching the given set of criteria as specified in the request
query. Any results that have been found are set to the result property of the res argument. result is
never null.
Parameters
options
The options to process the request using.
Returns
Promise<T[]>
Inherited from
doFindById()
protecteddoFindById(id,options):Promise<T|null>
Defined in: service-core/src/routes/ModelRoute.ts:427
Attempts to retrieve a single data model object as identified by the id parameter in the URI.
Parameters
id
string
options
The options to process the request using.
Returns
Promise<T | null>
Inherited from
doTruncate()
protecteddoTruncate(options):Promise<void>
Defined in: service-core/src/routes/ModelRoute.ts:464
Attempts to remove all entries of the data model type from the datasource matching the given parameters and query.
Parameters
options
The options to process the request using.
Returns
Promise<void>
Inherited from
doUpdate()
protecteddoUpdate(id,obj,options):Promise<T>
Defined in: service-core/src/routes/ModelRoute.ts:529
Attempts to modify an existing data model object as identified by the id parameter in the URI.
Parameters
id
string
obj
UpdateObject<T>
The object to update in the database
options
The options to process the request using.
Returns
Promise<T>
Inherited from
doUpdateProperty()
protecteddoUpdateProperty(id,propertyName,value,options):Promise<T>
Defined in: service-core/src/routes/ModelRoute.ts:581
Attempts to modify a single property of an existing data model object as identified by the id parameter in the URI.
Note that this effectively bypasses optimistic locking and can cause unexpected data overwrites. Use with care.
Parameters
id
string
The unique identifier of the object to update.
propertyName
string
The name of the property to update.
value
any
The value of the property to set.
options
The options to process the request using.
Returns
Promise<T>
Inherited from
exists()
exists(
id,query,res,user?):Promise<any>
Defined in: service-core/src/security/BaseACLRoute.ts:124
Parameters
id
string
query
any
res
user?
JWTUser
Returns
Promise<any>
Overrides
find()
find(
params,query,user?):Promise<T[]>
Defined in: service-core/src/security/BaseACLRoute.ts:134
Parameters
params
any
query
any
user?
JWTUser
Returns
Promise<T[]>
Overrides
findById()
findById(
id,query,user?):Promise<T|null>
Defined in: service-core/src/security/BaseACLRoute.ts:139
Parameters
id
string
query
any
user?
JWTUser
Returns
Promise<T | null>
Overrides
truncate()
truncate(
params,query,user?):Promise<void>
Defined in: service-core/src/security/BaseACLRoute.ts:144
Parameters
params
any
query
any
user?
JWTUser
Returns
Promise<void>
Overrides
update()
update(
id,obj,req,user?):Promise<T>
Defined in: service-core/src/security/BaseACLRoute.ts:149
Parameters
id
string
obj
UpdateObject<T>
req
user?
JWTUser
Returns
Promise<T>
Overrides
updateBulk()
updateBulk(
obj,req,user?):Promise<T[]>
Defined in: service-core/src/security/BaseACLRoute.ts:169
Parameters
obj
UpdateObject<T>[]
req
user?
JWTUser
Returns
Promise<T[]>
Overrides
updateProperty()
updateProperty(
id,propertyName,obj,user?):Promise<T>
Defined in: service-core/src/security/BaseACLRoute.ts:159
Parameters
id
string
propertyName
string
obj
any
user?
JWTUser
Returns
Promise<T>
Overrides
validate()
validate(
objs,options?):Promise<void>
Defined in: service-core/src/routes/ModelRoute.ts:623
Calls repoUtils.validate() to validate the object(s) provided.
Parameters
objs
Partial<T> | Partial<T>[]
options?
CreateRequestOptions | UpdateRequestOptions<T>
Returns
Promise<void>
Inherited from
validateCreate()
protectedvalidateCreate(obj,user?):Promise<void>
Defined in: service-core/src/routes/CRUDRoute.ts:77
Override this function to perform additional custom validation of object creation. This is called
for each object passed to the create() operation.
Parameters
obj
Partial<T>
user?
JWTUser
Returns
Promise<void>
Inherited from
validateUpdate()
protectedvalidateUpdate(id,obj,user?):Promise<void>
Defined in: service-core/src/routes/CRUDRoute.ts:166
Override this function to perform additional custom validation of object updates. This is called
for update() and updateBulk() operations. updateBulk() calls this function for each update
object.
Parameters
id
string
obj
UpdateObject<T>
user?
JWTUser
Returns
Promise<void>