createServer

Creates HTTP server

Importing

import { createServer } from '@marblejs/core';

Type declaration

createServer ::  CreateServerConfig -> () -> Promise<ServerIO<HttpServer>>

Parameters

CreateServerConfig

Returns

ServerIO<HttpServer>is

Example

import { IO } from 'fp-ts/lib/IO';
import { listener } from './http.listener';
import { createServer, bindTo } from '@marblejs/core';

const httpsOptions: https.ServerOptions = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem'),
};

const server = createServer({
  port: 1337,
  hostname: '127.0.0.1',
  httpListener,
  dependencies: [
    bindTo(fooToken)(foo),
  ],
  event$: (...args) => merge(
    listening$(...args),
    upgrade$(...args),
  ),
  options: { httpsOptions },
});

const main: IO<void> = async () =>
  await (await server)();

main();

Last updated