Neverending Programming Mistakes

    tiny-http2-server
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.2 • Public • Published

    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

    Keywords

    none

    Install

    npm i tiny-http2-server

    DownloadsWeekly Downloads

    25

    Version

    0.0.2

    License

    BSD-3-Clause

    Unpacked Size

    97.2 kB

    Total Files

    71

    Last publish

    Collaborators

    • yandeu