@awesomeorganization/servers
v2.0.2
Published
[ESM] The easiest way to create http, http2, https, https2, tcp, tls, udp servers in Node.js
Downloads
118
Maintainers
Readme
@awesomeorganization/servers
:boom: [ESM] The easiest way to create http, http2, https, https2, tcp, tls, udp servers in Node.js
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/