From 2bdb4fac6dff20056a6cec89c3855955e3ac8706 Mon Sep 17 00:00:00 2001 From: Christian Georgi Date: Tue, 10 Sep 2024 17:26:06 +0200 Subject: [PATCH] Add `cds.app` See https://cap.cloud.sap/docs/node.js/cds-server#cds-app --- CHANGELOG.md | 5 +++++ apis/server.d.ts | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- test/typescript/apis/project/cds-server.ts | 4 +++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de52f4a3..24ada5c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## Version 0.7.0 - tbd + +### Added +- `cds.app` typed as express.js application + ## Version 0.6.5 - 2024-08-13 ### Fixed - The `@types/sap__cds` link created by the `postinstall` script now also works in monorepo setups where the target `@cap-js/cds-types` might already be preinstalled (often hoisted some levels up). diff --git a/apis/server.d.ts b/apis/server.d.ts index 23410d50..7d4a14aa 100644 --- a/apis/server.d.ts +++ b/apis/server.d.ts @@ -163,3 +163,10 @@ type Middleswares = 'context' | 'trace' | 'auth' | 'ctx_model' | string export const middlewares: { add: (middleware: RequestHandler, pos?: XOR, { before: Middleswares }>) => void, } + +/** + * The {@link https://expressjs.com/en/4x/api.html#app| express.js application} constructed by the server implementation. + * + * @see [capire](https://cap.cloud.sap/docs/node.js/cds-server#cds-app) + */ +export const app: Application diff --git a/package-lock.json b/package-lock.json index 7580942d..1d896f20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cap-js/cds-types", - "version": "0.6.5", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cap-js/cds-types", - "version": "0.6.5", + "version": "0.7.0", "hasInstallScript": true, "license": "SEE LICENSE IN LICENSE", "dependencies": { diff --git a/package.json b/package.json index 773fef13..92e8cdc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cap-js/cds-types", - "version": "0.6.5", + "version": "0.7.0", "description": "Type definitions for main packages of CAP, like `@sap/cds`", "repository": "github:cap-js/cds-types", "homepage": "https://cap.cloud.sap/", diff --git a/test/typescript/apis/project/cds-server.ts b/test/typescript/apis/project/cds-server.ts index c10a9454..745b1e31 100644 --- a/test/typescript/apis/project/cds-server.ts +++ b/test/typescript/apis/project/cds-server.ts @@ -1,5 +1,5 @@ import cds from '@sap/cds' -import express from 'express' +import express, { Application } from 'express' const h = undefined as unknown as express.RequestHandler @@ -11,3 +11,5 @@ cds.middlewares.add(h, {after: 'foo'}) cds.middlewares.add(h, {before: 'foo', after: 'foo'}) // @ts-expect-error cds.middlewares.add(h, {after: 'foo', at: 2}) + +cds.app satisfies Application