@invect/express 0.0.1
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/LICENSE +21 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/middleware/index.cjs +24 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +15 -0
- package/dist/middleware/index.d.cts.map +1 -0
- package/dist/middleware/index.d.ts +15 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +22 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/router/index.cjs +1106 -0
- package/dist/router/index.cjs.map +1 -0
- package/dist/router/index.d.cts +19 -0
- package/dist/router/index.d.cts.map +1 -0
- package/dist/router/index.d.ts +19 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +1105 -0
- package/dist/router/index.js.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 @robase
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_router_index = require("./router/index.cjs");
|
|
3
|
+
let _invect_core = require("@invect/core");
|
|
4
|
+
Object.defineProperty(exports, "Invect", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return _invect_core.Invect;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
exports.createInvectRouter = require_router_index.createInvectRouter;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/async-handler.ts
|
|
3
|
+
/**
|
|
4
|
+
* Async handler wrapper for Express route handlers
|
|
5
|
+
* Catches async errors and passes them to the error handling middleware
|
|
6
|
+
*/
|
|
7
|
+
function asyncHandler(fn) {
|
|
8
|
+
return (req, res, next) => {
|
|
9
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Async handler for middleware functions
|
|
14
|
+
*/
|
|
15
|
+
function asyncMiddleware(fn) {
|
|
16
|
+
return (req, res, next) => {
|
|
17
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.asyncHandler = asyncHandler;
|
|
22
|
+
exports.asyncMiddleware = asyncMiddleware;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/async-handler.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express';\n\n/**\n * Async handler wrapper for Express route handlers\n * Catches async errors and passes them to the error handling middleware\n */\nexport function asyncHandler(\n fn: (req: Request, res: Response, next: NextFunction) => Promise<unknown>,\n) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(fn(req, res, next)).catch(next);\n };\n}\n\n/**\n * Async handler for middleware functions\n */\nexport function asyncMiddleware(\n fn: (req: Request, res: Response, next: NextFunction) => Promise<void>,\n) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(fn(req, res, next)).catch(next);\n };\n}\n"],"mappings":";;;;;;AAMA,SAAgB,aACd,IACA;AACA,SAAQ,KAAc,KAAe,SAAuB;AAC1D,UAAQ,QAAQ,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK;;;;;;AAOnD,SAAgB,gBACd,IACA;AACA,SAAQ,KAAc,KAAe,SAAuB;AAC1D,UAAQ,QAAQ,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
|
|
3
|
+
//#region src/async-handler.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Async handler wrapper for Express route handlers
|
|
6
|
+
* Catches async errors and passes them to the error handling middleware
|
|
7
|
+
*/
|
|
8
|
+
declare function asyncHandler(fn: (req: Request, res: Response, next: NextFunction) => Promise<unknown>): (req: Request, res: Response, next: NextFunction) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Async handler for middleware functions
|
|
11
|
+
*/
|
|
12
|
+
declare function asyncMiddleware(fn: (req: Request, res: Response, next: NextFunction) => Promise<void>): (req: Request, res: Response, next: NextFunction) => void;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { asyncHandler, asyncMiddleware };
|
|
15
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/async-handler.ts"],"mappings":";;;;;AAMA;;iBAAgB,YAAA,CACd,EAAA,GAAK,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA,KAAiB,OAAA,aAEjD,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA;;;;iBAQ7B,eAAA,CACd,EAAA,GAAK,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA,KAAiB,OAAA,UAEjD,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
|
|
3
|
+
//#region src/async-handler.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Async handler wrapper for Express route handlers
|
|
6
|
+
* Catches async errors and passes them to the error handling middleware
|
|
7
|
+
*/
|
|
8
|
+
declare function asyncHandler(fn: (req: Request, res: Response, next: NextFunction) => Promise<unknown>): (req: Request, res: Response, next: NextFunction) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Async handler for middleware functions
|
|
11
|
+
*/
|
|
12
|
+
declare function asyncMiddleware(fn: (req: Request, res: Response, next: NextFunction) => Promise<void>): (req: Request, res: Response, next: NextFunction) => void;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { asyncHandler, asyncMiddleware };
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/async-handler.ts"],"mappings":";;;;;AAMA;;iBAAgB,YAAA,CACd,EAAA,GAAK,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA,KAAiB,OAAA,aAEjD,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA;;;;iBAQ7B,eAAA,CACd,EAAA,GAAK,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA,KAAiB,OAAA,UAEjD,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/async-handler.ts
|
|
2
|
+
/**
|
|
3
|
+
* Async handler wrapper for Express route handlers
|
|
4
|
+
* Catches async errors and passes them to the error handling middleware
|
|
5
|
+
*/
|
|
6
|
+
function asyncHandler(fn) {
|
|
7
|
+
return (req, res, next) => {
|
|
8
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Async handler for middleware functions
|
|
13
|
+
*/
|
|
14
|
+
function asyncMiddleware(fn) {
|
|
15
|
+
return (req, res, next) => {
|
|
16
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { asyncHandler, asyncMiddleware };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/async-handler.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express';\n\n/**\n * Async handler wrapper for Express route handlers\n * Catches async errors and passes them to the error handling middleware\n */\nexport function asyncHandler(\n fn: (req: Request, res: Response, next: NextFunction) => Promise<unknown>,\n) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(fn(req, res, next)).catch(next);\n };\n}\n\n/**\n * Async handler for middleware functions\n */\nexport function asyncMiddleware(\n fn: (req: Request, res: Response, next: NextFunction) => Promise<void>,\n) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(fn(req, res, next)).catch(next);\n };\n}\n"],"mappings":";;;;;AAMA,SAAgB,aACd,IACA;AACA,SAAQ,KAAc,KAAe,SAAuB;AAC1D,UAAQ,QAAQ,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK;;;;;;AAOnD,SAAgB,gBACd,IACA;AACA,SAAQ,KAAc,KAAe,SAAuB;AAC1D,UAAQ,QAAQ,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK"}
|