-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
released v5.0.7 - withParams has more explicit check to prevent bindi…
…ng null
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { error } = require("../../dist/index") | ||
const { AutoRouter } = require("../../dist/AutoRouter") | ||
const { createServerAdapter } = require("@whatwg-node/server") | ||
const http = require("http") | ||
|
||
const router = AutoRouter({ | ||
catch: (err) => { | ||
console.log('ERROR', err.message, err.stack) | ||
|
||
return error(500, err.stack) | ||
} | ||
}) | ||
|
||
router.get('*', () => "Hello itty-router v5") | ||
|
||
const serverAdapter = createServerAdapter(async (request) => { | ||
// this works | ||
|
||
const url = new URL(request.url) | ||
|
||
console.log({ | ||
url: request.url, | ||
newURL: url, | ||
method: request.method, | ||
}) | ||
|
||
request.query = {} | ||
request.params = {} | ||
request.route = '/foo' | ||
request.proxy = new Proxy(request, {}) | ||
|
||
const slimRequest = { | ||
method: request.method, | ||
url: request.url, | ||
} | ||
|
||
return await router.fetch(request) | ||
}) | ||
|
||
const httpServer = http.createServer(serverAdapter) | ||
|
||
httpServer.listen(5000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters