Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Use Deno
uses: denolib/setup-deno@v2
with:
deno-version: 1.40.2
deno-version: 2.3.3
- run: make typedoc
- run: make ci
- name: Publish Updated Type Docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-egg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
- uses: actions/checkout@v2
- uses: denolib/setup-deno@v2
with:
deno-version: 1.40.2
- run: deno install -A -f --unstable -n eggs https://x.nest.land/[email protected]/eggs.ts
deno-version: 2.3.3
- run: deno install -A -f --global -n eggs https://x.nest.land/[email protected]/eggs.ts
- run: |
export PATH="/home/runner/.deno/bin:$PATH"
eggs link ${NEST_LAND_KEY}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
deno-version: [1.40.2]
deno-version: [2.3.3]

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

Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
deno-version: [1.40.2]
deno-version: [2.3.3]

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

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FILES_TO_FORMAT = ./src ./test ./deps.ts ./mod.ts ./version.ts

build:
@deno run --reload mod.ts
@deno run --allow-import --allow-env --allow-sys --allow-read --reload mod.ts

ci:
@make fmt-check
Expand All @@ -15,7 +15,7 @@ deps:
@npm install -g typescript@4 [email protected]

doc:
@deno doc ./mod.ts
@deno doc --allow-import ./mod.ts

fmt:
@deno fmt ${FILES_TO_FORMAT}
Expand All @@ -32,8 +32,7 @@ precommit:
@make fmt

test:
@deno test --allow-net --allow-read --allow-env --no-check --doc
@deno test --allow-net --allow-read --allow-env --no-check --doc --unstable
@deno test --allow-import --allow-net --allow-read --allow-env --allow-sys --no-check

typedoc:
@rm -rf docs
Expand Down
71 changes: 30 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
</p>
<p align="center">
<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>
<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>
<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>
<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>
<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>
<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>
Expand Down Expand Up @@ -53,15 +53,31 @@ SuperTest not working for you? [Raise an issue on Deno](https://github.com/denol

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

const app = opine();
const USER_ROUTE = new URLPattern({ pathname: "/user" });

app.get("/user", (req, res) => {
res.setStatus(200).json({ name: "Deno" });
});
function handler(req: Request): Response {
const match = USER_ROUTE.exec(req.url);

if (match) {
const body = JSON.stringify({ name: "Deno" });

return new Response(body, {
status: 200,
headers: {
"content-type": "application/json; charset=utf-8",
},
});
}

return new Response("Not found", {
status: 404,
});
}

superdeno(app)
const server = Deno.serve(handler);

superdeno(server)
.get("/user")
.expect("Content-Type", /json/)
.expect("Content-Length", "15")
Expand Down Expand Up @@ -96,7 +112,7 @@ import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
SuperDeno is also available on [nest.land](https://nest.land/package/superdeno),
a package registry for Deno on the Blockchain.

> 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`.
> 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`.

## Examples

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

Here's an example of SuperDeno working with the Opine web framework:

```ts
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
import { opine } from "https://deno.land/x/[email protected]/mod.ts";
import { expect } from "https://deno.land/x/[email protected]/mod.ts";

const app = opine();

app.get("/", (req, res) => {
res.send("Hello Deno!");
});

Deno.test("it should support regular expressions", async () => {
await superdeno(app)
.get("/")
.expect("Content-Type", /^application/)
.catch((err) => {
expect(err.message).toEqual(
'expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
);
});
});
```

See more examples in the [Opine test suite](./test/superdeno.opine.test.ts).

Here's an example of SuperDeno working with the Express web framework:

```ts
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
// @deno-types="npm:@types/express@^4.17"
import express from "npm:express@4.18.2";
import { expect } from "https://deno.land/x/[email protected].0/mod.ts";
// @deno-types="npm:@types/express@^4.17.22"
export { default as express } from "npm:express@4.21.2";
export { expect } from "https://deno.land/x/[email protected].2/mod.ts";

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

```ts
import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
import { Application, Router } from "https://deno.land/x/oak@v12.6.2/mod.ts";
import { Application, Router } from "jsr:@oak/oak@^17.1.4";

const router = new Router();
router.get("/", (ctx) => {
Expand All @@ -193,7 +182,7 @@ const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

Deno.test("it should support the Oak framework", () => {
Deno.test("it should support the Oak framework", async () => {
const controller = new AbortController();
const { signal } = controller;

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

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

const router = new Router();

Expand Down
7 changes: 2 additions & 5 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
export { Server } from "https://deno.land/[email protected]/http/server.ts";
export { STATUS_TEXT } from "https://deno.land/[email protected]/http/status.ts";
export type { StatusCode } from "https://deno.land/[email protected]/http/status.ts";
export { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
export { STATUS_TEXT, type StatusCode } from "jsr:@std/http@^1.0.16";
export { assertEquals } from "jsr:@std/assert@^1.0.13";
export { methods } from "https://deno.land/x/[email protected]/src/methods.ts";
export { mergeDescriptors } from "https://deno.land/x/[email protected]/src/utils/mergeDescriptors.ts";
export { getFreePort } from "https://deno.land/x/[email protected]/mod.ts";

// TODO: upgrade to v8
export { default as superagent } from "https://jspm.dev/[email protected]";
2 changes: 1 addition & 1 deletion docs/assets/js/search.json

Large diffs are not rendered by default.

Loading