Skip to main content

Abstract Class: BaseACLRoute<T>

Defined in: service-core/src/security/BaseACLRoute.ts:54

The BaseACLRoute class provides a base set of endpoints for managing Access Control List records.

Exposed endpoints:

NameHTTP MethodWhat it does
countHEAD /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.
createPOST /Adds one or more new ACLs to the datastore.
deleteDELETE /:idRemoves an existing ACL from the datastore.
existsHEAD /:idChecks if the ACL with the given ID exists in the datastore. Sets Content-Length header to 1 if the ACL exists, otherwise 0.
findGET /Returns all ACLs matching the provided set of criteria in the request's query parameters.
findByIdGET /:idReturns a single ACL with a specified unique identifier.
truncateDELETE /Removes all ACLs from the datastore.
updatePUT /:idModifies an existing ACL in the datastore.
updateBulkPUT /Modifies multiple existing ACLs in the datastore.
updatePropertyPUT /:id/:propertyModifies an single property of the given name of an existing ACL in the datastore.

!!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

Type Parameters

T

T extends AccessControlList

Constructors

Constructor

new BaseACLRoute<T>(): BaseACLRoute<T>

Returns

BaseACLRoute<T>

Inherited from

CRUDRoute.constructor

Properties

aclUtils?

protected optional aclUtils?: ACLUtils

Defined in: service-core/src/routes/ModelRoute.ts:121

Inherited from

CRUDRoute.aclUtils


cacheClient?

protected optional cacheClient?: Redis

Defined in: service-core/src/routes/ModelRoute.ts:125

The redis client that will be used as a 2nd level cache for all cacheable models.

Inherited from

CRUDRoute.cacheClient


config?

protected optional config?: any

Defined in: service-core/src/routes/ModelRoute.ts:129

The global application configuration.

Inherited from

CRUDRoute.config


defaultACLUid

protected defaultACLUid: string = ""

Defined in: service-core/src/routes/ModelRoute.ts:132

The unique identifier of the default ACL for the model type.

Inherited from

CRUDRoute.defaultACLUid


logger

protected logger: any

Defined in: service-core/src/routes/ModelRoute.ts:135

Inherited from

CRUDRoute.logger


notificationUtils?

protected optional notificationUtils?: NotificationUtils

Defined in: service-core/src/routes/ModelRoute.ts:138

Inherited from

CRUDRoute.notificationUtils


objectFactory?

protected optional objectFactory?: ObjectFactory

Defined in: service-core/src/routes/ModelRoute.ts:141

Inherited from

CRUDRoute.objectFactory


repoUtils?

protected optional repoUtils?: RepoUtils<T>

Defined in: service-core/src/routes/ModelRoute.ts:147

The repository utility class to use for common operations.

Inherited from

CRUDRoute.repoUtils


repoUtilsClass

protected readonly repoUtilsClass: any = RepoUtils

Defined in: service-core/src/routes/CRUDRoute.ts:52

The class of the RepoUtils to use when instantiating the utility.

Inherited from

CRUDRoute.repoUtilsClass


trackChanges

protected trackChanges: number = 0

Defined in: service-core/src/routes/ModelRoute.ts:153

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

CRUDRoute.trackChanges


trustedRoles

protected trustedRoles: string[]

Defined in: service-core/src/routes/ModelRoute.ts:156

Inherited from

CRUDRoute.trustedRoles

Accessors

modelClass

Get Signature

get modelClass(): any

Defined in: service-core/src/routes/ModelRoute.ts:161

The class type of the model this route is associated with.

Returns

any

Inherited from

CRUDRoute.modelClass

Methods

checkNotDefault()

protected checkNotDefault(id): void

Defined in: service-core/src/security/BaseACLRoute.ts:73

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()

protected checkPerms(params, user): Promise<void>

Defined in: service-core/src/security/BaseACLRoute.ts:55

Parameters

params

any

user

JWTUser

Returns

Promise<void>


checkPermsBulk()

protected checkPermsBulk(objs, user): void

Defined in: service-core/src/security/BaseACLRoute.ts:84

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:97

Parameters

params

any

query

any

res

HttpResponse

user?

JWTUser

Returns

Promise<any>

Overrides

CRUDRoute.count


create()

create(obj, req, user?): Promise<T | T[]>

Defined in: service-core/src/security/BaseACLRoute.ts:107

Parameters

obj

T | T[]

req

HttpRequest

user?

JWTUser

Returns

Promise<T | T[]>

Overrides

CRUDRoute.create


delete()

delete(id, version, purge, req, user?): Promise<void>

Defined in: service-core/src/security/BaseACLRoute.ts:112

Parameters

id

string

version

string | undefined

purge

string | undefined

req

HttpRequest

user?

JWTUser

Returns

Promise<void>

Overrides

CRUDRoute.delete


doBulkCreate()

protected doBulkCreate(objs, options): Promise<T[]>

Defined in: service-core/src/routes/ModelRoute.ts:259

Attempts to store a collection of objects provided in options.req.body into the datastore. 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

CreateRequestOptions

The options to process the request using.

Returns

Promise<T[]>

Inherited from

CRUDRoute.doBulkCreate


doBulkUpdate()

protected doBulkUpdate(objs, options): Promise<T[]>

Defined in: service-core/src/routes/ModelRoute.ts:498

Attempts to modify a collection of existing data model objects.

Parameters

objs

UpdateObject<T>[]

The object(s) to bulk update in the database.

options

UpdateRequestOptions<T>

The options to process the request using.

Returns

Promise<T[]>

Inherited from

CRUDRoute.doBulkUpdate


doCount()

protected doCount(options): Promise<HttpResponse>

Defined in: service-core/src/routes/ModelRoute.ts:193

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

FindRequestOptions

The options to process the request using.

Returns

Promise<HttpResponse>

Inherited from

CRUDRoute.doCount


doCreate()

protected doCreate(obj, options): Promise<T | T[]>

Defined in: service-core/src/routes/ModelRoute.ts:289

Attempts to store one or more objects provided in options.req.body into the datastore. 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

CreateRequestOptions

The options to process the request using.

Returns

Promise<T | T[]>

Inherited from

CRUDRoute.doCreate


doCreateObject()

protected doCreateObject(obj, options): Promise<T>

Defined in: service-core/src/routes/ModelRoute.ts:229

Attempts to store an object provided in options.req.body into the datastore. 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

CreateRequestOptions

The options to process the request using.

Returns

Promise<T>

Inherited from

CRUDRoute.doCreateObject


doDelete()

protected doDelete(id, options): Promise<void>

Defined in: service-core/src/routes/ModelRoute.ts:317

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

DeleteRequestOptions

The options to process the request using.

Returns

Promise<void>

Inherited from

CRUDRoute.doDelete


doExists()

protected doExists(id, options): Promise<any>

Defined in: service-core/src/routes/ModelRoute.ts:363

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

FindRequestOptions

The options to process the request using.

Returns

Promise<any>

Inherited from

CRUDRoute.doExists


doFind()

protected doFind(options): Promise<T[]>

Defined in: service-core/src/routes/ModelRoute.ts:397

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

FindRequestOptions

The options to process the request using.

Returns

Promise<T[]>

Inherited from

CRUDRoute.doFind


doFindById()

protected doFindById(id, options): Promise<T | null>

Defined in: service-core/src/routes/ModelRoute.ts:424

Attempts to retrieve a single data model object as identified by the id parameter in the URI.

Parameters

id

string

options

FindRequestOptions

The options to process the request using.

Returns

Promise<T | null>

Inherited from

CRUDRoute.doFindById


doTruncate()

protected doTruncate(options): Promise<void>

Defined in: service-core/src/routes/ModelRoute.ts:459

Attempts to remove all entries of the data model type from the datastore matching the given parameters and query.

Parameters

options

TruncateRequestOptions

The options to process the request using.

Returns

Promise<void>

Inherited from

CRUDRoute.doTruncate


doUpdate()

protected doUpdate(id, obj, options): Promise<T>

Defined in: service-core/src/routes/ModelRoute.ts:526

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

UpdateRequestOptions<T>

The options to process the request using.

Returns

Promise<T>

Inherited from

CRUDRoute.doUpdate


doUpdateProperty()

protected doUpdateProperty(id, propertyName, value, options): Promise<T>

Defined in: service-core/src/routes/ModelRoute.ts:577

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

UpdateRequestOptions<T>

The options to process the request using.

Returns

Promise<T>

Inherited from

CRUDRoute.doUpdateProperty


exists()

exists(id, query, res, user?): Promise<any>

Defined in: service-core/src/security/BaseACLRoute.ts:123

Parameters

id

string

query

any

res

HttpResponse

user?

JWTUser

Returns

Promise<any>

Overrides

CRUDRoute.exists


find()

find(params, query, user?): Promise<T[]>

Defined in: service-core/src/security/BaseACLRoute.ts:133

Parameters

params

any

query

any

user?

JWTUser

Returns

Promise<T[]>

Overrides

CRUDRoute.find


findById()

findById(id, query, user?): Promise<T | null>

Defined in: service-core/src/security/BaseACLRoute.ts:138

Parameters

id

string

query

any

user?

JWTUser

Returns

Promise<T | null>

Overrides

CRUDRoute.findById


truncate()

truncate(params, query, user?): Promise<void>

Defined in: service-core/src/security/BaseACLRoute.ts:143

Parameters

params

any

query

any

user?

JWTUser

Returns

Promise<void>

Overrides

CRUDRoute.truncate


update()

update(id, obj, req, user?): Promise<T>

Defined in: service-core/src/security/BaseACLRoute.ts:148

Parameters

id

string

obj

UpdateObject<T>

req

HttpRequest

user?

JWTUser

Returns

Promise<T>

Overrides

CRUDRoute.update


updateBulk()

updateBulk(obj, req, user?): Promise<T[]>

Defined in: service-core/src/security/BaseACLRoute.ts:168

Parameters

obj

UpdateObject<T>[]

req

HttpRequest

user?

JWTUser

Returns

Promise<T[]>

Overrides

CRUDRoute.updateBulk


updateProperty()

updateProperty(id, propertyName, obj, user?): Promise<T>

Defined in: service-core/src/security/BaseACLRoute.ts:158

Parameters

id

string

propertyName

string

obj

any

user?

JWTUser

Returns

Promise<T>

Overrides

CRUDRoute.updateProperty


validate()

validate(objs, options?): Promise<void>

Defined in: service-core/src/routes/ModelRoute.ts:619

Calls repoUtils.validate() to validate the object(s) provided.

Parameters

objs

Partial<T> | Partial<T>[]

options?

CreateRequestOptions | UpdateRequestOptions<T>

Returns

Promise<void>

Inherited from

CRUDRoute.validate


validateCreate()

protected validateCreate(obj, user?): Promise<void>

Defined in: service-core/src/routes/CRUDRoute.ts:70

Parameters

obj

Partial<T> | Partial<T>[]

user?

JWTUser

Returns

Promise<void>

Inherited from

CRUDRoute.validateCreate


validateUpdate()

protected validateUpdate(id, obj, user?): Promise<void>

Defined in: service-core/src/routes/CRUDRoute.ts:137

Parameters

id

string

obj

UpdateObject<T>

user?

JWTUser

Returns

Promise<void>

Inherited from

CRUDRoute.validateUpdate


validateUpdateBulk()

protected validateUpdateBulk(objs, user?): Promise<void>

Defined in: service-core/src/routes/CRUDRoute.ts:155

Parameters

objs

UpdateObject<T>[]

user?

JWTUser

Returns

Promise<void>

Inherited from

CRUDRoute.validateUpdateBulk