Skip to content

Commit

Permalink
Add cds.app (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo authored Sep 11, 2024
1 parent 0266eb3 commit f4cbc78
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
7 changes: 7 additions & 0 deletions apis/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,10 @@ type Middleswares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
export const middlewares: {
add: (middleware: RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middleswares }>, { 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
4 changes: 3 additions & 1 deletion test/typescript/apis/project/cds-server.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit f4cbc78

Please sign in to comment.