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
It currently includes deprecated things, but those will be removed by deno_std stabilizing this month.

BREAKING CHANGE: `createStandardResponse` and `STATUS_CODE` are now exported from hado/http instead of hado/router
  • Loading branch information
brc-dd committed Jul 11, 2024
1 parent 1d747c2 commit fad9ab9
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 96 deletions.
9 changes: 5 additions & 4 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,11 +20,11 @@
"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/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@^0.225.2",
"@std/regexp": "jsr:@std/regexp@^0.224.1",
"chokidar": "npm:chokidar@^3.6.0",
Expand Down
162 changes: 90 additions & 72 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 fad9ab9

Please sign in to comment.