release: WRNexusJS 0.8.0
This commit is contained in:
@@ -8,6 +8,11 @@ export const GET = async () => {
|
||||
};
|
||||
|
||||
export const POST = async (ctx: Context) => {
|
||||
const body = await ctx.req.json();
|
||||
const body = await ctx.req.json().catch(() => undefined);
|
||||
if (body === undefined)
|
||||
return Response.json(
|
||||
{ error: "Request body must be valid JSON." },
|
||||
{ status: 400, headers: { "cache-control": "no-store" } },
|
||||
);
|
||||
return Response.json({ received: body });
|
||||
};
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { createGraphqlHandler } from "@wrnexus/graphql";
|
||||
|
||||
const graphql = createGraphqlHandler({
|
||||
maxDepth: 8,
|
||||
maxAliases: 20,
|
||||
allowIntrospection: false,
|
||||
async execute(request) {
|
||||
return { data: { example: request.operationName ?? "anonymous" } };
|
||||
},
|
||||
});
|
||||
|
||||
export function POST(ctx: { req: Request }): Promise<Response> {
|
||||
return graphql(ctx.req);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineEndpoint } from "@wrnexus/core";
|
||||
import { CreateUserSchema } from "../schemas/create-user.ts";
|
||||
|
||||
/** Schema-derived request and response types are emitted into wrnexus.generated.d.ts. */
|
||||
export const POST = defineEndpoint({
|
||||
input: CreateUserSchema,
|
||||
output: CreateUserSchema,
|
||||
description: "Validate and echo a typed user payload.",
|
||||
handler(input) {
|
||||
return input;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
export const webhook = {
|
||||
event: "payment.completed",
|
||||
summary: "Payment completed",
|
||||
description: "Sent after a payment reaches its settled state.",
|
||||
payloadSchema: "#/components/schemas/PaymentCompleted",
|
||||
signatureHeader: "x-payment-signature",
|
||||
};
|
||||
|
||||
export async function POST(): Promise<Response> {
|
||||
return Response.json({ accepted: true });
|
||||
}
|
||||
Reference in New Issue
Block a user