0.1.0•Updated 7 months ago
import { InfinityResponse } from "./infinity_response.ts";
import { Context, RouterContext } from "jsr:@oak/oak@^17.1.4";
import { ContextState } from "../host/context_state.ts";
export class InfinityRequest {
readonly res: InfinityResponse
readonly ctx: RouterContext<string>
body: Record<string, any> = {}
// deno-lint-ignore ban-types
constructor(ctx: RouterContext<string, {}, Context<ContextState>>) {
this.ctx = ctx;
this.res = new InfinityResponse(this);
}
get params() {
return this.ctx.params as Record<string, any>;
}
get query() {
return this.ctx.request.url.searchParams;
}
get id() {
return this.ctx.state.id as string;
}
async init() {
try {
this.body = await this.ctx.request.body.json()
} catch(_) { /**/ }
}
}