ync-koa2-static-server

0.1.10 • Public • Published

简介

基于 koa2 搭建的静态服务。可以运行 React BrowserRouter 构建的前端页面。

如何开发

# 安装依赖
npm ci

# 发布
npm publish --access=public

如何使用

安装

# 安装
npm i ync-react-modal --save

默认开启健康检查和spa单页

const koa = require('ync-koa2-static-server');

const app = new koa();

const port = process.env.PORT || 6001;

app.start(port);

自定义健康检查

const koa = require('ync-koa2-static-server');

const app = new koa({ health: {
    {
        path: '/healthCheck',
        body: 'success'
    }
}});

const port = process.env.PORT || 6001;

app.start(port);

自定义 SPA 单页渲染

const koa = require('ync-koa2-static-server');

const app = new koa({ spa: {
    entry: 'dist',
    spa: {
        index:'entry',
        ext: '.htm'
    }, 
}});

const port = process.env.PORT || 6001;

app.start(port);

默认参数

{
    spa={
      entry: 'build',
      spa: {
        name: 'index',
        ext: '.html'
      }
    },
    health={
      path: '/health',
      body: 'ok'
    }
}

参数描述

参数名 类型 是否必须 说明 默认值
spa.entry string react 构建目录名称 build
spa.spa.name string react 构建目录启动文件名(不含文件扩展名) index
spa.spa.ext string react 构建目录启动文件扩展名 .html
health.path string koa2 静态服务健康检查地址 /health
health.body string koa2 静态服务健康检查响应 ok

/ync-koa2-static-server/

    Package Sidebar

    Install

    npm i ync-koa2-static-server

    Weekly Downloads

    1

    Version

    0.1.10

    License

    ISC

    Unpacked Size

    5.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • yunaichun