diff --git a/node.js/cds-server.md b/node.js/cds-server.md index 3941dddfe..1eff4af42 100644 --- a/node.js/cds-server.md +++ b/node.js/cds-server.md @@ -178,19 +178,32 @@ cds.on('bootstrap', app => { Emitted whenever a CDS model got loaded using `cds.load()` +```js twoslash +// @noErrors +const cds = require('@sap/cds') +cds.on('loaded', model => { /* ... */ }) +``` ### connect {.event} Emitted for each service constructed through [`cds.connect`](cds-connect). - +```js twoslash +// @noErrors +const cds = require('@sap/cds') +cds.on('connect', service => { /* ... */ }) +``` ### serving {.event} Emitted for each service constructed by [`cds.serve`](cds-serve). - +```js twoslash +// @noErrors +const cds = require('@sap/cds') +cds.on('serving', service => { /* ... */ }) +``` ### served {.event} @@ -199,7 +212,7 @@ A one-time event, emitted when all services have been bootstrapped and added to ```js twoslash // @noErrors const cds = require('@sap/cds') -cds.on('served', (services)=>{ +cds.on('served', async (services) => { // We can savely access service instances through the provided argument: const { CatalogService, db } = services // ... @@ -213,6 +226,11 @@ This event supports _asynchronous_ event handlers. A one-time event, emitted when the server has been started and is listening to incoming requests. +```js twoslash +// @noErrors +const cds = require('@sap/cds') +cds.on('listening', ({ server, url }) => { /* ... */ }) +``` ### shutdown {.event} @@ -221,6 +239,11 @@ A one-time event, emitted when the server is closed and/or the process finishes. This event supports _asynchronous_ event handlers. +```js twoslash +// @noErrors +const cds = require('@sap/cds') +cds.on('shutdown', async () => { /* ... */ }) +```