Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b7a74ca
Set release status
chgeo Apr 30, 2023
d15cb44
Set release status
chgeo Apr 30, 2023
09ce1e4
Checkmark styling: use consistent char
chgeo May 1, 2023
19f3ae4
Support comma-sep csv syntax
chgeo May 1, 2023
c45c817
Update aspects.md (#115)
BraunMatthias May 2, 2023
979dbea
Add docu for "additional odata vocabs" (#117)
stewsk May 2, 2023
45644e0
Describe OpenType support in OData v4 (#94)
eugene-andreev May 2, 2023
cff702e
@cds.localized and expanded entities (#105)
mariayord May 2, 2023
c8f15b8
Fix layout and other glitches in `about` (#119)
chgeo May 2, 2023
b635449
Minor cosmetics
danjoa May 2, 2023
2bb6908
Don't use IndexList (-> in general)
danjoa May 2, 2023
ed522c8
New cds.Services Guide
danjoa May 2, 2023
0b2cf53
fixed link
danjoa May 2, 2023
ba681c9
.
danjoa May 2, 2023
b455a96
Fix link
chgeo May 2, 2023
95f73d9
Fix styling of some synopsis
chgeo May 2, 2023
70d39e6
Fix anchor links
chgeo May 2, 2023
6317b80
Relace images w/ code by code blocks
chgeo May 2, 2023
b6bc328
Fix cds snippet
chgeo May 2, 2023
bdb198d
Another cds snippet error
chgeo May 2, 2023
28d9d67
Split code block
chgeo May 2, 2023
a9ea043
Advanced - OData: updated links and naming (#121)
renejeglinsky May 3, 2023
a5de7ae
cds import : updating doc for asyncapi import (#111)
muskansethi1 May 3, 2023
745dd61
fix: app-specific settings via cds.env (#120)
sjvans May 3, 2023
a03ef91
cds.env: better styling and code groups
chgeo May 3, 2023
95b203b
Update odata.md (#122)
renejeglinsky May 3, 2023
1943daa
Revised cds.ApplicationService docs
danjoa May 3, 2023
c368f60
..
danjoa May 3, 2023
94ad71f
.
danjoa May 3, 2023
de2032e
minor cleanup
danjoa May 4, 2023
fdfd9b0
Fix anchor links
chgeo May 4, 2023
a5aeabc
Moving (#123)
renejeglinsky May 4, 2023
03d7ca1
Fix link
chgeo May 4, 2023
7c6261b
Fix missing links (#125)
tim-sh May 4, 2023
4fe95cb
annotations.md: Fix missing URLs to some guides (#127)
bugwelle May 4, 2023
52705ba
cds import : minor change (#124)
muskansethi1 May 4, 2023
08b31d7
Update docu in Open Types (#128)
agoerler May 4, 2023
1b6464b
Handle initial java/node state
chgeo May 4, 2023
d1d97ff
Update Java properties from 1.34.0
chgeo May 4, 2023
1df40e8
Fix more dead links
chgeo May 4, 2023
52ac8b1
Better 2 column layout in about page
chgeo May 4, 2023
0c05d45
Adjusted links to core-services
danjoa May 5, 2023
af8508f
Remove superfluous style
chgeo May 5, 2023
f4d6a33
Fix anchor link
chgeo May 5, 2023
3dd20df
CDL: Use `cds` for code blocks instead of `swift` (#129)
bugwelle May 5, 2023
4b2e171
Use default `Inter` font as fallback
chgeo May 5, 2023
a0248b7
fixed error
renejeglinsky May 5, 2023
63d8716
.
renejeglinsky May 5, 2023
8ed392e
fix error
renejeglinsky May 5, 2023
d9624da
Dummy changed
chgeo May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
..
  • Loading branch information
danjoa committed May 3, 2023
commit c368f6084fb1589058970ff96df76753529ba746
54 changes: 25 additions & 29 deletions node.js/app-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,93 +48,89 @@ module.exports = class AdminService extends cds.ApplicationService {

## Generic Handlers in `srv.init()`

Generic handlers are registered by via respective instance methods documented below in `cds.ApplicationService.prototype.init()` like so:
Generic handlers are registered by via respective class methods documented below in `cds.ApplicationService.prototype.init()` like so:

```tsx
class cds.ApplicationService extends cds.Service {
init() {
this.authz()
this.etags()
this.validations()
this.localized()
this.temporal()
this.managed()
this.paging()
this.fiori()
this.crud()
const generics = Reflect.ownKeys(ApplicationService).filter(p => p.startsWith('handle_'))
for (let each of generics) each.call(this)
return super.init()
}
static handle_authorization(){}
static handle_etags(){}
static handle_validations(){}
static handle_temporal_data(){}
static handle_localized_data(){}
static handle_managed_data(){}
static handle_paging(){}
static handle_fiori(){}
static handle_crud(){}
}
```

You can override some of these methods in subclasses, for example to skip certain generic features.



## srv. authz() {.method}
## _static_ handle_authorization() {.method}

This method is adding request handlers for initial authorization checks, as documented in the [Authorization guide](../guides/authorization.md).



## srv. etags() {.method}
## _static_ handle_etags() {.method}

This method is adding request handlers for out-of-the-box concurrency control using ETags, as documented in the [Providing Services guide](../guides/providing-services/index.md#concurrency-control).



## srv. validations() {.method}
## _static_ handle_validations() {.method}

This method is adding request handlers for input validation based in `@assert` annotations, and other, as documented in the [Providing Services guide](../guides/providing-services/index.md#input-validation).


## _static_ handle_temporal_data() {.method}

## srv. localized() {.method}

This method is adding request handlers for handling localized data, as documented in the [Localized Data guide](../guides/localized-data.md).


This method is adding request handlers for handling temporal data, as documented in the [Temporal Data guide](../guides/temporal-data.md).

## srv. temporal() {.method}

This method is adding request handlers for handling temporal data, as documented in the [Temporal Data guide](../guides/temporal-data.md).
## _static_ handle_localized_data() {.method}

This method is adding request handlers for handling localized data, as documented in the [Localized Data guide](../guides/localized-data.md).


## srv. managed() {.method}
## _static_ handle_managed_data() {.method}

This method is adding request handlers for handling managed data, as documented in the [Providing Services guide](../guides/providing-services/index.md#managed-data).



## srv. paging() {.method}
## _static_ handle_paging() {.method}

This method is adding request handlers for paging & implicit sorting, as documented in the [Providing Services guide](../guides/providing-services/index.md#pagination-sorting).



## srv. fiori() {.method}
## _static_ handle_fiori() {.method}

This method is adding request handlers for handling Fiori Drafts and other Fiori-specifics, as documented in the [Serving Fiori guide](../advanced/fiori.md).



## srv. crud() {.method}
## _static_ handle_crud() {.method}

This method is adding request handlers for all CRUD operations including *deep* CRUD, as documented in the [Providing Services guide](../guides/providing-services/index.md#generic-providers).



## Adding Custom Handlers

You can add own generic handlers to all instances of `cds.ApplicationService`, and subclasses thereof, by monkey-patching the `init()` method like so:
You can add own generic handlers to all instances of `cds.ApplicationService`, and subclasses thereof, by simply adding a new class method prefixed with `handle_` like so:

```js
const cds = require('@sap/cds')
const $init = cds.ApplicationService.prototype.init
cds.ApplicationService.prototype.init = cds.service.impl (function(){
cds.ApplicationService.handle_log_events = cds.service.impl (function(){
this.on('*', req => console.log(req.event))
return $init.call(this)
})

```