Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp committed Mar 19, 2019
1 parent af858f8 commit ac1c685
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright 2019 Yusuke Sakurai. All rights reserved. MIT license.
import {IncomingHttpRequest, serve, ServeOptions} from "./server.ts";
import {encode} from "https://deno.land/[email protected]/strings/strings.ts";
import {
serve,
ServeOptions,
ServerRequest
} from "./server.ts";
import { encode } from "https://deno.land/[email protected]/strings/strings.ts";

export type RoutedServerRequest = IncomingHttpRequest & {
export type RoutedServerRequest = ServerRequest & {
match?: RegExpMatchArray;
};

Expand Down
10 changes: 5 additions & 5 deletions router_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ test(function httpMatchNearest() {
});
test(async function router() {
const server = createRouter();
server.handle("/index", async (req, { respond }) => {
await respond({
server.handle("/index", async req => {
await req.respond({
status: 200,
headers: new Headers({
"content-type": "text/plain"
}),
body: new StringReader("ok")
});
});
server.handle(new RegExp("/foo/(?<id>.+)"), async (req, { respond }) => {
server.handle(new RegExp("/foo/(?<id>.+)"), async req => {
const { id } = req.match.groups;
await respond({
await req.respond({
status: 200,
headers: new Headers({
"content-type": "application/json"
}),
body: new StringReader(JSON.stringify({ id }))
});
});
server.handle("/no-response", async (req, res) => {});
server.handle("/no-response", async req => {});
const cancel = defer<void>();
try {
server.listen("127.0.0.1:8898", { cancel: cancel.promise });
Expand Down
3 changes: 2 additions & 1 deletion serveio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
encode
} from "https://deno.land/[email protected]/strings/strings.ts";
import {
ClientRequest, IncomingHttpRequest,
ClientRequest,
IncomingHttpRequest,
IncomingHttpResponse,
ServerRequest,
ServerResponse
Expand Down

0 comments on commit ac1c685

Please sign in to comment.