alado 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +29 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,6 +19,7 @@
19
19
  - [defineRequest](#definerequest)
20
20
  - [defineResponse](#defineresponse)
21
21
  - [withAuth](#withauth)
22
+ - [accessControl](#acesscontrol)
22
23
  - [DTOs](#dtos)
23
24
  - [validateProperty](#validateproperty)
24
25
  - [validation](#validation)
@@ -26,6 +27,7 @@
26
27
  - [transformProperty](#transformproperty)
27
28
  - [fileUploadProperty](#fileuploadproperty)
28
29
  - [Authentication](#authentication)
30
+ - [Access Control](#accesscontrol)
29
31
  - [File Uploads](#file-uploads)
30
32
  - [OpenAPI / Swagger](#openapi--swagger)
31
33
  - [API Reference](#api-reference)
@@ -304,6 +306,32 @@ See [Authentication](#authentication) for full config details.
304
306
 
305
307
  ---
306
308
 
309
+ ### `accessControl`
310
+
311
+ Attaches an access control pipeline to a route.
312
+
313
+ ```ts
314
+ @patch('/user/:id', { tags: ['User'] })
315
+ @accessControl([
316
+ {
317
+ inputProperty: 'auth.user.id',
318
+ transformInputProperty: async (v: unknown) => v.toString(),
319
+ compareWithProperty: 'path.id',
320
+ statusCode: 403,
321
+ message: 'Access Denied',
322
+ },
323
+ ])
324
+ @withAuth(bearerAuth)
325
+ @defineRequest({ path: Id, body: UserDto })
326
+ async update(req: Request) {
327
+ console.log(req.auth.user); // injected by the auth handler
328
+ }
329
+ ```
330
+
331
+ See [Access Control](#accesscontrol) for full config details.
332
+
333
+ ---
334
+
307
335
  ### Full controller example
308
336
 
309
337
  ```ts
@@ -1145,4 +1173,4 @@ The object your handler must return:
1145
1173
 
1146
1174
  ## License
1147
1175
 
1148
- MIT © [Databikers Limited](https://databikers.com)
1176
+ MIT © [Data Bikers Limited](https://databikers.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alado",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Extremely fast, lightweight, robust framework for HTTP applications written in Node.js",
5
5
  "keywords": [
6
6
  "HTTP",