Last active
November 27, 2023 15:52
-
-
Save yusukebe/895f2ff55014c10f3e249a87e592ca49 to your computer and use it in GitHub Desktop.
node-benchmarks
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
node_modules | |
yarn.lock | |
yarn-error.log | |
*.tgz |
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
'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) |
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
'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' }) |
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
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 | |
}) |
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
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 | |
}) |
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
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 | |
}) |
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
{ | |
"dependencies": { | |
"@hono/node-server": "^1.2.3", | |
"express": "^4.18.2", | |
"fastify": "^4.24.3", | |
"hono": "^3.10.1", | |
"polka": "^0.5.2" | |
} | |
} |
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
'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