0.3.23 • Published 2 months ago

yyl-server v0.3.23

Weekly downloads
43
License
ISC
Repository
github
Last release
2 months ago

yyl-server

install

npm i yyl-server --save-dev

api

/// <reference types="@types/connect" />

import createServer = require("connect");

type Log = (type: string, args: any[]) => any;
type AnyObj = { [key:string]: any};
type App = createServer.Server

interface Commit {
  hostname?: string;
  /** 静态资源域名,若没有则会取 hostname */
  staticHost?: string;
  /** html域名,若没有则会取 hostname */
  mainHost?: string;
}



interface ServerConfig {
  /** 端口 */
  port?: number;
  /** 映射目录 */
  root?: string;
  /** 热更新 port */
  lrPort?: number;
  /** 是否执行livereload */
  livereload?: boolean;
  /** 服务地址 */
  serverAddress?: string,
  /** mock 根目录 */
  mockRoot?: string;
}

interface ProxyConfig {
  /** 代理端口 */
  port?: number;
  /** 映射表 */
  localRemote?: anyObj,
  /** 是否执行 https */
  https?: boolean,
  /** 主页 */
  homePage?: string,
  /** 跳过规则 */
  ignores?: string[]
}

/** yy.config.js 中用到的配置项 */
interface YylConfig {
  /** 本地服务 配置 */
  localserver: ServerConfig,
  /** 代理服务 配置 */
  proxy: ProxyConfig,
  /** 远程配置 */
  commit: Commit
}

interface ServerOption {
  /** connect 对象绑定 第三方 */
  appWillMounted?: (app: App) => Promise<any>
  appDidMounted?: (app: App) => Promise<any>
}

/** server 相关 */
declare class Server {
  constructor({ log: Tlog, env: anyObj, config: ServerConfig, cwd: string, option: ServerOption })
  /** 启动 */
  start(): Promise<any>;
  /** 停止 - 一般用于 unit-test */
  abort(): Promise<any>;
  /** 主动热更新 */
  livereload(): Promise<any>;
  /** 初始化后的配置 */
  config: ServerConfig;
  /** express or connect 对象 */
  app: App;
  /** server 对象 */
  server: any;
  /** 热更新服务对象 */
  lrServer: any;
  option: ServerOption;
}

/** 代理相关 */
declare class Proxy {
  constructor({ log: Tlog, env: AnyObj, config: ProxyConfig})
  /** 清除 本地缓存 */
  static clean(): Promise<any>;
  /** 启动 */
  start(): Promise<any>;
  /** 停止 */
  abort(): Promise<any>;
}

/** 执行者 包含 server & proxy */
declare class Runner {
  /** 清除 本地缓存 */
  static clean(): Promise<any>;
  constructor({ log: Log, env: AnyObj, config: YylConfig, cwd: string, serverOption: ServerOption })
  /** 启动 */
  start(): Promise<any>;
  /** 停止 */
  abort(): Promise<any>;
  /** 触发热更新 */
  livereload(): Promise<any>;
}

export {
  Server,
  Proxy,
  Runner
}
0.3.23

2 months ago

0.3.22

3 months ago

0.3.21

3 months ago

0.3.20

3 months ago

0.3.19

4 months ago

0.3.18

5 months ago

0.3.17

5 months ago

0.3.16

6 months ago

0.3.15

6 months ago

0.3.14

6 months ago

0.3.13

6 months ago

0.3.12

6 months ago

0.3.11

6 months ago

0.3.10

8 months ago

0.3.9

10 months ago

0.3.8

11 months ago

0.3.7

11 months ago

0.3.6

12 months ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago