@schmock/express 1.0.2 → 1.2.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/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -66,5 +66,4 @@ export interface ExpressAdapterOptions {
|
|
|
66
66
|
* Convert a Schmock mock instance to Express middleware
|
|
67
67
|
*/
|
|
68
68
|
export declare function toExpress(mock: CallableMockInstance, options?: ExpressAdapterOptions): RequestHandler;
|
|
69
|
-
export default toExpress;
|
|
70
69
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAM1D,OAAO,KAAK,EAAgB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,KAAK,GAAG,CAAC;IAErD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3E;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAErE;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACd,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,KAEX;QACE,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,GACD,SAAS,GACT,OAAO,CAAC,GAAG,CAAC,CAAC;IAEjB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CACf,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,EACD,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,KAEX;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAC9D,SAAS,GACT,OAAO,CACH;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAC9D,SAAS,CACZ,CAAC;CACP;AAwED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAkFhB"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class $ extends Error{code;context;constructor(
|
|
1
|
+
var Q="ROUTE_NOT_FOUND",O=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"];function F(A){return O.includes(A)}function G(A){let B=A.toUpperCase();if(!F(B))throw Error(`Invalid HTTP method: "${A}"`);return B}class $ extends Error{code;context;constructor(A,B,V){super(A);this.code=B;this.context=V;if(this.name="SchmockError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor)}}function M(A,B){if(A.status!=null)B.status(A.status);if(A.headers)Object.entries(A.headers).forEach(([V,W])=>{if(typeof W==="string")B.set(V,W)});if(A.body!==void 0)if(typeof A.body==="string")B.send(A.body);else B.json(A.body);else B.end()}function P(A){return Object.fromEntries(Object.entries(A).map(([B,V])=>[B,Array.isArray(V)?V[0]:V||""]))}function S(A){let B={};for(let[V,W]of Object.entries(A))if(typeof W==="string")B[V]=W;else if(Array.isArray(W))B[V]=W[0]?String(W[0]):"";else if(W!=null)B[V]=String(W);return B}function a(A,B={}){let{errorFormatter:V,passErrorsToNext:W=!0,transformHeaders:H=P,transformQuery:N=S,beforeRequest:U,beforeResponse:w}=B;return async(X,z,_)=>{try{let J={method:G(X.method),path:X.path,headers:H(X.headers),body:X.body,query:N(X.query)};if(U){let Z=await U(X,z);if(Z)J={...J,...Z,method:G(Z.method||J.method)}}let Y=await A.handle(J.method,J.path,{headers:J.headers,body:J.body,query:J.query}),L=Y.body;if(Y.status===404&&L&&typeof L==="object"&&"code"in L&&L.code===Q){_();return}if(w){let Z=await w(Y,X,z);if(Z)Y=Z}M(Y,z)}catch(J){if(J instanceof $&&V){let Y=V(J,X);z.status(500).json(Y)}else if(W)_(J);else z.status(500).json({error:J instanceof Error?J.message:"Internal Server Error",code:J instanceof $?J.code:"INTERNAL_ERROR"})}}}export{a as toExpress};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/express",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Express adapter for Schmock mock API generator",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/express": "^5.0.6",
|
|
32
32
|
"express": "^5.2.1",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
|
-
"vitest": "^4.0.
|
|
34
|
+
"vitest": "^4.0.18"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@schmock/core": "^1.0.0",
|