包详细信息

tiny-http2-server

yandeu49BSD-3-Clause0.0.2

A tiny http/https/http2 server.

自述文件

Tiny HTTP2 Server

tiny-http2-server

A tiny wrapper around Node's http/http2.

codecov Known Vulnerabilities

Getting Started

Create a simple http, https or http2 server.
http2 is always over https!

import { TinyServerHttp, TinyServerHttps, TinyServerHttp2 } from 'tiny-server'

const server = new TinyServerHttp2() // or TinyServerHttp(), or TinyServerHttps()
const route = server.route

// classic
route.use(logger())

// minimal
route.logger()

// classic
route.get('/hello', ({ req, res }) => {
  return res.send.text('hello')
})

// minimal
route.get('/hello', _ => 'hello')

await server.listen(8443)
console.log('Server: https://localhost:8443/')

Middleware

There are some fancy middleware includes.
See: ./src/middleware

Testing

To make a automated test use npm test.
To run a single test, use npm test -- STRING

Create a simple ssl certificate

# create certs
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -days 3560 -subj '/CN=localhost' \
 -keyout cert/localhost-privkey.pem -out cert/localhost-cert.pem