@awesomeorganization/servers
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@awesomeorganization/servers

💥 [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/

Package Sidebar

Install

npm i @awesomeorganization/servers

Weekly Downloads

11

Version

2.0.2

License

MIT

Unpacked Size

10.5 kB

Total Files

4

Last publish

Collaborators

  • sergey.sedoy.97