Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions types/sap__approuter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@
For full help, please consult the README file in @sap/approuter (the source npm package) or
https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/LATEST/en-US/050d87a61faa4fb88f687abd7bdf16ce.html


## Limitations

These types (and their tests) are mostly extracted from the above-mentioned README file and `doc/extending.md`
in @sap/approuter (the source npm package). If some types are incorrect or missing, please open up an issue at
https://github.com/DefinitelyTyped/DefinitelyTyped, or, even better, add them by yourself via a Pull Request.


### Command Parser

Adding custom commands with commander.js is currently not supported.
The latest version of commander.js is typed but approuter is using an older version.


### Middlewares

There is a set of basic middlewares in the `lib/middleware` folder. The middlewares are currently not completely typed.
Feel free to provide the types if you need them.


### Express

Approuter uses express internally. The types (e.g. request, response) are currently based on the http package.
Expand Down
9 changes: 6 additions & 3 deletions types/sap__approuter/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ declare namespace approuter {

type RouterConfig = unknown;

/**
* lib/configuration/schemas/options-schema.json
*/
interface StartOptions {
/** A TCP port the application router will listen to */
port?: string;
port?: string | number;

/** The working directory for the application router, should contain the xs-app.json file */
workingDir?: string;
Expand All @@ -119,13 +122,13 @@ declare namespace approuter {
extensions?: Extensions[];

/** An object representing the content which is usually put in xs-app.json file. If this property is present it will take precedence over the content of xs-app.json. */
xsAppConfig?: ComSapXsappSchema_82;
xsappConfig?: ComSapXsappSchema_82;

/**
* Options similar to [https.createServer](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
* If this property is present, application router will be started as an https server.
*/
httpsConfig?: ServerOptions;
httpsOptions?: ServerOptions;

/**
* Provide custom access token
Expand Down
2 changes: 1 addition & 1 deletion types/sap__approuter/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/sap__approuter",
"version": "14.3.9999",
"version": "16.6.9999",
"projects": [
"https://www.npmjs.com/package/@sap/approuter"
],
Expand Down
24 changes: 22 additions & 2 deletions types/sap__approuter/sap__approuter-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* These tests are mostly extracted from the README file and `doc/extending.md` (both in @sap/approuter (the source npm
* package).
*/
import { MiddlewareHandler, StartOptions } from "@sap/approuter";
import { MiddlewareHandler, RouterConfigOptions, StartOptions } from "@sap/approuter";
import approuter = require("@sap/approuter");
import xsrfHandler = require("@sap/approuter/lib/middleware/xsrf-token-handler");

Expand Down Expand Up @@ -72,7 +72,7 @@ ar.start({
});

let customRouterConfig: unknown;
const options = {
const options: RouterConfigOptions = {
xsappConfig: {
routes: [
{
Expand Down Expand Up @@ -175,3 +175,23 @@ function middlewareHandlerWithCustomProps(): MiddlewareHandler<RequestWithSessio
}

ar.beforeRequestHandler.use("/my-ext", middlewareHandlerWithCustomProps);

/*************** start options ***************/

const startOptions: StartOptions = {
port: 5000,
xsappConfig: {
sessionTimeout: 3600,
},
httpsOptions: {
key: "key",
cert: "cert",
},
workingDir: "/path/to/working/dir",
extensions: [],
getRouterConfig: () => null,
getSessionSecret: () => "session",
getToken: () => "token",
};

ar.start(startOptions);