@types/sap__approuter 14.3.0 → 14.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sap__approuter/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for @sap/approuter (https://www.npmjs.com
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sap__approuter.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Wed, 29 Nov 2023 13:08:30 GMT
|
|
12
12
|
* Dependencies: [@types/http-server](https://npmjs.com/package/@types/http-server), [@types/node](https://npmjs.com/package/@types/node), [@types/verror](https://npmjs.com/package/@types/verror)
|
|
13
13
|
|
|
14
14
|
# Credits
|
sap__approuter/index.d.ts
CHANGED
|
@@ -60,22 +60,36 @@ declare namespace approuter {
|
|
|
60
60
|
*/
|
|
61
61
|
backendTimeout?: (req: IncomingMessage, done: () => void) => void;
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
/** In order to make it easier to write middlewares being agnostic of the route, the `req.url` will be altered to remove the route part and the original URL will be set to this value */
|
|
64
|
+
originalUrl?: string;
|
|
65
|
+
|
|
66
|
+
/** Note: On each request, the application router executes registered middlewares in a certain order and the session is not available to all of them. */
|
|
67
|
+
sessionID?: string;
|
|
68
|
+
|
|
69
|
+
sessionStore?: SessionStore;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
73
|
* A handler for requests, called Middleware.
|
|
73
74
|
*
|
|
75
|
+
* The generic type T can be used to add custom properties to the request object type
|
|
76
|
+
* this is useful if a middleware adds custom properties to the request object
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* interface RequestWithSession = {
|
|
80
|
+
* session?: {}
|
|
81
|
+
* }
|
|
82
|
+
* MiddlewareHandler<RequestWithSession>
|
|
83
|
+
*
|
|
74
84
|
* @param request - Data of the incoming Request
|
|
75
85
|
* @param response - Object for the outgoing Response; can be manipulated to alter the response
|
|
76
86
|
* @param next - Call next to give control back to Application Router Middleware
|
|
77
87
|
*/
|
|
78
|
-
type MiddlewareHandler =
|
|
88
|
+
type MiddlewareHandler<T = {}> = (
|
|
89
|
+
request: AppRouterIncomingMessage & T,
|
|
90
|
+
response: ServerResponse,
|
|
91
|
+
next: (value?: Error | string) => void,
|
|
92
|
+
) => void;
|
|
79
93
|
|
|
80
94
|
interface Extensions {
|
|
81
95
|
/**
|
|
@@ -253,21 +267,6 @@ declare namespace approuter {
|
|
|
253
267
|
|
|
254
268
|
/**
|
|
255
269
|
* SAP Application Router
|
|
256
|
-
*
|
|
257
|
-
* For full help, please consult the README file in @sap/approuter (the source npm package) or
|
|
258
|
-
* https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/LATEST/en-US/050d87a61faa4fb88f687abd7bdf16ce.html
|
|
259
|
-
*
|
|
260
|
-
* These types (and their tests) are mostly extracted from the above mentioned README file and `doc/extending.md`
|
|
261
|
-
* in @sap/approuter (the source npm package). If some types are incorrect or missing, please open up an issue at
|
|
262
|
-
* {@link https://github.com/DefinitelyTyped/DefinitelyTyped}, or, even better, add them by yourself via a Pull Request.
|
|
263
|
-
*
|
|
264
|
-
* ## Command Parser
|
|
265
|
-
* The {@link cmdParser} property is set to a {@link Command} instance when instantiating an Approuter. It is possible
|
|
266
|
-
* to disable this feature by setting {@link cmdParser} to false. To do this typesafe, you have to use
|
|
267
|
-
* `Approuter<false>` as a type when creating the Approuter instance.
|
|
268
|
-
* @example
|
|
269
|
-
* const ar = new Approuter<false>();
|
|
270
|
-
* ar.cmdParser = false;
|
|
271
270
|
*/
|
|
272
271
|
interface Approuter extends EventEmitter {
|
|
273
272
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IncomingMessage } from "http";
|
|
2
|
+
|
|
3
|
+
export type checkTokenResult = {
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
details: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a token is required for an incoming request:
|
|
10
|
+
* - GET and HEAD requests do not require a token (except if they are used to fetch a new token)
|
|
11
|
+
* - public path requests do not require a token
|
|
12
|
+
*
|
|
13
|
+
* @param req
|
|
14
|
+
* @returns true if a token is required, else false
|
|
15
|
+
*/
|
|
16
|
+
export function isTokenRequired(req: IncomingMessage): boolean;
|
|
17
|
+
|
|
18
|
+
export function isTokenFetchRequest(req: IncomingMessage): boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Check a token send by the client
|
|
22
|
+
*
|
|
23
|
+
* @param req
|
|
24
|
+
* @returns {isValid: boolean, details: string}
|
|
25
|
+
*/
|
|
26
|
+
export function checkToken(req: IncomingMessage): checkTokenResult;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a new token and stores it in the session (or returns an existing one from the session)
|
|
30
|
+
*
|
|
31
|
+
* @param req
|
|
32
|
+
* @param cb function cb(err, token)
|
|
33
|
+
*/
|
|
34
|
+
export function getToken<T = void>(req: IncomingMessage, cb: (error: Error | null, xsrfToken?: string) => T): T;
|
|
35
|
+
|
|
36
|
+
export function hasTokenFetchHeader(req: IncomingMessage): boolean;
|
|
37
|
+
|
|
38
|
+
export function isGetRequest(req: IncomingMessage): boolean;
|
|
39
|
+
|
|
40
|
+
export function isHeadRequest(req: IncomingMessage): boolean;
|
sap__approuter/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/sap__approuter",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.2",
|
|
4
4
|
"description": "TypeScript definitions for @sap/approuter",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sap__approuter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"@types/node": "*",
|
|
30
30
|
"@types/verror": "*"
|
|
31
31
|
},
|
|
32
|
-
"typesPublisherContentHash": "
|
|
33
|
-
"typeScriptVersion": "4.
|
|
32
|
+
"typesPublisherContentHash": "e06bafbc8452e284b708f640bc11cef75aef577c429bcd01f0185f0c62f1cb13",
|
|
33
|
+
"typeScriptVersion": "4.6"
|
|
34
34
|
}
|