Skip to content

Commit

Permalink
feat!: re-export everything from the @std/http module
Browse files Browse the repository at this point in the history
TODO: reduce dependency hell once `deno_std` is stable (ETA Aug 2024). Deprecated things will also be removed with it.

BREAKING CHANGE: `createStandardResponse` and `STATUS_CODE` are now exported from `hado/http` instead of `hado/router`
  • Loading branch information
brc-dd committed Jul 12, 2024
1 parent 1d747c2 commit fe52d32
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 111 deletions.
13 changes: 7 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@globalbrain/hado",
"version": "0.4.2",
"exports": {
"./http": "./src/http.ts",
"./router": "./src/router.ts",
"./utils": "./src/utils.ts"
},
Expand All @@ -19,13 +20,13 @@
"noUnusedParameters": true
},
"imports": {
"@std/assert": "jsr:@std/assert@^0.226.0",
"@std/assert": "jsr:@std/assert@^1.0.0",
"@std/async": "jsr:@std/async@^0.224.2",
"@std/fs": "jsr:@std/fs@^0.229.2",
"@std/http": "jsr:@std/http@^0.224.4",
"@std/net": "jsr:@std/net@^0.224.2",
"@std/path": "jsr:@std/path@^0.225.2",
"@std/regexp": "jsr:@std/regexp@^0.224.1",
"@std/fs": "jsr:@std/fs@^0.229.3",
"@std/http": "jsr:@std/http@^0.224.5",
"@std/net": "jsr:@std/net@^0.224.5",
"@std/path": "jsr:@std/path@^1.0.0",
"@std/regexp": "jsr:@std/regexp@^1.0.0",
"chokidar": "npm:chokidar@^3.6.0",
"zod": "npm:zod@^3.23.8"
},
Expand Down
184 changes: 99 additions & 85 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
type InputOptions,
Select as _Select,
type SelectOptions,
} from 'jsr:@cliffy/[email protected].4'
} from 'jsr:@cliffy/[email protected].5'
import { $ } from 'jsr:@david/dax'
import { Spinner } from 'jsr:@std/cli'
import { bold, cyan, dim, green, magenta } from 'jsr:@std/fmt/colors'
Expand Down
27 changes: 27 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @module http
*
* @description
* A collection of HTTP utilities.
*/

import { STATUS_TEXT, type StatusCode } from '@std/http'

// re-export everything from the standard HTTP module
export * from '@std/http'

/**
* Creates a standard response with the given status code.
* @param status The status code.
* @param init The response init.
* @returns The response.
*
* @example
* ```ts
* const response = createStandardResponse(STATUS_CODE.NotFound)
* ```
*/
export function createStandardResponse(status: StatusCode, init?: ResponseInit): Response {
const statusText = STATUS_TEXT[status]
return new Response(statusText, { status, statusText, ...init })
}
Loading

0 comments on commit fe52d32

Please sign in to comment.