Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Feb 2, 2024
1 parent b877071 commit 4941fed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utopia-remix/app/util/api.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TypedResponse, json } from "@remix-run/node";
import invariant from "tiny-invariant";
import { Env } from "../env.server";
import { ServerEnvironment } from "../env.server";
import { Status } from "./statusCodes.server";
import { Method, isMethod } from "./methods.server";

Expand All @@ -13,13 +13,13 @@ type EmptyResponse = Record<string, never>;
export type ApiResponse<T> = TypedResponse<T | ErrorResponse | EmptyResponse>;

const responseHeaders: HeadersInit = {
"Access-Control-Allow-Origin": Env.CORSOrigin,
"Access-Control-Allow-Origin": ServerEnvironment.CORSOrigin,
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Headers": "content-type, origin, cookie",
"Access-Control-Allow-Methods": "GET,POST,PUT,DELETE,OPTIONS",
};

export async function handleOptions() {
export async function handleOptions(): Promise<TypedResponse<EmptyResponse>> {
return json({}, { headers: responseHeaders });
}

Expand All @@ -28,7 +28,7 @@ export function handle(
handlers: {
[method in Method]?: (request: Request) => Promise<unknown>;
},
) {
): Promise<unknown> {
const invalidMethod = new ApiError(
"invalid method",
Status.METHOD_NOT_ALLOWED,
Expand Down

0 comments on commit 4941fed

Please sign in to comment.