Comparing version 0.2.1 to 0.2.2
@@ -53,2 +53,7 @@ "use strict"; | ||
await (0, import_compose.compose)([...this.middlewares, this.execute])(ctx); | ||
if (ctx.http.headers.get("Content-Type") === "text/html") { | ||
return ctx.html(); | ||
} else if (ctx.http.headers.get("Content-Type") === "text/plain") { | ||
return ctx.text(); | ||
} | ||
return ctx.json(); | ||
@@ -55,0 +60,0 @@ }; |
@@ -36,2 +36,8 @@ "use strict"; | ||
} | ||
html() { | ||
return this.http.toHtml(); | ||
} | ||
text() { | ||
return this.http.toText(); | ||
} | ||
set(key, value) { | ||
@@ -38,0 +44,0 @@ this._map || (this._map = {}); |
@@ -37,3 +37,11 @@ "use strict"; | ||
} | ||
toHtml() { | ||
this.headers.set("content-type", "text/html"); | ||
return new Response(this.body, { | ||
status: this.status ?? 200, | ||
headers: this.headers | ||
}); | ||
} | ||
toText() { | ||
this.headers.set("content-type", "text/plain"); | ||
return new Response(this.body, { | ||
@@ -40,0 +48,0 @@ status: this.status ?? 200, |
@@ -31,2 +31,7 @@ // src/app.ts | ||
await compose([...this.middlewares, this.execute])(ctx); | ||
if (ctx.http.headers.get("Content-Type") === "text/html") { | ||
return ctx.html(); | ||
} else if (ctx.http.headers.get("Content-Type") === "text/plain") { | ||
return ctx.text(); | ||
} | ||
return ctx.json(); | ||
@@ -33,0 +38,0 @@ }; |
@@ -12,4 +12,6 @@ import type { ExecutionContext, Environment } from '../types'; | ||
json(): Response; | ||
html(): Response; | ||
text(): Response; | ||
set(key: string, value: unknown): void; | ||
get(key: string): any; | ||
} |
@@ -14,2 +14,8 @@ // src/context/context.ts | ||
} | ||
html() { | ||
return this.http.toHtml(); | ||
} | ||
text() { | ||
return this.http.toText(); | ||
} | ||
set(key, value) { | ||
@@ -16,0 +22,0 @@ this._map || (this._map = {}); |
@@ -9,2 +9,3 @@ export declare class HttpContext { | ||
toJSON(): Response; | ||
toHtml(): Response; | ||
toText(): Response; | ||
@@ -11,0 +12,0 @@ set status(status: number | undefined); |
@@ -15,3 +15,11 @@ // src/context/http.ts | ||
} | ||
toHtml() { | ||
this.headers.set("content-type", "text/html"); | ||
return new Response(this.body, { | ||
status: this.status ?? 200, | ||
headers: this.headers | ||
}); | ||
} | ||
toText() { | ||
this.headers.set("content-type", "text/plain"); | ||
return new Response(this.body, { | ||
@@ -18,0 +26,0 @@ status: this.status ?? 200, |
{ | ||
"name": "edgeql", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Minghe Huang <h.minghe@gmail.com> (https://github.com/metrue)", | ||
@@ -82,2 +82,7 @@ "license": "MIT", | ||
}, | ||
"./graphiql": { | ||
"types": "./dist/esm/middleware/graphiql/index.d.ts", | ||
"import": "./dist/esm/middleware/graphiql/index.js", | ||
"require": "./dist/cjs/middleware/graphiql/index.js" | ||
}, | ||
"./utils/jwt": { | ||
@@ -108,2 +113,5 @@ "types": "./dist/esm/utils/jwt/index.d.ts", | ||
], | ||
"middleware/graphiql": [ | ||
"./dist/esm/middleware/graphiql" | ||
], | ||
"utils/jwt": [ | ||
@@ -110,0 +118,0 @@ "./dist/esm/utils/jwt/index.d.ts" |
@@ -152,3 +152,4 @@ # EdgeQL | ||
* [JWT](src/middleware/jwt) | ||
* [GraphiQL](src/middleware/graphiql) | ||
* [CORS](src/middleware/cors) | ||
* [wallclock](src/middleware/wallclock) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79931
53
2375
155