sprint-es 0.0.49 ā 0.0.51
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.
- package/dist/cjs/cli.cjs +2 -3
- package/dist/cjs/index.cjs +9 -1
- package/dist/esm/cli.js +2 -3
- package/dist/esm/index.js +9 -1
- package/dist/types/sprint.d.ts +2 -2
- package/dist/types/sprint.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/cli.cjs
CHANGED
|
@@ -88,15 +88,14 @@ switch (command) {
|
|
|
88
88
|
break;
|
|
89
89
|
case "generate-keys":
|
|
90
90
|
const { publicKey, privateKey } = crypto__namespace.generateKeyPairSync("rsa", {
|
|
91
|
-
modulusLength:
|
|
91
|
+
modulusLength: 2048,
|
|
92
92
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
93
93
|
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
94
94
|
});
|
|
95
|
-
const jwtSecret = crypto__namespace.randomBytes(32).toString("hex");
|
|
96
95
|
console.log("\nš Generating JWT keys...\n");
|
|
97
96
|
console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
|
|
98
97
|
console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
|
|
99
|
-
console.log("\nJWT_ENCRYPTION_SECRET=" +
|
|
98
|
+
console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
|
|
100
99
|
console.log("\nš Add these to your .env file (use single quotes for multiline values):\n");
|
|
101
100
|
process.exit(0);
|
|
102
101
|
break;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -121,6 +121,7 @@ class Sprint {
|
|
|
121
121
|
return void 0;
|
|
122
122
|
};
|
|
123
123
|
req.sprint = { getAuthorization };
|
|
124
|
+
req.custom = {};
|
|
124
125
|
next();
|
|
125
126
|
});
|
|
126
127
|
this.app.use((_, res, next) => {
|
|
@@ -308,7 +309,14 @@ class Sprint {
|
|
|
308
309
|
return this.app.patch(this.applyPrefix(path2), handler);
|
|
309
310
|
}
|
|
310
311
|
use(pathOrHandler, maybeHandler) {
|
|
311
|
-
if (typeof pathOrHandler === "string" && maybeHandler)
|
|
312
|
+
if (typeof pathOrHandler === "string" && maybeHandler) {
|
|
313
|
+
return this.app.use(this.applyPrefix(pathOrHandler), maybeHandler);
|
|
314
|
+
}
|
|
315
|
+
if (pathOrHandler && typeof pathOrHandler === "object" && "handler" in pathOrHandler) {
|
|
316
|
+
const config = pathOrHandler;
|
|
317
|
+
const handlers = Array.isArray(config.handler) ? config.handler : [config.handler];
|
|
318
|
+
return this.app.use(...handlers);
|
|
319
|
+
}
|
|
312
320
|
return this.app.use(pathOrHandler);
|
|
313
321
|
}
|
|
314
322
|
listen(callback) {
|
package/dist/esm/cli.js
CHANGED
|
@@ -70,15 +70,14 @@ switch (command) {
|
|
|
70
70
|
break;
|
|
71
71
|
case "generate-keys":
|
|
72
72
|
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
|
|
73
|
-
modulusLength:
|
|
73
|
+
modulusLength: 2048,
|
|
74
74
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
75
75
|
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
76
76
|
});
|
|
77
|
-
const jwtSecret = crypto.randomBytes(32).toString("hex");
|
|
78
77
|
console.log("\nš Generating JWT keys...\n");
|
|
79
78
|
console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
|
|
80
79
|
console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
|
|
81
|
-
console.log("\nJWT_ENCRYPTION_SECRET=" +
|
|
80
|
+
console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
|
|
82
81
|
console.log("\nš Add these to your .env file (use single quotes for multiline values):\n");
|
|
83
82
|
process.exit(0);
|
|
84
83
|
break;
|
package/dist/esm/index.js
CHANGED
|
@@ -118,6 +118,7 @@ class Sprint {
|
|
|
118
118
|
return void 0;
|
|
119
119
|
};
|
|
120
120
|
req.sprint = { getAuthorization };
|
|
121
|
+
req.custom = {};
|
|
121
122
|
next();
|
|
122
123
|
});
|
|
123
124
|
this.app.use((_, res, next) => {
|
|
@@ -305,7 +306,14 @@ class Sprint {
|
|
|
305
306
|
return this.app.patch(this.applyPrefix(path2), handler);
|
|
306
307
|
}
|
|
307
308
|
use(pathOrHandler, maybeHandler) {
|
|
308
|
-
if (typeof pathOrHandler === "string" && maybeHandler)
|
|
309
|
+
if (typeof pathOrHandler === "string" && maybeHandler) {
|
|
310
|
+
return this.app.use(this.applyPrefix(pathOrHandler), maybeHandler);
|
|
311
|
+
}
|
|
312
|
+
if (pathOrHandler && typeof pathOrHandler === "object" && "handler" in pathOrHandler) {
|
|
313
|
+
const config = pathOrHandler;
|
|
314
|
+
const handlers = Array.isArray(config.handler) ? config.handler : [config.handler];
|
|
315
|
+
return this.app.use(...handlers);
|
|
316
|
+
}
|
|
309
317
|
return this.app.use(pathOrHandler);
|
|
310
318
|
}
|
|
311
319
|
listen(callback) {
|
package/dist/types/sprint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Handler, SprintOptions } from './types';
|
|
1
|
+
import { Handler, SprintOptions, MiddlewareConfig } from './types';
|
|
2
2
|
import { default as express, Application } from 'express';
|
|
3
3
|
export declare const isDevelopment: boolean;
|
|
4
4
|
export declare const isProduction: boolean;
|
|
@@ -36,7 +36,7 @@ export declare class Sprint {
|
|
|
36
36
|
put(path: string, handler: Handler): express.Application;
|
|
37
37
|
delete(path: string, handler: Handler): express.Application;
|
|
38
38
|
patch(path: string, handler: Handler): express.Application;
|
|
39
|
-
use(pathOrHandler: string | Handler, maybeHandler?: Handler): express.Application;
|
|
39
|
+
use(pathOrHandler: string | Handler | MiddlewareConfig, maybeHandler?: Handler): express.Application;
|
|
40
40
|
listen(callback?: () => void): void;
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=sprint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACrF,OAAO,OAAO,EAAE,EAAE,WAAW,EAAoD,MAAM,SAAS,CAAC;AAejG,eAAO,MAAM,aAAa,SAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AAEnC,qBAAa,MAAM;IACR,GAAG,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,IAAI,CAAqC;IACjD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,iBAAiB,CAA0B;gBAEvC,EACR,IAAuB,EACvB,UAAuB,EACvB,eAAiC,EACjC,YAA2B,EAC3B,SAAkB,EAClB,eAAwB,EACxB,MAAW,EACX,UAAiB,EACpB,GAAE,aAAkB;YAkBP,IAAI;IA+BlB,OAAO,CAAC,YAAY;IAiDpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA4B9B;;OAEG;YACW,eAAe;IAgC7B,OAAO,CAAC,eAAe;YAcT,UAAU;YAgDV,YAAY;IAmB1B,OAAO,CAAC,YAAY;IAgCpB,+BAA+B;IAC/B,OAAO,CAAC,WAAW;IAMZ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACpC,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,EAAE,YAAY,CAAC,EAAE,OAAO;IAclF,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;CAsDzC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export interface SprintRequest {
|
|
|
6
6
|
getAuthorization: (sources?: AuthorizationSource | AuthorizationSource[]) => string | undefined;
|
|
7
7
|
}
|
|
8
8
|
export type SprintResponse = Response;
|
|
9
|
-
export type NextFunction = NextFunction;
|
|
10
9
|
declare global {
|
|
11
10
|
namespace Express {
|
|
12
11
|
interface Request {
|
|
13
12
|
sprint: SprintRequest;
|
|
13
|
+
custom: any;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -68,4 +68,5 @@ export interface SprintOptions {
|
|
|
68
68
|
/** Auto-start the server. Default: true */
|
|
69
69
|
autoListen?: boolean;
|
|
70
70
|
}
|
|
71
|
+
export type { NextFunction } from 'express';
|
|
71
72
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpG,MAAM,MAAM,OAAO,GAAG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