@kiyasov/platform-hono 1.3.9 → 1.3.11
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/cjs/src/adapters/hono-adapter.d.ts +2 -2
- package/dist/cjs/src/adapters/hono-adapter.js +21 -5
- package/dist/cjs/src/adapters/hono-adapter.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/adapters/hono-adapter.d.ts +2 -2
- package/dist/esm/src/adapters/hono-adapter.js +21 -5
- package/dist/esm/src/adapters/hono-adapter.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/hono-adapter.ts +8 -55
package/package.json
CHANGED
|
@@ -139,19 +139,8 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
139
139
|
ctx.set("body", body);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
public
|
|
143
|
-
ctx
|
|
144
|
-
statusCode: StatusCode
|
|
145
|
-
) {
|
|
146
|
-
if (typeof ctx === "function") {
|
|
147
|
-
ctx = await ctx();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (ctx && typeof ctx.status === "function") {
|
|
151
|
-
ctx.status(statusCode);
|
|
152
|
-
} else {
|
|
153
|
-
throw new Error("Invalid context: status method not found.");
|
|
154
|
-
}
|
|
142
|
+
public status(ctx: Context, statusCode: StatusCode) {
|
|
143
|
+
ctx.status(statusCode);
|
|
155
144
|
}
|
|
156
145
|
|
|
157
146
|
public async end() {
|
|
@@ -162,20 +151,8 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
162
151
|
throw new Error("Method not implemented.");
|
|
163
152
|
}
|
|
164
153
|
|
|
165
|
-
public
|
|
166
|
-
ctx
|
|
167
|
-
statusCode: RedirectStatusCode,
|
|
168
|
-
url: string
|
|
169
|
-
) {
|
|
170
|
-
if (typeof ctx === "function") {
|
|
171
|
-
ctx = await ctx();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (ctx && typeof ctx.redirect === "function") {
|
|
175
|
-
ctx.redirect(url, statusCode);
|
|
176
|
-
} else {
|
|
177
|
-
throw new Error("Invalid context: redirect method not found.");
|
|
178
|
-
}
|
|
154
|
+
public redirect(ctx: Context, statusCode: RedirectStatusCode, url: string) {
|
|
155
|
+
ctx.redirect(url, statusCode);
|
|
179
156
|
}
|
|
180
157
|
|
|
181
158
|
public setErrorHandler(handler: ErrorHandler) {
|
|
@@ -209,36 +186,12 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
209
186
|
return ctx.req.header(name);
|
|
210
187
|
}
|
|
211
188
|
|
|
212
|
-
public
|
|
213
|
-
ctx
|
|
214
|
-
name: string,
|
|
215
|
-
value: string
|
|
216
|
-
) {
|
|
217
|
-
if (typeof ctx === "function") {
|
|
218
|
-
ctx = await ctx();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (ctx && typeof ctx.header === "function") {
|
|
222
|
-
ctx.header(name, value);
|
|
223
|
-
} else {
|
|
224
|
-
throw new Error("Invalid context: set method not found on context.");
|
|
225
|
-
}
|
|
189
|
+
public setHeader(ctx: Context, name: string, value: string) {
|
|
190
|
+
ctx.header(name, value);
|
|
226
191
|
}
|
|
227
192
|
|
|
228
|
-
public
|
|
229
|
-
ctx
|
|
230
|
-
name: string,
|
|
231
|
-
value: string
|
|
232
|
-
) {
|
|
233
|
-
if (typeof ctx === "function") {
|
|
234
|
-
ctx = await ctx();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (ctx && typeof ctx.res.headers.append === "function") {
|
|
238
|
-
ctx.res.headers.append(name, value);
|
|
239
|
-
} else {
|
|
240
|
-
throw new Error("Invalid context: append method not found on context.");
|
|
241
|
-
}
|
|
193
|
+
public appendHeader?(ctx: Context, name: string, value: string) {
|
|
194
|
+
ctx.res.headers.append(name, value);
|
|
242
195
|
}
|
|
243
196
|
|
|
244
197
|
public getRequestHostname(ctx: Context): string {
|