Skip to content

Commit 112b235

Browse files
authored
feat: support Express and upgrade dependencies (#44)
1 parent 55ea0ca commit 112b235

33 files changed

+1435
-306
lines changed

.github/workflows/publish-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
- name: Use Node.js
1414
uses: actions/setup-node@v1
1515
with:
16-
node-version: 12
16+
node-version: 20
1717
- name: Install deps
1818
run: make deps
1919
- name: Use Deno
2020
uses: denolib/setup-deno@v2
2121
with:
22-
deno-version: 1.19.3
22+
deno-version: 1.40.2
2323
- run: make typedoc
2424
- run: make ci
2525
- name: Publish Updated Type Docs
2626
uses: stefanzweifel/git-auto-commit-action@v4
2727
with:
2828
commit_message: publish typedocs
29-
push_options: --force
29+
push_options: --force

.github/workflows/publish-egg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: denolib/setup-deno@v2
1313
with:
14-
deno-version: 1.19.3
14+
deno-version: 1.40.2
1515
- run: deno install -A -f --unstable -n eggs https://x.nest.land/[email protected]/eggs.ts
1616
- run: |
1717
export PATH="/home/runner/.deno/bin:$PATH"

.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.19.3]
14+
deno-version: [1.40.2]
1515

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

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

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

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ci:
1212
@make test
1313

1414
deps:
15-
@npm install -g typescript [email protected]
15+
@npm install -g typescript@4 [email protected]
1616

1717
doc:
1818
@deno doc ./mod.ts
@@ -24,7 +24,7 @@ fmt-check:
2424
@deno fmt --check ${FILES_TO_FORMAT}
2525

2626
lint:
27-
@deno lint --unstable ${FILES_TO_FORMAT}
27+
@deno lint ${FILES_TO_FORMAT}
2828

2929
precommit:
3030
@make typedoc

README.md

Lines changed: 53 additions & 20 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.19.3-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-^1.40.2-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>
@@ -31,7 +31,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
3131
- [Getting Started](#getting-started)
3232
- [About](#about)
3333
- [Installation](#installation)
34-
- [Example](#example)
34+
- [Examples](#examples)
3535
- [Documentation](#documentation)
3636
- [API](#api)
3737
- [Notes](#notes)
@@ -42,7 +42,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
4242

4343
```ts
4444
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
45-
import { opine } from "https://deno.land/x/opine@1.9.1/mod.ts";
45+
import { opine } from "https://deno.land/x/opine@2.3.4/mod.ts";
4646

4747
const app = opine();
4848

@@ -85,9 +85,9 @@ import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
8585
SuperDeno is also available on [nest.land](https://nest.land/package/superdeno),
8686
a package registry for Deno on the Blockchain.
8787

88-
> 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.8.0/mod.ts`.
88+
> 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`.
8989
90-
## Example
90+
## Examples
9191

9292
You may pass a url string,
9393
[`http.Server`](https://doc.deno.land/https/deno.land/std/http/mod.ts#Server), a
@@ -116,8 +116,8 @@ Here's an example of SuperDeno working with the Opine web framework:
116116

117117
```ts
118118
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
119-
import { opine } from "https://deno.land/x/opine@1.9.1/mod.ts";
120-
export { expect } from "https://deno.land/x/expect@v0.2.9/mod.ts";
119+
import { opine } from "https://deno.land/x/opine@2.3.4/mod.ts";
120+
import { expect } from "https://deno.land/x/expect@v0.4.0/mod.ts";
121121

122122
const app = opine();
123123

@@ -129,19 +129,49 @@ Deno.test("it should support regular expressions", async () => {
129129
await superdeno(app)
130130
.get("/")
131131
.expect("Content-Type", /^application/)
132-
.end((err) => {
132+
.catch((err) => {
133133
expect(err.message).toEqual(
134-
'expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"',
134+
'expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
135135
);
136136
});
137137
});
138138
```
139139

140+
See more examples in the [Opine test suite](./test/superdeno.opine.test.ts).
141+
142+
Here's an example of SuperDeno working with the Express web framework:
143+
144+
```ts
145+
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
146+
// @deno-types="npm:@types/express@^4.17"
147+
import express from "npm:[email protected]";
148+
import { expect } from "https://deno.land/x/[email protected]/mod.ts";
149+
150+
Deno.test("it should support regular expressions", async () => {
151+
const app = express();
152+
153+
app.get("/", (_req, res) => {
154+
res.send("Hello Deno!");
155+
});
156+
157+
await superdeno(app)
158+
.get("/")
159+
.expect("Content-Type", /^application/)
160+
.catch((err) => {
161+
expect(err.message).toEqual(
162+
'expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
163+
);
164+
});
165+
});
166+
```
167+
168+
See more examples in the [Express test suite](./test/superdeno.express.test.ts).
169+
140170
Here's an example of SuperDeno working with the Oak web framework:
141171

142172
```ts
143173
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
144-
import { Application, Router } from "https://deno.land/x/oak@v10.0.0/mod.ts";
174+
import { Application, Router } from "https://deno.land/x/oak@v12.6.2/mod.ts";
145175

146176
const router = new Router();
147177
router.get("/", (ctx) => {
@@ -171,6 +201,8 @@ Deno.test("it should support the Oak framework", () => {
171201
});
172202
```
173203

204+
See more examples in the [Oak test suite](./test/superdeno.oak.test.ts).
205+
174206
If you are using the [Oak](https://github.com/oakserver/oak/) web framework then
175207
it is recommended that you use the specialized
176208
[SuperOak](https://github.com/cmorten/superoak) assertions library for
@@ -181,7 +213,7 @@ are making use of the `app.handle()` method (for example for serverless apps)
181213
then you can write slightly less verbose tests for Oak:
182214

183215
```ts
184-
import { Application, Router } from "https://deno.land/x/oak@v10.0.0/mod.ts";
216+
import { Application, Router } from "https://deno.land/x/oak@v12.6.2/mod.ts";
185217
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
186218

187219
const router = new Router();
@@ -194,15 +226,16 @@ const app = new Application();
194226
app.use(router.routes());
195227
app.use(router.allowedMethods());
196228

197-
Deno.test("it should support the Oak framework `app.handle` method", async () => {
198-
/**
199-
* Note that we have to bind `app` to the function otherwise `app.handle`
200-
* doesn't preserve the `this` context from `app`.
201-
*/
202-
await superdeno(app.handle.bind(app))
203-
.get("/")
204-
.expect("Hello Deno!");
205-
});
229+
Deno.test(
230+
"it should support the Oak framework `app.handle` method",
231+
async () => {
232+
/**
233+
* Note that we have to bind `app` to the function otherwise `app.handle`
234+
* doesn't preserve the `this` context from `app`.
235+
*/
236+
await superdeno(app.handle.bind(app)).get("/").expect("Hello Deno!");
237+
}
238+
);
206239
```
207240

208241
In this case, SuperDeno handles the setup and closing of the server for you, so

deps.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
export { Server } from "https://deno.land/[email protected]/http/server.ts";
2-
export { STATUS_TEXT } from "https://deno.land/[email protected]/http/http_status.ts";
3-
export { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
4-
export { methods } from "https://deno.land/x/[email protected]/src/methods.ts";
5-
export { mergeDescriptors } from "https://deno.land/x/[email protected]/src/utils/mergeDescriptors.ts";
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";
5+
export { methods } from "https://deno.land/x/[email protected]/src/methods.ts";
6+
export { mergeDescriptors } from "https://deno.land/x/[email protected]/src/utils/mergeDescriptors.ts";
7+
export { getFreePort } from "https://deno.land/x/[email protected]/mod.ts";
8+
9+
// TODO: upgrade to v8
610
export { default as superagent } from "https://jspm.dev/[email protected]";

0 commit comments

Comments
 (0)