npm.io
4.2.0 • Published 1 year ago

@phenyl/http-server

Licence
Apache-2.0
Version
4.2.0
Deps
2
Size
21 kB
Vulns
0
Weekly
0
Stars
58

@phenyl/http-server

Simple HTTP Server to host PhenylRestApi

example

To create a PhenylHttpServer instance, you need to create a PhenylRestApi instance.

import { createServer } from "http";
import PhenylHttpServer from "@phenyl/http-server";
import PhenylRestApi from "@phenyl/rest-api";
import { createEntityClient } from "@phenyl/memory-db";

const entityClient = createEntityClient();

class NonUserDefinition {
  constructor() {}
}

const functionalGroup = {
  nonUsers: { nonUser: new NonUserDefinition() },
  users: undefined,
  customQueries: undefined,
  customCommands: undefined,
};

const restApiHandler = new PhenylRestApi(functionalGroup, {
  entityClient,
  sessionClient: entityClient.createSessionClient(),
});

const server = new PhenylHttpServer(createServer(), { restApiHandler });

server.listen(8080)