# m2-nodejs

> The package is provided utilities and facilities for nodejs.

Latest version **1.0.1** (published 2019-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install m2-nodejs
pnpm add m2-nodejs
yarn add m2-nodejs
bun add m2-nodejs
```

## 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.1 |
| Published | 2019-07-04 |
| First published | 2019-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | mirhe |
| Keywords | npm, nodejs, mysql, mongodb, redis, express, koa, m2, m2-nodejs |

## Links

- npm: https://www.npmjs.com/package/m2-nodejs
- Repository: https://github.com/hmiinyu/m2-nodejs
- Homepage: https://github.com/hmiinyu/m2-nodejs#readme
- Issues: https://github.com/hmiinyu/m2-nodejs/issues
- npm.io page: https://npm.io/package/m2-nodejs

## Dependencies (10)

- [mysql](https://npm.io/package/mysql.md) ^2.17.1
- [redis](https://npm.io/package/redis.md) ^2.8.0
- [morgan](https://npm.io/package/morgan.md) ^1.9.1
- [koa-redis](https://npm.io/package/koa-redis.md) ^4.0.0
- [koa-morgan](https://npm.io/package/koa-morgan.md) ^1.0.1
- [http-errors](https://npm.io/package/http-errors.md) ^1.7.3
- [querystring](https://npm.io/package/querystring.md) ^0.2.0
- [connect-redis](https://npm.io/package/connect-redis.md) ^3.4.1
- [express-session](https://npm.io/package/express-session.md) ^1.16.2
- [koa-generic-session](https://npm.io/package/koa-generic-session.md) ^2.0.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-07-04
- 1.0.0 — 2019-06-26

## README

## m2-nodejs

[![](https://img.shields.io/badge/m2--nodejs-v1.0.1-green.svg)](https://github.com/hmiinyu/m2-nodejs.git) <br/>
The package is provided utilities and facilities for nodejs.

### Usage
 - Install
```bash
npm install m2-nodejs
yarn add m2-nodejs
```
### APIs
- mysql Provide nodejs how to connect to mysql
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| connect | func | Get the mysql connection instance for the params **config** | |
| escape | func | Prevent SQL-inject attack to escape the params | |
| execSql | func | Exec the sql statement for the params **connection**, **sql** | |
- redis Provide nodejs how to connect to redis
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| connect | func | Get the redis client instance for the params **config** | |
| setItem | func | Set the item into redis for the params **client**, **key**, **val** | |
| getItem | func | Get the item from redis for the params **client**, **key** | |
| delItem | func | Remove the item from redis for the params **client**, **key** | |
- cookie Provide how to operate cookie in the server
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| getCookieExpire | func | Get the cookie expire time for the params **{type,offset}}** | |
| setServerCookie | func | Set the cookie in the server for the params **res**, **key**, **val**, **options** | |
- http Provide how to http request and response in the server
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| getPostData | func | Get post data via stream for the params **req** | |
| parseQuery | func | Parse query data or the params **req** | |
| parseCookie | func | Parse cookie data for the params **req** | |
| parseSession | func | Parse session data for the params **req**,**redis** | |
- model Provide data response model include SuccessModel, ErrorModel
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| SuccessModel | class | Provide the data model when data will be fetched | |
| ErrorModel | class | Provide the error model when data will be rejected | |
- util Provide node util function in the server
#### 
| prop or func | type | description | example |
| ------------ | ------------ | ------------ | ------------ |
| readline | func | Provide the readline instance based on read stream | |
| writeLog | func | Write the appending log into file | |
| md5 | func | Encrypt the content by md5 | |
| encryptPassword | func | Encrypt the password by md5 and key | |

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