Skip to content

What is a hub?

The Hub is the heart of your application. It centralizes configuration, routes, and plugins. These elements do not depend on the runtime platform. They can live in any JavaScript environment. (Some features are exceptions and still require a server environment because they create files.)

Create a hub

ts
import { 
createHub
,
routeStore
} from "@duplojs/http";
import {
codeGeneratorPlugin
} from "@duplojs/http/codeGenerator";
export const
hub
=
createHub
({
environment
: "DEV" })
.
plug
(
codeGeneratorPlugin
({
outputFile
: "/types.d.ts" }))
.
register
(
routeStore
.
getAll
());

Simply import the createHub function from @duplojs/http, call it, configure your environment, register your plugins, and register your routes.

INFO

  • The codeGenerator plugin creates a type definition file for your routes’ input/output.
  • Your routes are registered via the routeStore. All routes, once declared, are automatically registered in the routeStore.

Released under the MIT License.