Skip to content

Commit

Permalink
Merge pull request #882 from BitGo/DX-703
Browse files Browse the repository at this point in the history
feat: add type error if path doesn't start with /
  • Loading branch information
andrew-scott-fischer authored Aug 23, 2024
2 parents 3a9a0f4 + a27e388 commit 64dc7af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/io-ts-http/src/httpRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export const Method = t.keyof({

export type Method = t.TypeOf<typeof Method>;

export type PathString = `/${string}`;

export type HttpRoute<M extends Method = Method> = {
readonly path: string;
readonly path: PathString;
readonly method: Uppercase<M>;
readonly request: HttpRequestCodec<any>;
readonly response: HttpResponse;
Expand Down
2 changes: 1 addition & 1 deletion packages/superagent-wrapper/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const requestForRoute =
let path = route.path;
for (const key in reqProps.params) {
if (reqProps.params.hasOwnProperty(key)) {
path = path.replace(`{${key}}`, reqProps.params[key]);
path = path.replace(`{${key}}`, reqProps.params[key]) as h.PathString;
}
}

Expand Down

0 comments on commit 64dc7af

Please sign in to comment.