Skip to content

Fix EnhancePreflightFn signature #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type EnhanceElemArg = {

export type EnhanceApiFn = (
/** The parsed HTTP request */
request: EnhanceApiReq,
request: EnhanceApiReq
) => Promise<EnhanceApiRes> | EnhanceApiRes;

export type EnhanceApiFnChain = EnhanceApiFn[];
Expand All @@ -112,6 +112,6 @@ export type EnhanceElemFn = (payload: EnhanceElemArg) => EnhanceElemResult;

export type EnhancePageFn = EnhanceElemFn;

export type EnhancePreflightFn = (
payload: EnhanceApiReq,
) => Promise<Record<string, any>> | Record<string, any>;
export type EnhancePreflightFn = ({
req: EnhanceApiReq,
}) => Promise<Record<string, any>> | Record<string, any>;
7 changes: 4 additions & 3 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expectError } from "tsd";
import type {
EnhanceApiFn,
EnhanceApiFnChain,
Expand All @@ -10,8 +9,10 @@ import type {
EnhancePreflightFn,
} from ".";

import { expectError } from "tsd";

// Preflight
export const preflight: EnhancePreflightFn = function (req) {
export const preflight: EnhancePreflightFn = function ({ req }) {
const { method, path } = req;
const title = `Todos — ${path} `;
console.log(`Handling ${method} ${path}...`);
Expand Down Expand Up @@ -41,7 +42,7 @@ export const get: EnhanceApiFn = function (request) {
(invalidResponse = {
json: { foo: "bar" },
body: "",
}),
})
);

return {
Expand Down
Loading