inital #3
This commit is contained in:
32
README.md
32
README.md
@@ -10,6 +10,36 @@ npm install git+https://git.biotronik.int/scm/coe-bs-website/node-pkg-express-ut
|
||||
|
||||
##### 2. Copy the types
|
||||
|
||||
Copy the folder `src/types` to some location within the source folder of your project.
|
||||
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 UserInfo {
|
||||
email: string,
|
||||
email_verified: boolean,
|
||||
family_name: string,
|
||||
given_name: string,
|
||||
groups: string[],
|
||||
name: string,
|
||||
preferred_username: string,
|
||||
sub: string,
|
||||
}
|
||||
|
||||
interface Request {
|
||||
getUserInfo(): Promise<UserInfo|undefined>;
|
||||
noLogging: boolean|undefined;
|
||||
permissionDetails?: import('role-acl').Permission;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
initLogout(): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
```
|
||||
|
||||
2
out/index.d.ts
vendored
2
out/index.d.ts
vendored
@@ -5,7 +5,7 @@ export { AuthProxy } from './auth-proxy';
|
||||
export { Resolvable, WaitForSync } from './helpers/resolvable';
|
||||
export { urlJoin } from './helpers/urlJoin';
|
||||
export { AutoReloader } from './auto-reload';
|
||||
export { Polyfill } from './polyfill';
|
||||
export { Polyfill, PolyfillOptions } from './polyfill';
|
||||
export { Session } from './session';
|
||||
export { Permissions } from './permissions';
|
||||
export { UserInfo } from './helpers/userinfo';
|
||||
|
||||
10
out/polyfill.d.ts
vendored
10
out/polyfill.d.ts
vendored
@@ -1,5 +1,13 @@
|
||||
import { RequestHandler } from 'express';
|
||||
import { PolyfillOptions } from 'polyfill-library';
|
||||
import { PolyfillFeatureList } from 'polyfill-library';
|
||||
export declare type PolyfillOptions = {
|
||||
minify: boolean;
|
||||
unknown: 'polyfill' | 'ignore';
|
||||
features: PolyfillFeatureList;
|
||||
excludes: string[];
|
||||
uaString: string;
|
||||
rum: boolean;
|
||||
};
|
||||
declare function getRouter(opts?: Partial<PolyfillOptions>): RequestHandler;
|
||||
export declare const Polyfill: {
|
||||
getRouter: typeof getRouter;
|
||||
|
||||
60
package-lock.json
generated
60
package-lock.json
generated
@@ -2369,6 +2369,66 @@
|
||||
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
|
||||
"dev": true
|
||||
},
|
||||
"pkg-express-utils-types": {
|
||||
"version": "file:../node-pkg-express-utils-types",
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "14.14.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz",
|
||||
"integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg=="
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||
},
|
||||
"jsonpath-plus": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-0.18.1.tgz",
|
||||
"integrity": "sha512-4yQiuV641HROc4z9YGvnsr8yAdmzbu8JjdAen8WfiXsXewKvTG4ie2bSygF2maek9PcbtROmS6aLQs31BD+oNQ=="
|
||||
},
|
||||
"lodash.clonedeep": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
|
||||
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
|
||||
},
|
||||
"lodash.flattendeep": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
|
||||
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI="
|
||||
},
|
||||
"matcher": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/matcher/-/matcher-1.1.1.tgz",
|
||||
"integrity": "sha512-+BmqxWIubKTRKNWx/ahnCkk3mG8m7OturVlqq6HiojGJTd5hVYbgZm6WzcYPCoB+KBT4Vd6R7WSRG2OADNaCjg==",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"notation": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/notation/-/notation-1.3.6.tgz",
|
||||
"integrity": "sha512-DIuJmrP/Gg1DcXKaApsqcjsJD6jEccqKSfmU3BUx/f1GHsMiTJh70cERwYc64tOmTRTARCeMwkqNNzjh3AHhiw=="
|
||||
},
|
||||
"role-acl": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/role-acl/-/role-acl-4.5.4.tgz",
|
||||
"integrity": "sha512-T7baCc5BCFzLaxUrtAEIDcfK8HM/WTt6l2SLiMts6zLADSp7wOrrU3op0HVKhwjKi01d0Q6T4NeZ0jdLii9WuQ==",
|
||||
"requires": {
|
||||
"jsonpath-plus": "^0.18.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lodash.flattendeep": "^4.4.0",
|
||||
"matcher": "^1.0.0",
|
||||
"notation": "^1.3.5"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
|
||||
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"polyfill-library": {
|
||||
"version": "3.97.0",
|
||||
"resolved": "https://registry.npmjs.org/polyfill-library/-/polyfill-library-3.97.0.tgz",
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
"express-session": "^1.17.1",
|
||||
"json-prune": "^1.1.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"pkg-express-utils-types": "file:../node-pkg-express-utils-types",
|
||||
"polyfill-library": "^3.97.0",
|
||||
"proper-url-join": "^2.1.1",
|
||||
"redis": "^3.0.2",
|
||||
"role-acl": "^4.5.4",
|
||||
"run-script-os": "^1.1.3",
|
||||
"threads": "^1.6.3",
|
||||
"tiny-worker": "^2.3.0",
|
||||
"uuid": "^8.3.1",
|
||||
"winston": "^3.3.3",
|
||||
"run-script-os": "^1.1.3"
|
||||
"winston": "^3.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/connect-redis": "0.0.15",
|
||||
|
||||
@@ -5,7 +5,7 @@ export {AuthProxy} from './auth-proxy';
|
||||
export {Resolvable, WaitForSync} from './helpers/resolvable';
|
||||
export {urlJoin} from './helpers/urlJoin';
|
||||
export {AutoReloader} from './auto-reload';
|
||||
export {Polyfill} from './polyfill';
|
||||
export {Polyfill, PolyfillOptions} from './polyfill';
|
||||
export {Session} from './session';
|
||||
export {Permissions} from './permissions';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {expose} from "threads/worker";
|
||||
import * as fs from "fs";
|
||||
import {analyze} from '@10xjs/polyfill-analyzer';
|
||||
import allPolyfills from '@10xjs/polyfill-analyzer/dist/polyfills';
|
||||
import {PolyfillFeatureList} from "polyfill-library";
|
||||
import {PolyfillFeatureList} from 'polyfill-library';
|
||||
|
||||
expose(() => {
|
||||
const exclude = [
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import {RequestHandler} from 'express';
|
||||
import * as polyfillLibrary from 'polyfill-library';
|
||||
import {PolyfillFeatureList, PolyfillOptions} from 'polyfill-library';
|
||||
import {PolyfillFeatureList} from 'polyfill-library';
|
||||
import {DefaultConfig, Logger, WaitForSync} from '.';
|
||||
import {spawn, Thread, Worker} from 'threads';
|
||||
import {WorkerFunction} from 'threads/dist/types/worker';
|
||||
|
||||
export type PolyfillOptions = {
|
||||
minify: boolean,
|
||||
unknown: 'polyfill'|'ignore',
|
||||
features: PolyfillFeatureList,
|
||||
excludes: string[],
|
||||
uaString: string,
|
||||
rum: boolean,
|
||||
}
|
||||
|
||||
const features = new WaitForSync<PolyfillFeatureList>();
|
||||
|
||||
(async () => {
|
||||
|
||||
9
src/types/auth-proxy.d.ts
vendored
9
src/types/auth-proxy.d.ts
vendored
@@ -1,9 +0,0 @@
|
||||
declare namespace Express {
|
||||
interface Request {
|
||||
getUserInfo(): Promise<import('../helpers/userinfo').UserInfo|undefined>;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
initLogout(): boolean;
|
||||
}
|
||||
}
|
||||
28
src/types/extend-request.d.ts
vendored
Normal file
28
src/types/extend-request.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// extend-request.d.ts
|
||||
|
||||
declare global {
|
||||
namespace Express {
|
||||
interface UserInfo {
|
||||
email: string,
|
||||
email_verified: boolean,
|
||||
family_name: string,
|
||||
given_name: string,
|
||||
groups: string[],
|
||||
name: string,
|
||||
preferred_username: string,
|
||||
sub: string,
|
||||
}
|
||||
|
||||
interface Request {
|
||||
getUserInfo(): Promise<UserInfo|undefined>;
|
||||
noLogging: boolean|undefined;
|
||||
permissionDetails?: import('role-acl').Permission;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
initLogout(): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
5
src/types/logging.d.ts
vendored
5
src/types/logging.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
declare namespace Express {
|
||||
interface Request {
|
||||
noLogging: boolean|undefined;
|
||||
}
|
||||
}
|
||||
5
src/types/permissions.d.ts
vendored
5
src/types/permissions.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
declare namespace Express {
|
||||
interface Request {
|
||||
permissionDetails?: import('role-acl').Permission;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user