@gravito/core 1.0.0-beta.6 → 1.0.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/dist/compat.d.cts +1 -0
- package/dist/compat.d.ts +1 -0
- package/dist/index.cjs +9 -8
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -8
- package/package.json +1 -1
package/dist/compat.d.cts
CHANGED
|
@@ -297,6 +297,7 @@ type GravitoHandler<V extends GravitoVariables = GravitoVariables> = (ctx: Gravi
|
|
|
297
297
|
* const logger: GravitoMiddleware = async (ctx, next) => {
|
|
298
298
|
* console.log(`${ctx.req.method} ${ctx.req.path}`)
|
|
299
299
|
* await next()
|
|
300
|
+
* return undefined
|
|
300
301
|
* }
|
|
301
302
|
* ```
|
|
302
303
|
*/
|
package/dist/compat.d.ts
CHANGED
|
@@ -297,6 +297,7 @@ type GravitoHandler<V extends GravitoVariables = GravitoVariables> = (ctx: Gravi
|
|
|
297
297
|
* const logger: GravitoMiddleware = async (ctx, next) => {
|
|
298
298
|
* console.log(`${ctx.req.method} ${ctx.req.path}`)
|
|
299
299
|
* await next()
|
|
300
|
+
* return undefined
|
|
300
301
|
* }
|
|
301
302
|
* ```
|
|
302
303
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -112,7 +112,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
112
112
|
// package.json
|
|
113
113
|
var package_default = {
|
|
114
114
|
name: "@gravito/core",
|
|
115
|
-
version: "1.0.0
|
|
115
|
+
version: "1.0.0",
|
|
116
116
|
description: "",
|
|
117
117
|
module: "./dist/index.js",
|
|
118
118
|
main: "./dist/index.cjs",
|
|
@@ -183,6 +183,7 @@ var PhotonRequestWrapper = class {
|
|
|
183
183
|
constructor(photonCtx) {
|
|
184
184
|
this.photonCtx = photonCtx;
|
|
185
185
|
}
|
|
186
|
+
_cachedJson = null;
|
|
186
187
|
get url() {
|
|
187
188
|
return this.photonCtx.req.url;
|
|
188
189
|
}
|
|
@@ -211,7 +212,13 @@ var PhotonRequestWrapper = class {
|
|
|
211
212
|
return this.photonCtx.req.header();
|
|
212
213
|
}
|
|
213
214
|
async json() {
|
|
214
|
-
|
|
215
|
+
const ctx = this.photonCtx;
|
|
216
|
+
if (ctx._cachedJsonBody !== void 0) {
|
|
217
|
+
return ctx._cachedJsonBody;
|
|
218
|
+
}
|
|
219
|
+
const body = await this.photonCtx.req.json();
|
|
220
|
+
ctx._cachedJsonBody = body;
|
|
221
|
+
return body;
|
|
215
222
|
}
|
|
216
223
|
async text() {
|
|
217
224
|
return this.photonCtx.req.text();
|
|
@@ -3087,12 +3094,6 @@ var Router = class {
|
|
|
3087
3094
|
}
|
|
3088
3095
|
handlers.push(resolvedHandler);
|
|
3089
3096
|
if (options.domain) {
|
|
3090
|
-
const _wrappedHandler = async (c) => {
|
|
3091
|
-
if (c.req.header("host") !== options.domain) {
|
|
3092
|
-
return new Response("Not Found", { status: 404 });
|
|
3093
|
-
}
|
|
3094
|
-
return void 0;
|
|
3095
|
-
};
|
|
3096
3097
|
const domainCheck = async (c, next) => {
|
|
3097
3098
|
if (c.req.header("host") !== options.domain) {
|
|
3098
3099
|
return c.text("Not Found", 404);
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@gravito/core",
|
|
11
|
-
version: "1.0.0
|
|
11
|
+
version: "1.0.0",
|
|
12
12
|
description: "",
|
|
13
13
|
module: "./dist/index.js",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
@@ -79,6 +79,7 @@ var PhotonRequestWrapper = class {
|
|
|
79
79
|
constructor(photonCtx) {
|
|
80
80
|
this.photonCtx = photonCtx;
|
|
81
81
|
}
|
|
82
|
+
_cachedJson = null;
|
|
82
83
|
get url() {
|
|
83
84
|
return this.photonCtx.req.url;
|
|
84
85
|
}
|
|
@@ -107,7 +108,13 @@ var PhotonRequestWrapper = class {
|
|
|
107
108
|
return this.photonCtx.req.header();
|
|
108
109
|
}
|
|
109
110
|
async json() {
|
|
110
|
-
|
|
111
|
+
const ctx = this.photonCtx;
|
|
112
|
+
if (ctx._cachedJsonBody !== void 0) {
|
|
113
|
+
return ctx._cachedJsonBody;
|
|
114
|
+
}
|
|
115
|
+
const body = await this.photonCtx.req.json();
|
|
116
|
+
ctx._cachedJsonBody = body;
|
|
117
|
+
return body;
|
|
111
118
|
}
|
|
112
119
|
async text() {
|
|
113
120
|
return this.photonCtx.req.text();
|
|
@@ -2982,12 +2989,6 @@ var Router = class {
|
|
|
2982
2989
|
}
|
|
2983
2990
|
handlers.push(resolvedHandler);
|
|
2984
2991
|
if (options.domain) {
|
|
2985
|
-
const _wrappedHandler = async (c) => {
|
|
2986
|
-
if (c.req.header("host") !== options.domain) {
|
|
2987
|
-
return new Response("Not Found", { status: 404 });
|
|
2988
|
-
}
|
|
2989
|
-
return void 0;
|
|
2990
|
-
};
|
|
2991
2992
|
const domainCheck = async (c, next) => {
|
|
2992
2993
|
if (c.req.header("host") !== options.domain) {
|
|
2993
2994
|
return c.text("Not Found", 404);
|