@@ -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
5555import { 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";
96112SuperDeno is also available on [ nest.land] ( https://nest.land/package/superdeno ) ,
97113a 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-
153142Here's an example of SuperDeno working with the Express web framework:
154143
155144``` ts
156145import { 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
161150Deno .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
184173import { 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
187176const router = new Router ();
188177router .get (" /" , (ctx ) => {
@@ -193,7 +182,7 @@ const app = new Application();
193182app .use (router .routes ());
194183app .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)
224213then 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" ;
228216import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
217+ import { Application , Router } from " jsr:@oak/oak@^17.1.4" ;
229218
230219const router = new Router ();
231220
0 commit comments