Skip to main content

Server Initialization

Once you have installed the @genzy/api library, you can now init the API.

Initialization

Standalone

const { GenzyApi, GenzyContainer } = require("@genzy/api");

const container = new GenzyContainer().addLocalServices(/* services */);

const app = new GenzyApi().from(container);

app.listen(3000);

This implicitly starts a Express Application.

With an existing Express Application

const express = require("express");
const { GenzyApi, GenzyContainer } = require("@genzy/api");

const container = new GenzyContainer().addLocalServices(/* services */);

const existingApp = express();

const app = new GenzyApi({ app: existingApp }).from(container);

existingApp.listen(3000);
caution

Using app.listen(3000) will not work here, as it creates a new HTTP server.

Options

The complete list of available options can be found here.