Skip to content

Commit

Permalink
fix(micro): use new micro semantics (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
chernodub authored Sep 4, 2024
1 parent eb60f20 commit 02a1827
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
9 changes: 4 additions & 5 deletions benchmarks/micro-route.cjs
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)
11 changes: 7 additions & 4 deletions benchmarks/micro.cjs
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)
11 changes: 4 additions & 7 deletions benchmarks/microrouter.cjs
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)

0 comments on commit 02a1827

Please sign in to comment.