-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove use of
std/http/http_errors
(#638)
- Loading branch information
Showing
11 changed files
with
52 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
// Copyright 2023 the Deno authors. All rights reserved. MIT license. | ||
import type { Handlers } from "$fresh/server.ts"; | ||
import { getItem } from "@/utils/db.ts"; | ||
import { Status } from "std/http/http_status.ts"; | ||
import { createHttpError } from "std/http/http_errors.ts"; | ||
|
||
export const handler: Handlers = { | ||
async GET(_req, ctx) { | ||
const item = await getItem(ctx.params.id); | ||
if (item === null) throw createHttpError(Status.NotFound, "Item not found"); | ||
if (item === null) throw new Deno.errors.NotFound("Item not found"); | ||
return Response.json(item); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
// Copyright 2023 the Deno authors. All rights reserved. MIT license. | ||
import { type Handlers, Status } from "$fresh/server.ts"; | ||
import type { Handlers } from "$fresh/server.ts"; | ||
import { getUser } from "@/utils/db.ts"; | ||
import { createHttpError } from "std/http/http_errors.ts"; | ||
|
||
export const handler: Handlers = { | ||
async GET(_req, ctx) { | ||
const user = await getUser(ctx.params.login); | ||
if (user === null) throw createHttpError(Status.NotFound, "User not found"); | ||
if (user === null) throw new Deno.errors.NotFound("User not found"); | ||
return Response.json(user); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters