moonflower 1.1.1 → 1.2.0
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/README.md +2 -2
- package/dist/errors/UserFacingErrors.cjs +1 -1
- package/dist/errors/UserFacingErrors.cjs.map +1 -1
- package/dist/errors/UserFacingErrors.d.ts +12 -0
- package/dist/errors/UserFacingErrors.d.ts.map +1 -1
- package/dist/errors/UserFacingErrors.mjs +30 -9
- package/dist/errors/UserFacingErrors.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +52 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/errors/UserFacingErrors.ts +21 -0
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Moonflower
|
|
2
2
|
|
|
3
|
-
> This section is work-in-progress.
|
|
4
|
-
|
|
5
3
|
Moonflower is a TypeScript-first [Koa Router](https://www.npmjs.com/package/koa-router) extension that allows for automatic [OpenAPI](https://www.openapis.org/what-is-openapi) spec generation directly from backend code, without any extra work. Combined with an ORM like [Prisma.js](https://www.npmjs.com/package/prisma) and an API client generator on frontend, it allows for creation of end-to-end type safe REST API.
|
|
6
4
|
|
|
7
5
|
Moonflower provides type safe 'hooks' that handle runtime validation and return clean types with minimal boilerplate.
|
|
8
6
|
|
|
7
|
+
> This readme is work-in-progress.
|
|
8
|
+
|
|
9
9
|
## Feature Overview
|
|
10
10
|
|
|
11
11
|
- React hooks inspired Node.js backend REST API
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./BaseHttpError.cjs"),e=require("./StatusCodes.cjs");class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./BaseHttpError.cjs"),e=require("./StatusCodes.cjs"),s=t.BaseHttpError;class a extends t.BaseHttpError{constructor(r){super(e.StatusCodes.BAD_REQUEST,r)}}class E extends t.BaseHttpError{constructor(r){super(e.StatusCodes.BAD_REQUEST,r)}}class u extends t.BaseHttpError{constructor(r){super(e.StatusCodes.UNAUTHORIZED,r)}}class n extends t.BaseHttpError{constructor(r){super(e.StatusCodes.NOT_FOUND,r)}}class c extends t.BaseHttpError{constructor(r){super(e.StatusCodes.INTERNAL_SERVER_ERROR,r)}}class d extends t.BaseHttpError{constructor(r){super(e.StatusCodes.SERVICE_UNAVAILABLE,r)}}exports.HttpStatusCodes=e.StatusCodes;exports.BadRequestError=E;exports.InternalServerError=c;exports.MoonflowerError=s;exports.NotFoundError=n;exports.ServiceUnavailableError=d;exports.UnauthorizedError=u;exports.ValidationError=a;
|
|
2
2
|
//# sourceMappingURL=UserFacingErrors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserFacingErrors.cjs","sources":["../../src/errors/UserFacingErrors.ts"],"sourcesContent":["import { BaseHttpError } from './BaseHttpError'\nimport { StatusCodes } from './StatusCodes'\n\nexport class ValidationError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class BadRequestError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class UnauthorizedError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.UNAUTHORIZED, message)\n\t}\n}\n\n// To be used later\n// export const errorNameToStatusCode = (name: string): number => {\n// \tswitch (name) {\n// \t\tcase 'ValidationError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'BadRequestError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'UnauthorizedError':\n// \t\t\treturn StatusCodes.UNAUTHORIZED\n// \t}\n// \treturn StatusCodes.INTERNAL_SERVER_ERROR\n// }\n\n// import { getReasonPhrase } from 'http-status-codes'\n// export const errorNameToReason = (name: string): string => {\n// \treturn getReasonPhrase(errorNameToStatusCode(name) || 500)\n// }\n"],"names":["
|
|
1
|
+
{"version":3,"file":"UserFacingErrors.cjs","sources":["../../src/errors/UserFacingErrors.ts"],"sourcesContent":["import { BaseHttpError } from './BaseHttpError'\nimport { StatusCodes } from './StatusCodes'\n\nexport const MoonflowerError = BaseHttpError\nexport { StatusCodes as HttpStatusCodes }\n\nexport class ValidationError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class BadRequestError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class UnauthorizedError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.UNAUTHORIZED, message)\n\t}\n}\n\nexport class NotFoundError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.NOT_FOUND, message)\n\t}\n}\n\nexport class InternalServerError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.INTERNAL_SERVER_ERROR, message)\n\t}\n}\n\nexport class ServiceUnavailableError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.SERVICE_UNAVAILABLE, message)\n\t}\n}\n\n// To be used later\n// export const errorNameToStatusCode = (name: string): number => {\n// \tswitch (name) {\n// \t\tcase 'ValidationError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'BadRequestError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'UnauthorizedError':\n// \t\t\treturn StatusCodes.UNAUTHORIZED\n// \t}\n// \treturn StatusCodes.INTERNAL_SERVER_ERROR\n// }\n\n// import { getReasonPhrase } from 'http-status-codes'\n// export const errorNameToReason = (name: string): string => {\n// \treturn getReasonPhrase(errorNameToStatusCode(name) || 500)\n// }\n"],"names":["MoonflowerError","BaseHttpError","ValidationError","message","StatusCodes","BadRequestError","UnauthorizedError","NotFoundError","InternalServerError","ServiceUnavailableError"],"mappings":"sJAGaA,EAAkBC,EAAAA,cAGxB,MAAMC,UAAwBD,EAAAA,aAAc,CAClD,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,YAAaD,CAAO,CAAA,CAExC,CAEO,MAAME,UAAwBJ,EAAAA,aAAc,CAClD,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,YAAaD,CAAO,CAAA,CAExC,CAEO,MAAMG,UAA0BL,EAAAA,aAAc,CACpD,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,aAAcD,CAAO,CAAA,CAEzC,CAEO,MAAMI,UAAsBN,EAAAA,aAAc,CAChD,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,UAAWD,CAAO,CAAA,CAEtC,CAEO,MAAMK,UAA4BP,EAAAA,aAAc,CACtD,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,sBAAuBD,CAAO,CAAA,CAElD,CAEO,MAAMM,UAAgCR,EAAAA,aAAc,CAC1D,YAAYE,EAAiB,CACtB,MAAAC,EAAAA,YAAY,oBAAqBD,CAAO,CAAA,CAEhD"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseHttpError } from './BaseHttpError';
|
|
2
|
+
import { StatusCodes } from './StatusCodes';
|
|
2
3
|
|
|
4
|
+
export declare const MoonflowerError: typeof BaseHttpError;
|
|
5
|
+
export { StatusCodes as HttpStatusCodes };
|
|
3
6
|
export declare class ValidationError extends BaseHttpError {
|
|
4
7
|
constructor(message: string);
|
|
5
8
|
}
|
|
@@ -9,4 +12,13 @@ export declare class BadRequestError extends BaseHttpError {
|
|
|
9
12
|
export declare class UnauthorizedError extends BaseHttpError {
|
|
10
13
|
constructor(message: string);
|
|
11
14
|
}
|
|
15
|
+
export declare class NotFoundError extends BaseHttpError {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class InternalServerError extends BaseHttpError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class ServiceUnavailableError extends BaseHttpError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
12
24
|
//# sourceMappingURL=UserFacingErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserFacingErrors.d.ts","sourceRoot":"","sources":["../../src/errors/UserFacingErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"UserFacingErrors.d.ts","sourceRoot":"","sources":["../../src/errors/UserFacingErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,eAAO,MAAM,eAAe,sBAAgB,CAAA;AAC5C,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,CAAA;AAEzC,qBAAa,eAAgB,SAAQ,aAAa;gBACrC,OAAO,EAAE,MAAM;CAG3B;AAED,qBAAa,eAAgB,SAAQ,aAAa;gBACrC,OAAO,EAAE,MAAM;CAG3B;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACvC,OAAO,EAAE,MAAM;CAG3B;AAED,qBAAa,aAAc,SAAQ,aAAa;gBACnC,OAAO,EAAE,MAAM;CAG3B;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACzC,OAAO,EAAE,MAAM;CAG3B;AAED,qBAAa,uBAAwB,SAAQ,aAAa;gBAC7C,OAAO,EAAE,MAAM;CAG3B"}
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
import { BaseHttpError as s } from "./BaseHttpError.mjs";
|
|
2
|
-
import { StatusCodes as
|
|
3
|
-
|
|
2
|
+
import { StatusCodes as o } from "./StatusCodes.mjs";
|
|
3
|
+
const n = s;
|
|
4
|
+
class E extends s {
|
|
5
|
+
constructor(r) {
|
|
6
|
+
super(o.BAD_REQUEST, r);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
class a extends s {
|
|
4
10
|
constructor(r) {
|
|
5
|
-
super(
|
|
11
|
+
super(o.BAD_REQUEST, r);
|
|
6
12
|
}
|
|
7
13
|
}
|
|
8
14
|
class u extends s {
|
|
9
15
|
constructor(r) {
|
|
10
|
-
super(
|
|
16
|
+
super(o.UNAUTHORIZED, r);
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
|
-
class
|
|
19
|
+
class d extends s {
|
|
20
|
+
constructor(r) {
|
|
21
|
+
super(o.NOT_FOUND, r);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class l extends s {
|
|
25
|
+
constructor(r) {
|
|
26
|
+
super(o.INTERNAL_SERVER_ERROR, r);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class p extends s {
|
|
14
30
|
constructor(r) {
|
|
15
|
-
super(
|
|
31
|
+
super(o.SERVICE_UNAVAILABLE, r);
|
|
16
32
|
}
|
|
17
33
|
}
|
|
18
34
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
a as BadRequestError,
|
|
36
|
+
o as HttpStatusCodes,
|
|
37
|
+
l as InternalServerError,
|
|
38
|
+
n as MoonflowerError,
|
|
39
|
+
d as NotFoundError,
|
|
40
|
+
p as ServiceUnavailableError,
|
|
41
|
+
u as UnauthorizedError,
|
|
42
|
+
E as ValidationError
|
|
22
43
|
};
|
|
23
44
|
//# sourceMappingURL=UserFacingErrors.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserFacingErrors.mjs","sources":["../../src/errors/UserFacingErrors.ts"],"sourcesContent":["import { BaseHttpError } from './BaseHttpError'\nimport { StatusCodes } from './StatusCodes'\n\nexport class ValidationError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class BadRequestError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class UnauthorizedError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.UNAUTHORIZED, message)\n\t}\n}\n\n// To be used later\n// export const errorNameToStatusCode = (name: string): number => {\n// \tswitch (name) {\n// \t\tcase 'ValidationError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'BadRequestError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'UnauthorizedError':\n// \t\t\treturn StatusCodes.UNAUTHORIZED\n// \t}\n// \treturn StatusCodes.INTERNAL_SERVER_ERROR\n// }\n\n// import { getReasonPhrase } from 'http-status-codes'\n// export const errorNameToReason = (name: string): string => {\n// \treturn getReasonPhrase(errorNameToStatusCode(name) || 500)\n// }\n"],"names":["
|
|
1
|
+
{"version":3,"file":"UserFacingErrors.mjs","sources":["../../src/errors/UserFacingErrors.ts"],"sourcesContent":["import { BaseHttpError } from './BaseHttpError'\nimport { StatusCodes } from './StatusCodes'\n\nexport const MoonflowerError = BaseHttpError\nexport { StatusCodes as HttpStatusCodes }\n\nexport class ValidationError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class BadRequestError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.BAD_REQUEST, message)\n\t}\n}\n\nexport class UnauthorizedError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.UNAUTHORIZED, message)\n\t}\n}\n\nexport class NotFoundError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.NOT_FOUND, message)\n\t}\n}\n\nexport class InternalServerError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.INTERNAL_SERVER_ERROR, message)\n\t}\n}\n\nexport class ServiceUnavailableError extends BaseHttpError {\n\tconstructor(message: string) {\n\t\tsuper(StatusCodes.SERVICE_UNAVAILABLE, message)\n\t}\n}\n\n// To be used later\n// export const errorNameToStatusCode = (name: string): number => {\n// \tswitch (name) {\n// \t\tcase 'ValidationError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'BadRequestError':\n// \t\t\treturn StatusCodes.BAD_REQUEST\n// \t\tcase 'UnauthorizedError':\n// \t\t\treturn StatusCodes.UNAUTHORIZED\n// \t}\n// \treturn StatusCodes.INTERNAL_SERVER_ERROR\n// }\n\n// import { getReasonPhrase } from 'http-status-codes'\n// export const errorNameToReason = (name: string): string => {\n// \treturn getReasonPhrase(errorNameToStatusCode(name) || 500)\n// }\n"],"names":["MoonflowerError","BaseHttpError","ValidationError","message","StatusCodes","BadRequestError","UnauthorizedError","NotFoundError","InternalServerError","ServiceUnavailableError"],"mappings":";;AAGO,MAAMA,IAAkBC;AAGxB,MAAMC,UAAwBD,EAAc;AAAA,EAClD,YAAYE,GAAiB;AACtB,UAAAC,EAAY,aAAaD,CAAO;AAAA,EAAA;AAExC;AAEO,MAAME,UAAwBJ,EAAc;AAAA,EAClD,YAAYE,GAAiB;AACtB,UAAAC,EAAY,aAAaD,CAAO;AAAA,EAAA;AAExC;AAEO,MAAMG,UAA0BL,EAAc;AAAA,EACpD,YAAYE,GAAiB;AACtB,UAAAC,EAAY,cAAcD,CAAO;AAAA,EAAA;AAEzC;AAEO,MAAMI,UAAsBN,EAAc;AAAA,EAChD,YAAYE,GAAiB;AACtB,UAAAC,EAAY,WAAWD,CAAO;AAAA,EAAA;AAEtC;AAEO,MAAMK,UAA4BP,EAAc;AAAA,EACtD,YAAYE,GAAiB;AACtB,UAAAC,EAAY,uBAAuBD,CAAO;AAAA,EAAA;AAElD;AAEO,MAAMM,UAAgCR,EAAc;AAAA,EAC1D,YAAYE,GAAiB;AACtB,UAAAC,EAAY,qBAAqBD,CAAO;AAAA,EAAA;AAEhD;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./errors/HttpErrorHandler.cjs"),r=require("./errors/UserFacingErrors.cjs"),u=require("./hooks/authentication/useAuth.cjs"),i=require("./hooks/authentication/useOptionalAuth.cjs"),n=require("./hooks/useApiEndpoint.cjs"),l=require("./hooks/useApiHeader/useApiHeader.cjs"),d=require("./hooks/useCookieParams.cjs"),o=require("./hooks/useExposeApiModel.cjs"),t=require("./hooks/useHeaderParams.cjs"),p=require("./hooks/usePathParams.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./errors/HttpErrorHandler.cjs"),r=require("./errors/UserFacingErrors.cjs"),u=require("./hooks/authentication/useAuth.cjs"),i=require("./hooks/authentication/useOptionalAuth.cjs"),n=require("./hooks/useApiEndpoint.cjs"),l=require("./hooks/useApiHeader/useApiHeader.cjs"),d=require("./hooks/useCookieParams.cjs"),o=require("./hooks/useExposeApiModel.cjs"),t=require("./hooks/useHeaderParams.cjs"),p=require("./hooks/usePathParams.cjs"),E=require("./hooks/useQueryParams.cjs"),q=require("./hooks/useRequestBody.cjs"),m=require("./hooks/useRequestRawBody.cjs"),h=require("./hooks/useReturnValue.cjs"),c=require("./openapi/initOpenApiEngine.cjs"),V=require("./router/Router.cjs"),e=require("./validators/BuiltInValidators.cjs"),a=require("./validators/ParamWrappers.cjs"),P=require("./errors/StatusCodes.cjs");exports.HttpErrorHandler=s.HttpErrorHandler;exports.BadRequestError=r.BadRequestError;exports.InternalServerError=r.InternalServerError;exports.MoonflowerError=r.MoonflowerError;exports.NotFoundError=r.NotFoundError;exports.ServiceUnavailableError=r.ServiceUnavailableError;exports.UnauthorizedError=r.UnauthorizedError;exports.ValidationError=r.ValidationError;exports.useAuth=u.useAuth;exports.useOptionalAuth=i.useOptionalAuth;exports.useApiEndpoint=n.useApiEndpoint;exports.useApiHeader=l.useApiHeader;exports.useCookieParams=d.useCookieParams;exports.useExposeApiModel=o.useExposeApiModel;exports.useExposeNamedApiModels=o.useExposeNamedApiModels;exports.useHeaderParams=t.useHeaderParams;exports.useRequestHeaders=t.useRequestHeaders;exports.usePathParams=p.usePathParams;exports.useQueryParams=E.useQueryParams;exports.useRequestBody=q.useRequestBody;exports.useRequestRawBody=m.useRequestRawBody;exports.useReturnValue=h.useReturnValue;exports.initOpenApiEngine=c.initOpenApiEngine;exports.Router=V.Router;exports.BigIntValidator=e.BigIntValidator;exports.BooleanValidator=e.BooleanValidator;exports.EmailValidator=e.EmailValidator;exports.NonEmptyStringValidator=e.NonEmptyStringValidator;exports.NullableBigIntValidator=e.NullableBigIntValidator;exports.NullableBooleanValidator=e.NullableBooleanValidator;exports.NullableNumberValidator=e.NullableNumberValidator;exports.NullableStringValidator=e.NullableStringValidator;exports.NumberValidator=e.NumberValidator;exports.StringValidator=e.StringValidator;exports.OptionalParam=a.OptionalParam;exports.PathParam=a.PathParam;exports.RequiredParam=a.RequiredParam;exports.HttpStatusCodes=P.StatusCodes;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
|
-
import { HttpErrorHandler as
|
|
2
|
-
import { BadRequestError as t,
|
|
3
|
-
import { useAuth as
|
|
4
|
-
import { useOptionalAuth as
|
|
5
|
-
import { useApiEndpoint as
|
|
6
|
-
import { useApiHeader as
|
|
7
|
-
import { useCookieParams as
|
|
8
|
-
import { useExposeApiModel as
|
|
9
|
-
import { useHeaderParams as
|
|
10
|
-
import { usePathParams as
|
|
11
|
-
import { useQueryParams as
|
|
12
|
-
import { useRequestBody as
|
|
13
|
-
import { useRequestRawBody as
|
|
14
|
-
import { useReturnValue as
|
|
1
|
+
import { HttpErrorHandler as e } from "./errors/HttpErrorHandler.mjs";
|
|
2
|
+
import { BadRequestError as t, InternalServerError as l, MoonflowerError as u, NotFoundError as i, ServiceUnavailableError as p, UnauthorizedError as m, ValidationError as s } from "./errors/UserFacingErrors.mjs";
|
|
3
|
+
import { useAuth as n } from "./hooks/authentication/useAuth.mjs";
|
|
4
|
+
import { useOptionalAuth as f } from "./hooks/authentication/useOptionalAuth.mjs";
|
|
5
|
+
import { useApiEndpoint as V } from "./hooks/useApiEndpoint.mjs";
|
|
6
|
+
import { useApiHeader as P } from "./hooks/useApiHeader/useApiHeader.mjs";
|
|
7
|
+
import { useCookieParams as b } from "./hooks/useCookieParams.mjs";
|
|
8
|
+
import { useExposeApiModel as B, useExposeNamedApiModels as S } from "./hooks/useExposeApiModel.mjs";
|
|
9
|
+
import { useHeaderParams as H, useRequestHeaders as h } from "./hooks/useHeaderParams.mjs";
|
|
10
|
+
import { usePathParams as y } from "./hooks/usePathParams.mjs";
|
|
11
|
+
import { useQueryParams as C } from "./hooks/useQueryParams.mjs";
|
|
12
|
+
import { useRequestBody as M } from "./hooks/useRequestBody.mjs";
|
|
13
|
+
import { useRequestRawBody as w } from "./hooks/useRequestRawBody.mjs";
|
|
14
|
+
import { useReturnValue as c } from "./hooks/useReturnValue.mjs";
|
|
15
15
|
import { initOpenApiEngine as z } from "./openapi/initOpenApiEngine.mjs";
|
|
16
16
|
import { Router as Q } from "./router/Router.mjs";
|
|
17
|
-
import { BigIntValidator as
|
|
18
|
-
import { OptionalParam as
|
|
17
|
+
import { BigIntValidator as D, BooleanValidator as G, EmailValidator as J, NonEmptyStringValidator as K, NullableBigIntValidator as L, NullableBooleanValidator as T, NullableNumberValidator as W, NullableStringValidator as X, NumberValidator as Y, StringValidator as Z } from "./validators/BuiltInValidators.mjs";
|
|
18
|
+
import { OptionalParam as $, PathParam as rr, RequiredParam as or } from "./validators/ParamWrappers.mjs";
|
|
19
|
+
import { StatusCodes as ar } from "./errors/StatusCodes.mjs";
|
|
19
20
|
export {
|
|
20
21
|
t as BadRequestError,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
L as
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
D as BigIntValidator,
|
|
23
|
+
G as BooleanValidator,
|
|
24
|
+
J as EmailValidator,
|
|
25
|
+
e as HttpErrorHandler,
|
|
26
|
+
ar as HttpStatusCodes,
|
|
27
|
+
l as InternalServerError,
|
|
28
|
+
u as MoonflowerError,
|
|
29
|
+
K as NonEmptyStringValidator,
|
|
30
|
+
i as NotFoundError,
|
|
31
|
+
L as NullableBigIntValidator,
|
|
32
|
+
T as NullableBooleanValidator,
|
|
33
|
+
W as NullableNumberValidator,
|
|
34
|
+
X as NullableStringValidator,
|
|
35
|
+
Y as NumberValidator,
|
|
36
|
+
$ as OptionalParam,
|
|
37
|
+
rr as PathParam,
|
|
38
|
+
or as RequiredParam,
|
|
34
39
|
Q as Router,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
p as ServiceUnavailableError,
|
|
41
|
+
Z as StringValidator,
|
|
42
|
+
m as UnauthorizedError,
|
|
43
|
+
s as ValidationError,
|
|
38
44
|
z as initOpenApiEngine,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
V as useApiEndpoint,
|
|
46
|
+
P as useApiHeader,
|
|
47
|
+
n as useAuth,
|
|
48
|
+
b as useCookieParams,
|
|
49
|
+
B as useExposeApiModel,
|
|
50
|
+
S as useExposeNamedApiModels,
|
|
51
|
+
H as useHeaderParams,
|
|
52
|
+
f as useOptionalAuth,
|
|
53
|
+
y as usePathParams,
|
|
54
|
+
C as useQueryParams,
|
|
55
|
+
M as useRequestBody,
|
|
56
|
+
h as useRequestHeaders,
|
|
57
|
+
w as useRequestRawBody,
|
|
58
|
+
c as useReturnValue
|
|
53
59
|
};
|
|
54
60
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BaseHttpError } from './BaseHttpError'
|
|
2
2
|
import { StatusCodes } from './StatusCodes'
|
|
3
3
|
|
|
4
|
+
export const MoonflowerError = BaseHttpError
|
|
5
|
+
export { StatusCodes as HttpStatusCodes }
|
|
6
|
+
|
|
4
7
|
export class ValidationError extends BaseHttpError {
|
|
5
8
|
constructor(message: string) {
|
|
6
9
|
super(StatusCodes.BAD_REQUEST, message)
|
|
@@ -19,6 +22,24 @@ export class UnauthorizedError extends BaseHttpError {
|
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
export class NotFoundError extends BaseHttpError {
|
|
26
|
+
constructor(message: string) {
|
|
27
|
+
super(StatusCodes.NOT_FOUND, message)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class InternalServerError extends BaseHttpError {
|
|
32
|
+
constructor(message: string) {
|
|
33
|
+
super(StatusCodes.INTERNAL_SERVER_ERROR, message)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class ServiceUnavailableError extends BaseHttpError {
|
|
38
|
+
constructor(message: string) {
|
|
39
|
+
super(StatusCodes.SERVICE_UNAVAILABLE, message)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
22
43
|
// To be used later
|
|
23
44
|
// export const errorNameToStatusCode = (name: string): number => {
|
|
24
45
|
// switch (name) {
|