@vode-app/create-hono-server (0.1.0-pre.35)

Published 2026-05-30 14:49:18 +02:00 by temir in vode-app/create-hono-server

Installation

@vode-app:registry=
npm install @vode-app/create-hono-server@0.1.0-pre.35
"@vode-app/create-hono-server": "0.1.0-pre.35"

About this package

Introduction

This template scaffolds a ...

Table of Contents

  1. Quick Start
  2. Documentation
    1. createAppHost()
    2. createSpaHost()
  3. DevOps
    1. Change Management
    2. Publish

Quick Start

# placeholder:
    # <TEMPLATE_PACKAGE_NAME: @vode-app/create-hono-server
    # <TEMPLATE_NAME: @vode-app/hono-server

# print the latest version
npm info "@vode-app/create-hono-server" version

# create/update a package from the template in the current directory
npm create --no-install --no-git "@vode-app/hono-server@latest" .

# set metadata in package.json

npm update

Documentation

The following sections explain the configurations and conventions baked into the generated package. Useful when adapting it to fit specific needs.

<DOCUMENTATION>

In the src/main.ts file, an App Host is first created, then an App Host Server is started with the created App Host.

An App Host is just a Hono<E> instance. Do with it what you will.

createAppHost()

A convenience function for creating an App Host is provided by the @vode-app/common-server-side/hono package. It abstracts away some of the common setup and configuration, while still allowing for flexibility and customization.

Example usage:

import {
    // ...
    createAppHost,
    type CreateAppHostOptions,
    // ...
    createLoggingMiddleware,
    createRequestLoggerMiddleware,
    // ...
} from '@vode-app/common-server-side/hono';

import { requestId } from 'hono/request-id';
import { compress } from 'hono/compress';
import { secureHeaders } from 'hono/secure-headers';

// ...
    // ...
    const createAppHostOptions: CreateAppHostOptions<AppHostEnv> = {
        middleware: [

            createLoggingMiddleware({
                logLevel: env.LOG_LEVEL,
                logLevelPerScope: logLevelPerScope
                    ? logLevelPerScope
                    : undefined
                ,
            }),

            // DEVEL: Add dependency injection middleware here

            requestId(),
            createRequestLoggerMiddleware<AppHostEnv>(),
            compress(),
            secureHeaders(),

            // DEVEL: Add middleware here

        ],
        endpointGroups: [

            createGetHealthEndpoint({
                path: '/health',
                description: 'App host health check endpoint.',
            }),
            createGetBuildinfoEndpoint({
                path: '/buildinfo',
                description: 'App host buildinfo endpoint.',
                buildinfoUrl: serverBuildinfoUrl,
            }),

            // DEVEL: Add endpoint groups here

        ],
        exposeOpenApi: env.EXPOSE_OPENAPI,
    };
    if (basePathTrimmed) createAppHostOptions.basePath = basePathTrimmed;
    if (createAppHostOptions.exposeOpenApi) {
        createAppHostOptions.openApi = {
            title: 'Web API',
            version: '1.0.0',
            description: 'API documentation for the server.',
            path: 'openapi',
            uiPath: 'scalar',
        };
    }

    appHost = createAppHost<AppHostEnv>(createAppHostOptions);
    // ...
// ... 

createSpaHost()

A convenience function for creating an SPA Host is provided by the @vode-app/common-server-side/hono package. It abstracts away some of the common setup and configuration for hosting a Single Page Application (SPA), while still allowing for flexibility and customization. Under the hood, it creates an App Host and configures it to serve the SPA.

Example usage:

import {
    // ...
    createSpaHost,
    type CreateSpaHostOptions,
    type CreateSpaOptions,
    // ...
} from '@vode-app/common-server-side/hono';

import {
    buildinfoUrl as clientBuildinfoUrl,
    indexHtmlUrl as clientIndexHtmlUrl,
    assetsUrl as clientAssetsUrl,
    distUrl as clientDistUrl
} from 'example-vode-app-client/constants';

// ...
    // ...
    const createSpaOptions: CreateSpaOptions = {
        path: 'example/',
        buildinfoUrl: clientBuildinfoUrl,
        indexHtmlUrl: clientIndexHtmlUrl,
        assets: {
            'index.bundle.js': new URL('index.bundle.js', clientDistUrl),
            'index.bundle.css': new URL('index.bundle.css', clientDistUrl),
            'favicon.svg': new URL('favicon.svg', clientAssetsUrl),
            'pwa/manifest.webmanifest': new URL('pwa/manifest.webmanifest', clientAssetsUrl),
            'pwa/images/wide-screenshot.png': new URL('pwa/images/wide-screenshot.png', clientAssetsUrl),
            'pwa/images/mobile-screenshot.png': new URL('pwa/images/mobile-screenshot.png', clientAssetsUrl),
        },
    };
    if (basePathTrimmed) createSpaOptions.basePath = `/${basePathTrimmed}/`;

    const createSpaHostOptions: CreateSpaHostOptions<AppHostEnv> = {
        logLevel: {
            default: env.LOG_LEVEL,
            perScope: logLevelPerScope,
        },
        dependencyInjectionMiddleware: [

            // DEVEL: add dependency injection middleware here

        ],
        middleware: [

            // DEVEL: add middleware here

        ],
        serverBuildinfoUrl: serverBuildinfoUrl,
        spa: createSpaOptions,
        endpointGroups: [

            // DEVEL: add endpoint groups here

        ],
        exposeOpenApi: env.EXPOSE_OPENAPI,
    };
    if (basePathTrimmed) createSpaHostOptions.basePath = basePathTrimmed;
    if (createSpaHostOptions.exposeOpenApi) {
        createSpaHostOptions.openApi = {
            title: 'Web API',
            version: '1.0.0',
            description: 'API documentation for the server.',
            path: 'openapi',
            uiPath: 'scalar',
        };
    }

    appHost = createSpaHost<AppHostEnv>(createSpaHostOptions);
    // ...
// ...

DevOps

npm install
npm update

npm run clean
npm run build
npm run tests

npmx tsx dist/cli.bundle.js -- example/

Change Management

  1. Create a new branch for the change.
  2. Make the changes and commit.
  3. Bump the version in package.json.
  4. Add an entry for the new version in CHANGELOG.md.
  5. Pull-request the branch.
  6. Ensure package artifacts are current.
  7. Publish.

Publish

~/.npmrc or .npmrc:

@vode-app:registry=https://git.chimps.quest/api/packages/vode-app/npm/
//git.chimps.quest/api/packages/vode-app/npm/:_authToken=${VODE_APP_REGISTRY_AUTH_TOKEN}

~/.bunfig.toml or bunfig.toml:

[install.scopes]
"vode-app" = { url = "https://git.chimps.quest/api/packages/vode-app/npm/", token = "$VODE_APP_REGISTRY_AUTH_TOKEN" }
# git.chimps.quest/api/packages/vode-app/npm/
export VODE_APP_REGISTRY_AUTH_TOKEN=<AUTH_TOKEN>
# or
$env:VODE_APP_REGISTRY_AUTH_TOKEN = "<AUTH_TOKEN>"
npm publish

Dependencies

Development dependencies

ID Version
@types/node latest
esbuild latest
tsx latest
typescript ^6.0.3

Keywords

typescript template server hono
Details
npm
2026-05-30 14:49:18 +02:00
5
temir.ra
MIT
10 KiB
Assets (1)
Versions (42) View all
0.1.0-pre.59 2026-07-05
0.1.0-pre.58 2026-07-05
0.1.0-pre.57 2026-07-05
0.1.0-pre.56 2026-07-05
0.1.0-pre.55 2026-07-05