Skip to content

Commit 9616906

Browse files
[#46] Deno 2.x Support (#47)
1 parent 57252a3 commit 9616906

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+579
-1549
lines changed

.github/workflows/publish-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Use Deno
2020
uses: denolib/setup-deno@v2
2121
with:
22-
deno-version: 1.40.2
22+
deno-version: 2.3.3
2323
- run: make typedoc
2424
- run: make ci
2525
- name: Publish Updated Type Docs

.github/workflows/publish-egg.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: denolib/setup-deno@v2
1313
with:
14-
deno-version: 1.40.2
15-
- run: deno install -A -f --unstable -n eggs https://x.nest.land/[email protected]/eggs.ts
14+
deno-version: 2.3.3
15+
- run: deno install -A -f --global -n eggs https://x.nest.land/[email protected]/eggs.ts
1616
- run: |
1717
export PATH="/home/runner/.deno/bin:$PATH"
1818
eggs link ${NEST_LAND_KEY}

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macos-latest]
14-
deno-version: [1.40.2]
14+
deno-version: [2.3.3]
1515

1616
runs-on: ${{ matrix.os }}
1717

@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [windows-latest]
30-
deno-version: [1.40.2]
30+
deno-version: [2.3.3]
3131

3232
runs-on: ${{ matrix.os }}
3333

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FILES_TO_FORMAT = ./src ./test ./deps.ts ./mod.ts ./version.ts
44

55
build:
6-
@deno run --reload mod.ts
6+
@deno run --allow-import --allow-env --allow-sys --allow-read --reload mod.ts
77

88
ci:
99
@make fmt-check
@@ -15,7 +15,7 @@ deps:
1515
@npm install -g typescript@4 [email protected]
1616

1717
doc:
18-
@deno doc ./mod.ts
18+
@deno doc --allow-import ./mod.ts
1919

2020
fmt:
2121
@deno fmt ${FILES_TO_FORMAT}
@@ -32,8 +32,7 @@ precommit:
3232
@make fmt
3333

3434
test:
35-
@deno test --allow-net --allow-read --allow-env --no-check --doc
36-
@deno test --allow-net --allow-read --allow-env --no-check --doc --unstable
35+
@deno test --allow-import --allow-net --allow-read --allow-env --allow-sys --no-check
3736

3837
typedoc:
3938
@rm -rf docs

README.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
1818
</p>
1919
<p align="center">
2020
<a href="https://deno.land/x/superdeno"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fsuperdeno%2Fmod.ts" alt="SuperDeno latest /x/ version" /></a>
21-
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-^1.40.2-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
21+
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-^2.3.3-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
2222
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fsuperdeno%2Fmod.ts" alt="SuperDeno dependency count" /></a>
2323
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fsuperdeno%2Fmod.ts" alt="SuperDeno dependency outdatedness" /></a>
2424
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fx%2Fsuperdeno%2Fmod.ts" alt="SuperDeno cached size" /></a>
@@ -53,15 +53,31 @@ SuperTest not working for you? [Raise an issue on Deno](https://github.com/denol
5353

5454
```ts
5555
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
56-
import { opine } from "https://deno.land/x/[email protected]/mod.ts";
5756

58-
const app = opine();
57+
const USER_ROUTE = new URLPattern({ pathname: "/user" });
5958

60-
app.get("/user", (req, res) => {
61-
res.setStatus(200).json({ name: "Deno" });
62-
});
59+
function handler(req: Request): Response {
60+
const match = USER_ROUTE.exec(req.url);
61+
62+
if (match) {
63+
const body = JSON.stringify({ name: "Deno" });
64+
65+
return new Response(body, {
66+
status: 200,
67+
headers: {
68+
"content-type": "application/json; charset=utf-8",
69+
},
70+
});
71+
}
72+
73+
return new Response("Not found", {
74+
status: 404,
75+
});
76+
}
6377

64-
superdeno(app)
78+
const server = Deno.serve(handler);
79+
80+
superdeno(server)
6581
.get("/user")
6682
.expect("Content-Type", /json/)
6783
.expect("Content-Length", "15")
@@ -96,7 +112,7 @@ import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
96112
SuperDeno is also available on [nest.land](https://nest.land/package/superdeno),
97113
a package registry for Deno on the Blockchain.
98114

99-
> Note: All examples in this README are using the unversioned form of the import URL. In production you should always use the versioned import form such as `https://deno.land/x/superdeno@4.9.0/mod.ts`.
115+
> Note: All examples in this README are using the unversioned form of the import URL. In production you should always use the versioned import form such as `https://deno.land/x/superdeno@5.0.0/mod.ts`.
100116
101117
## Examples
102118

@@ -123,40 +139,13 @@ Deno.test("GET /user responds with json", async () => {
123139
});
124140
```
125141

126-
Here's an example of SuperDeno working with the Opine web framework:
127-
128-
```ts
129-
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
130-
import { opine } from "https://deno.land/x/[email protected]/mod.ts";
131-
import { expect } from "https://deno.land/x/[email protected]/mod.ts";
132-
133-
const app = opine();
134-
135-
app.get("/", (req, res) => {
136-
res.send("Hello Deno!");
137-
});
138-
139-
Deno.test("it should support regular expressions", async () => {
140-
await superdeno(app)
141-
.get("/")
142-
.expect("Content-Type", /^application/)
143-
.catch((err) => {
144-
expect(err.message).toEqual(
145-
'expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
146-
);
147-
});
148-
});
149-
```
150-
151-
See more examples in the [Opine test suite](./test/superdeno.opine.test.ts).
152-
153142
Here's an example of SuperDeno working with the Express web framework:
154143

155144
```ts
156145
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
157-
// @deno-types="npm:@types/express@^4.17"
158-
import express from "npm:express@4.18.2";
159-
import { expect } from "https://deno.land/x/[email protected].0/mod.ts";
146+
// @deno-types="npm:@types/express@^4.17.22"
147+
export { default as express } from "npm:express@4.21.2";
148+
export { expect } from "https://deno.land/x/[email protected].2/mod.ts";
160149

161150
Deno.test("it should support regular expressions", async () => {
162151
const app = express();
@@ -182,7 +171,7 @@ Here's an example of SuperDeno working with the Oak web framework:
182171

183172
```ts
184173
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
185-
import { Application, Router } from "https://deno.land/x/oak@v12.6.2/mod.ts";
174+
import { Application, Router } from "jsr:@oak/oak@^17.1.4";
186175

187176
const router = new Router();
188177
router.get("/", (ctx) => {
@@ -193,7 +182,7 @@ const app = new Application();
193182
app.use(router.routes());
194183
app.use(router.allowedMethods());
195184

196-
Deno.test("it should support the Oak framework", () => {
185+
Deno.test("it should support the Oak framework", async () => {
197186
const controller = new AbortController();
198187
const { signal } = controller;
199188

@@ -224,8 +213,8 @@ are making use of the `app.handle()` method (for example for serverless apps)
224213
then you can write slightly less verbose tests for Oak:
225214

226215
```ts
227-
import { Application, Router } from "https://deno.land/x/[email protected]/mod.ts";
228216
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
217+
import { Application, Router } from "jsr:@oak/oak@^17.1.4";
229218

230219
const router = new Router();
231220

deps.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
export { Server } from "https://deno.land/[email protected]/http/server.ts";
2-
export { STATUS_TEXT } from "https://deno.land/[email protected]/http/status.ts";
3-
export type { StatusCode } from "https://deno.land/[email protected]/http/status.ts";
4-
export { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
1+
export { STATUS_TEXT, type StatusCode } from "jsr:@std/http@^1.0.16";
2+
export { assertEquals } from "jsr:@std/assert@^1.0.13";
53
export { methods } from "https://deno.land/x/[email protected]/src/methods.ts";
64
export { mergeDescriptors } from "https://deno.land/x/[email protected]/src/utils/mergeDescriptors.ts";
75
export { getFreePort } from "https://deno.land/x/[email protected]/mod.ts";
8-
96
// TODO: upgrade to v8
107
export { default as superagent } from "https://jspm.dev/[email protected]";

docs/assets/js/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)