@kiyasov/platform-hono 1.3.8 → 1.3.9
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 +4 -4
- package/dist/cjs/src/adapters/hono-adapter.js +40 -8
- 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 +4 -4
- package/dist/esm/src/adapters/hono-adapter.js +40 -8
- 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 +55 -8
package/package.json
CHANGED
|
@@ -139,8 +139,19 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
139
139
|
ctx.set("body", body);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
public status(
|
|
143
|
-
ctx
|
|
142
|
+
public async status(
|
|
143
|
+
ctx: Context | (() => Promise<Context>),
|
|
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
|
+
}
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
public async end() {
|
|
@@ -151,8 +162,20 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
151
162
|
throw new Error("Method not implemented.");
|
|
152
163
|
}
|
|
153
164
|
|
|
154
|
-
public redirect(
|
|
155
|
-
ctx
|
|
165
|
+
public async redirect(
|
|
166
|
+
ctx: Context | (() => Promise<Context>),
|
|
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
|
+
}
|
|
156
179
|
}
|
|
157
180
|
|
|
158
181
|
public setErrorHandler(handler: ErrorHandler) {
|
|
@@ -186,12 +209,36 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
186
209
|
return ctx.req.header(name);
|
|
187
210
|
}
|
|
188
211
|
|
|
189
|
-
public setHeader(
|
|
190
|
-
ctx
|
|
212
|
+
public async setHeader(
|
|
213
|
+
ctx: Context | (() => Promise<Context>),
|
|
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
|
+
}
|
|
191
226
|
}
|
|
192
227
|
|
|
193
|
-
public appendHeader?(
|
|
194
|
-
ctx
|
|
228
|
+
public async appendHeader?(
|
|
229
|
+
ctx: Context | (() => Promise<Context>),
|
|
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
|
+
}
|
|
195
242
|
}
|
|
196
243
|
|
|
197
244
|
public getRequestHostname(ctx: Context): string {
|