# finch-min

> Minimal typescript HTTP server.

Latest version **0.1.4** (published 2020-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install finch-min
pnpm add finch-min
yarn add finch-min
bun add finch-min
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2020-05-11 |
| First published | 2020-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BenjaminHsu |
| Maintainers | benjaminhsu0072 |

## Links

- npm: https://www.npmjs.com/package/finch-min
- Repository: https://github.com/BenjaminHsu0072/finch-min
- Homepage: https://github.com/BenjaminHsu0072/finch-min#readme
- Issues: https://github.com/BenjaminHsu0072/finch-min/issues
- npm.io page: https://npm.io/package/finch-min

## Dependencies (1)

- [finch-log](https://npm.io/package/finch-log.md) ^0.1.0

## Recent versions

- 0.1.4 (latest) — 2020-05-11
- 0.1.3 — 2020-04-27
- 0.1.2 — 2020-04-27
- 0.1.1 — 2020-04-07
- 0.1.0 — 2020-04-06

## README

# finch-min
 Minimal Typescript Http Server

#### Features
finch is a simple framework for middleware HTTP services written in Typescript.   
Unlike other middleware systems, this code does not encapsulate the `request`( as
 `IncomingMessage` ) and `response` ( as `ServerResponse`) objects of the node itself.  
You can do whatever you want with native objects.

#### Compare with finch
Remove bundled middleware to keep it simple.

#### Install
` npm install finch-min`

#### Usage

```typescript
import {Finch, responseJson, responseStaticFiles} from "finch-min";

//instance a new finch for your app and name it;
let mike = new Finch();

//set the StaticFile app so mike can search and response files form it
mike.staticDir = "./static";

//Traditional way of using middleware
mike.use('/', (req, res, next) => {
    responseStaticFiles(res,"./static/index.html");
});
mike.use('/hello', (req, res, next) => {
    responseJson(res,{hello:'world'});
});

//start listening the port
mike.listen(3000);
```

#### Structure
The core is very simple and includes : 
* `Finch` : class;
    * `staticDir`
    * `listen(port: number)`
    * `use(handle: string, middleWare: middleWareFunction): void`
    * `all(middleWare: middleWareFunction):void`
* A set of `response` methods;
    * `responseJson(response: ServerResponse, msg: string | object)` 
    * `response404(response:ServerResponse) `
    * `response403(response:ServerResponse)`
    * `responseStaticFiles(res:ServerResponse, staticFilePath:string)`
    * `responseDownloadFile(res:ServerResponse, dfp:string, dfn?:string)`
    * `responseRedirect(response: ServerResponse, url: string)`
* `logger` : method;

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