@thisisagile/easy 7.41.1 → 7.41.2

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 +15 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -261,9 +261,20 @@ The `When` class is a utility that is usually exposed through the `when()` funct
261
261
  The `reject()` method is used to reject the chain, so it will not execute any of its following statements. The `reject()` method accept any error type. A special case is made for `when().not.isValid`. This statement validates the subject of the `when`, and reject with the results (an instance of `Results`) if no parameter is passed to `reject()`.
262
262
 
263
263
  ## Authentication and Authorization
264
- Access to endpoints is configured using the `@requires` decorator group.
265
- If multiple decorators are added, all conditions must be met to access the endpoint.
264
+ Access to endpoints is configured using the `@requires` decorator group. If multiple decorators are added, all conditions must be met to access the endpoint. A resource class (which is the main entry to an **easy** service) with security decorators is shown in the following example.
266
265
 
267
- To use these decorators, the generic `security` middleware must be loaded first.
268
- In most cases, it should be added to the `pre` list of handlers of a service.
266
+ @route(ProductUri.Products)
267
+ export class ProductsResource {
268
+ constructor(readonly manage = new ManageProduct()) {}
269
+
270
+ @get()
271
+ @requires.useCase(UseCase.ViewProduct)
272
+ search = (req: Req): Promise<List<Product>> => this.manage.search(req.q);
273
+
274
+ @post()
275
+ @requires.useCase(UseCase.ManageProduct)
276
+ add = (req: Req): Promise<Product> => this.manage.add(req.body as Json);
277
+ }
278
+
279
+ To use these decorators, the generic `security` middleware must be loaded first. In most cases, it should be added to the `pre` list of handlers of a service.
269
280
  The security middleware takes an optional configuration object, which is documented [in code](packages/easy-express/src/express/SecurityHandler.ts).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "7.41.1",
3
+ "version": "7.41.2",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "7.41.1",
34
+ "@thisisagile/easy-test": "7.41.2",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.5",
37
37
  "@types/validator": "^13.6.6"