2.0.2 • Published 2 years ago

@awesomeorganization/servers v2.0.2

Weekly downloads
135
License
MIT
Repository
github
Last release
2 years ago

@awesomeorganization/servers

:boom: ESM The easiest way to create http, http2, https, https2, tcp, tls, udp servers in Node.js


GitHub Workflow Codacy CodeFactor Snyk Depfu npms.io


Install

npm install @awesomeorganization/servers

Example

Full example in /example folder.

import { LOCALHOST_CERT, LOCALHOST_KEY, http, https, https2 } from '@awesomeorganization/servers'

const example = () => {
  http({
    handlers: {
      request(_request, response) {
        response.end('Hi!')
      },
    },
    listenOptions: {
      host: '127.0.0.1',
      port: 3000,
    },
  })
  https({
    createOptions: {
      cert: LOCALHOST_CERT,
      key: LOCALHOST_KEY,
    },
    handlers: {
      request(_request, response) {
        response.end('Hi!')
      },
    },
    listenOptions: {
      host: '127.0.0.1',
      port: 4000,
    },
  })
  https2({
    createOptions: {
      cert: LOCALHOST_CERT,
      key: LOCALHOST_KEY,
    },
    handlers: {
      stream(stream) {
        stream.end('Hi!')
      },
    },
    listenOptions: {
      host: '127.0.0.1',
      port: 5000,
    },
  })
}

example()

// TRY
// http://127.0.0.1:3000/
// https://127.0.0.1:4000/
// https://127.0.0.1:5000/
2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago