# @flowxjs/typeservice

> Native nodejs server container framework

Latest version **1.0.4** (published 2020-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @flowxjs/typeservice
pnpm add @flowxjs/typeservice
yarn add @flowxjs/typeservice
bun add @flowxjs/typeservice
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-05-02 |
| First published | 2020-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 2.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | evio |
| Maintainers | evio |
| Keywords | typescript, container, ioC, rx, rxjs, service |

## Links

- npm: https://www.npmjs.com/package/@flowxjs/typeservice
- npm.io page: https://npm.io/package/@flowxjs/typeservice

## Dependencies (6)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.5
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [inversify](https://npm.io/package/inversify.md) ^5.0.1
- [rxjs-compat](https://npm.io/package/rxjs-compat.md) ^6.5.5
- [@reactivex/rxjs](https://npm.io/package/@reactivex/rxjs.md) ^6.5.5
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-05-02
- 1.0.3 — 2020-05-02
- 1.0.2 — 2020-04-25
- 1.0.1 — 2020-04-25
- 1.0.0 — 2020-04-25

## README

#  TypeService

基于`Nodejs`的容器服务启动器，通过插件模式可扩展具体应用实例。

## Usage

安装模块

```bash
$ npm i @flowxjs/typeservice
```

创建一个日志文件 `src/app.logger.ts`

```ts
export type TTypeServiceLogger = Console;
export const TypeServiceLogger = console;
```

创建一个启动文件 `src/app.bootstrap.ts`

```ts
import { Factory, TTypeServiceFactoryBootstrapInstance, TypeServiceFactoryInstance, TAnnotationScanerResult } from '@flowxjs/typeservice';
import { TTypeServiceLogger, TypeServiceLogger } from './app.logger';
import { Plugin } from './app.plugin';

@Factory.Logger(TypeServiceLogger)
@Factory.Setup(Plugin)
export class ApplicationFactory extends TypeServiceFactoryInstance<TTypeServiceLogger> implements TTypeServiceFactoryBootstrapInstance {
  message(value: any) {
    if (value instanceof Error) return this.factory.logger.error(value);
    this.factory.logger.info(value);
  }

  initialize(meta: TAnnotationScanerResult) {
    console.log('factory initialize', meta);
  }

  terminate(meta: TAnnotationScanerResult) {
    console.log('factory terminate', meta);
  }
}
```

创建一个插件文件 `src/app.plugin.ts`

```ts
import { TypeServiceFactoryInstance, TTypeServiceLifeCycleInstance, TAnnotationScanerResult } from '@flowxjs/typeservice';
import { TTypeServiceLogger } from './app.logger';

export class Plugin extends TypeServiceFactoryInstance<TTypeServiceLogger> implements TTypeServiceLifeCycleInstance {
  async initialize(meta: TAnnotationScanerResult) {
    console.log('plugin initialize', meta);
    await new Promise(resolve => setTimeout(resolve, 2000));
  }

  async terminate(meta: TAnnotationScanerResult) {
    await new Promise(resolve => setTimeout(resolve, 3000));
    console.log('plugin terminate', meta);
  }
}
```

## CLI

使用命令行工具

- 启动开发程序 `ts-dev`
- 启动PM2托管 `ts-pm2-start`
- 停止PM2托管 `ts-pm2-stop`
- 重启PM2托管 `ts-pm2-restart`
- 删除PM2托管 `ts-pm2-delete`

---
_Source: https://npm.io/package/@flowxjs/typeservice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
