@chanzor/nest-leaf 0.0.1 → 0.0.2
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.js +29 -29
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
import { ForbiddenException as i } from "@nestjs/common";
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
return
|
|
2
|
+
function d(r) {
|
|
3
|
+
let t;
|
|
4
|
+
return r.length > 0 && (t = (e, n) => {
|
|
5
5
|
if (e === void 0) {
|
|
6
|
-
|
|
6
|
+
n(null, !0);
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
if (typeof e != "string")
|
|
10
10
|
throw new i("Not allowed by CORS");
|
|
11
|
-
for (const o of
|
|
11
|
+
for (const o of r) {
|
|
12
12
|
if (o.includes("*") && new RegExp(`^${o.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`).test(e)) {
|
|
13
|
-
|
|
13
|
+
n(null, !0);
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
if (o === e) {
|
|
17
|
-
|
|
17
|
+
n(null, !0);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
throw new i("Not allowed by CORS");
|
|
22
|
-
}), { origin:
|
|
22
|
+
}), { origin: t, methods: ["GET"], credentials: !0, allowedHeaders: ["Content-Type", "x-access-token"] };
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
switch (
|
|
24
|
+
function f(r) {
|
|
25
|
+
switch (r) {
|
|
26
26
|
case "dev":
|
|
27
27
|
return !1;
|
|
28
28
|
case "prod":
|
|
29
29
|
return !0;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function c(
|
|
33
|
-
const e =
|
|
32
|
+
function c(r, t) {
|
|
33
|
+
const e = r.get(t);
|
|
34
34
|
if (typeof e != "string") return;
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
35
|
+
const n = e.trim();
|
|
36
|
+
if (n.length)
|
|
37
|
+
return n;
|
|
38
38
|
}
|
|
39
|
-
function l(
|
|
40
|
-
const e =
|
|
39
|
+
function l(r, t) {
|
|
40
|
+
const e = r.get(t);
|
|
41
41
|
if (typeof e == "string")
|
|
42
|
-
return e.split(",").map((
|
|
42
|
+
return e.split(",").map((n) => n.trim());
|
|
43
43
|
}
|
|
44
|
-
function p(
|
|
45
|
-
switch (
|
|
44
|
+
function p(r, t) {
|
|
45
|
+
switch (r.get(t)) {
|
|
46
46
|
case "dev":
|
|
47
47
|
return "dev";
|
|
48
48
|
case "prod":
|
|
49
49
|
return "prod";
|
|
50
50
|
default:
|
|
51
|
-
throw new Error(`${
|
|
51
|
+
throw new Error(`${t} is invalid, must be 'dev' or 'prod'`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
function a(
|
|
55
|
-
const e =
|
|
54
|
+
function a(r, t) {
|
|
55
|
+
const e = r.get(t);
|
|
56
56
|
if (typeof e == "number") return e;
|
|
57
57
|
if (typeof e == "string") {
|
|
58
|
-
const
|
|
59
|
-
if (!isNaN(
|
|
60
|
-
return
|
|
58
|
+
const n = parseInt(e);
|
|
59
|
+
if (!isNaN(n))
|
|
60
|
+
return n;
|
|
61
61
|
}
|
|
62
|
-
throw new Error(`${
|
|
62
|
+
throw new Error(`${t} is invalid, must be a number integer`);
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
d as buildConfigCorsOption,
|
|
66
|
+
f as isConfigProd,
|
|
67
67
|
c as optionalEnvAccessToken,
|
|
68
68
|
l as optionalEnvAllowedCrossOrigin,
|
|
69
69
|
p as requireEnvMode,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@nestjs/common")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n["@chanzor/nest-leaf"]={},n.NestjsCommon))})(this,function(n,i){"use strict";function
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@nestjs/common")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n["@chanzor/nest-leaf"]={},n.NestjsCommon))})(this,function(n,i){"use strict";function u(o){let t;return o.length>0&&(t=(e,r)=>{if(e===void 0){r(null,!0);return}if(typeof e!="string")throw new i.ForbiddenException("Not allowed by CORS");for(const s of o){if(s.includes("*")&&new RegExp(`^${s.replace(/\./g,"\\.").replace(/\*/g,".*")}$`).test(e)){r(null,!0);return}if(s===e){r(null,!0);return}}throw new i.ForbiddenException("Not allowed by CORS")}),{origin:t,methods:["GET"],credentials:!0,allowedHeaders:["Content-Type","x-access-token"]}}function d(o){switch(o){case"dev":return!1;case"prod":return!0}}function f(o,t){const e=o.get(t);if(typeof e!="string")return;const r=e.trim();if(r.length)return r}function c(o,t){const e=o.get(t);if(typeof e=="string")return e.split(",").map(r=>r.trim())}function l(o,t){switch(o.get(t)){case"dev":return"dev";case"prod":return"prod";default:throw new Error(`${t} is invalid, must be 'dev' or 'prod'`)}}function p(o,t){const e=o.get(t);if(typeof e=="number")return e;if(typeof e=="string"){const r=parseInt(e);if(!isNaN(r))return r}throw new Error(`${t} is invalid, must be a number integer`)}n.buildConfigCorsOption=u,n.isConfigProd=d,n.optionalEnvAccessToken=f,n.optionalEnvAllowedCrossOrigin=c,n.requireEnvMode=l,n.requireEnvPort=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|