# tspexpress

> ts Promise API Express

Latest version **0.0.10** (published 2020-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install tspexpress
pnpm add tspexpress
yarn add tspexpress
bun add tspexpress
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2020-07-05 |
| First published | 2020-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hblvsjtu |
| Maintainers | hblvsjtu |
| Keywords | ts, express, promise |

## Links

- npm: https://www.npmjs.com/package/tspexpress
- Repository: https://github.com/hblvsjtu/TsPExpress
- Homepage: https://github.com/hblvsjtu/TsPExpress#readme
- Issues: https://github.com/hblvsjtu/TsPExpress/issues
- npm.io page: https://npm.io/package/tspexpress

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.0.10 (latest) — 2020-07-05
- 0.0.9 — 2020-06-21
- 0.0.8 — 2020-06-14
- 0.0.7 — 2020-06-14
- 0.0.6 — 2020-06-14
- 0.0.5 — 2020-06-14
- 0.0.4 — 2020-06-14
- 0.0.3 — 2020-06-13
- 0.0.2 — 2020-06-13
- 0.0.1 — 2020-06-13

## README

# TsPExpress

使用 Typescript 和 Promise API 重构 Express

## 安装

```sh
npm install tspexpress
```

## 使用方法 开箱即用

```js
/// <reference path="../src/types/golbal.d.ts" />

import pexpress from 'tspexpress';

const router: PExpress = pexpress.create(); // 创建实例

router.use((next: Next) => {
    // logger拦截器
    const {req, res} = next;
    console.log(
        `\r\n\r\n==================   ${new Date().toISOString()}   ==================\r\n`
    );
    return next;
});

router.setStaticPath(BASE_DIR, {defaultFile: 'index.html'}); // 设置静态资源目录

router.get('/get/:name', (next: Next) => {
    const {req, res} = next;
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(
        'path is get/path, and routerQuery = ' +
            JSON.stringify(req.routeQuery) +
            JSON.stringify(req.query)
    );
    return next;
});

router.post('/post/:path', (next: Next) => {
    const {req, res} = next;
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(
        'path is /put/path, and routerQuery = ' +
            JSON.stringify(req.routeQuery) +
            JSON.stringify(req.query) +
            JSON.stringify(req.body)
    );
    return next;
});

router.get('/*', (next: Next) => {
    // 任意目录
    const {req, res} = next;
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(
        'path is not set, and routerQuery = ' +
            JSON.stringify(req.routeQuery) +
            JSON.stringify(req.query)
    );
    return next;
});

router.listen(3000, () => console.log('server start!'));
```

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