-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(micro): use new micro semantics (#342)
- Loading branch information
Showing
3 changed files
with
15 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
'use strict' | ||
|
||
const micro = require('micro') | ||
const http = require('http') | ||
const { send, serve } = require('micro') | ||
const dispatch = require('micro-route/dispatch') | ||
|
||
const handler = (req, res) => micro.send(res, 200, { hello: 'world' }) | ||
const handler = (req, res) => send(res, 200, { hello: 'world' }) | ||
|
||
const server = micro( | ||
dispatch('/', 'GET', handler) | ||
) | ||
const server = new http.Server(serve(dispatch('/', 'GET', handler))) | ||
|
||
server.listen(3000) |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
'use strict' | ||
|
||
const micro = require('micro') | ||
const http = require('http') | ||
const { serve } = require('micro') | ||
|
||
const server = micro(async function (req, res) { | ||
return { hello: 'world' } | ||
}) | ||
const server = new http.Server( | ||
serve(async function (req, res) { | ||
return { hello: 'world' } | ||
}) | ||
) | ||
|
||
server.listen(3000) |
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
'use strict' | ||
|
||
const micro = require('micro') | ||
const http = require('http') | ||
const { serve, send } = require('micro') | ||
const { router, get } = require('microrouter') | ||
|
||
const hello = async function (req, res) { | ||
return micro.send(res, 200, { hello: 'world' }) | ||
return send(res, 200, { hello: 'world' }) | ||
} | ||
const server = micro( | ||
router( | ||
get('/', hello) | ||
) | ||
) | ||
const server = new http.Server(serve(router(get('/', hello)))) | ||
|
||
server.listen(3000) |