Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Last active November 27, 2023 15:52
Show Gist options
  • Save yusukebe/895f2ff55014c10f3e249a87e592ca49 to your computer and use it in GitHub Desktop.
Save yusukebe/895f2ff55014c10f3e249a87e592ca49 to your computer and use it in GitHub Desktop.
node-benchmarks
node_modules
yarn.lock
yarn-error.log
*.tgz
'use strict'
const express = require('express')
const app = express()
app.disable('etag')
app.disable('x-powered-by')
app.get('/', function (req, res) {
res.header('Content-Type', 'text/plain;charset=UTF-8')
res.end('Hi')
})
app.get('/json', function (req, res) {
res.json({ hello: 'world' })
})
const port = 2997
console.log(port)
app.listen(port)
'use strict'
const fastify = require('fastify')()
fastify.get('/', async (request, reply) => {
reply.type('text/plain;charset=UTF-8').send('Hi')
})
const schema = {
schema: {
response: {
200: {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
}
}
fastify.get('/json', schema, function (req, reply) {
reply.send({ hello: 'world' })
})
const port = 2999
console.log(port)
fastify.listen({ port, host: '127.0.0.1' })
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hi'))
app.get('/json', (c) =>
c.json({
hello: 'world'
})
)
const port = 3002
console.log(port)
Bun.serve({
port,
fetch: app.fetch
})
import { serve } from '../../honojs/node-server/dist/index.mjs'
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hi'))
app.get('/json', (c) =>
c.json({
hello: 'world'
})
)
const port = 3001
console.log(port)
serve({
fetch: app.fetch,
port
})
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hi'))
app.get('/json', (c) =>
c.json({
hello: 'world'
})
)
const port = 3000
console.log(port)
serve({
fetch: app.fetch,
port
})
{
"dependencies": {
"@hono/node-server": "^1.2.3",
"express": "^4.18.2",
"fastify": "^4.24.3",
"hono": "^3.10.1",
"polka": "^0.5.2"
}
}
'use strict'
const polka = require('polka')
const app = polka()
app.get('/', (req, res) => {
res.setHeader('content-type', 'text/plain;charset=UTF-8')
res.end('Hi')
})
app.get('/json', (req, res) => {
res.setHeader('content-type', 'application/json; charset=utf-8')
res.end(JSON.stringify({ hello: 'world' }))
})
const port = 2998
console.log(2998)
app.listen(port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment