41 lines
1.0 KiB
Markdown
41 lines
1.0 KiB
Markdown
# Express Utils for Node Projects
|
|
|
|
## Installation
|
|
|
|
##### 1. Install the package
|
|
|
|
```
|
|
npm install git+https://git.biotronik.int/scm/coe-bs-website/node-pkg-express-utils.git
|
|
```
|
|
|
|
##### 2. Copy the types
|
|
|
|
Copy the content below to any location within the source folder of your project and name it `extend-request.d.ts`.
|
|
It just needs to sit there with no more action required.
|
|
|
|
```ts
|
|
// extend-request.d.ts
|
|
|
|
declare global {
|
|
namespace Express {
|
|
interface Request {
|
|
// fetch user info (needs AuthProxy and some headers)
|
|
getUserInfo(): Promise<import('pkg-express-utils').UserInfo|undefined>;
|
|
// fetch user info (needed for HttpLogger)
|
|
noHttpLogging: boolean|undefined;
|
|
// permission details (after a Permission route)
|
|
permissionDetails: import('role-acl').Permission;
|
|
// switch session to another user;does not close old session (after Session router)
|
|
setSessionById(sessionId: string): Promise<boolean>;
|
|
}
|
|
|
|
interface Response {
|
|
// initialize a logout (needs AuthProxy and some headers)
|
|
initLogout(): boolean;
|
|
}
|
|
}
|
|
}
|
|
|
|
export {};
|
|
```
|