# blueskyfish-express-mysql

> A database connector and middleware to mysql server for micro services

Latest version **0.3.5** (published 2018-05-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install blueskyfish-express-mysql
pnpm add blueskyfish-express-mysql
yarn add blueskyfish-express-mysql
bun add blueskyfish-express-mysql
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.5 |
| Published | 2018-05-11 |
| First published | 2018-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 53.7 KB |
| Known vulnerabilities | 0 (+13 in 3 direct dependencies) |
| Install scripts | yes |
| Author | BlueSkyFish |
| Maintainers | blueskyfish |
| Keywords | express, mysql, commons, micro service, http, https, blueskyfish |

## Links

- npm: https://www.npmjs.com/package/blueskyfish-express-mysql
- Repository: https://github.com/blueskyfish/blueskyfish-express-mysql
- npm.io page: https://npm.io/package/blueskyfish-express-mysql

## Dependencies (6)

- [mysql](https://npm.io/package/mysql.md) 2.15.0
- [lodash](https://npm.io/package/lodash.md) 4.17.10
- [moment](https://npm.io/package/moment.md) 2.22.1
- [express](https://npm.io/package/express.md) 4.16.3
- [typescript](https://npm.io/package/typescript.md) 2.8.3
- [blueskyfish-express-commons](https://npm.io/package/blueskyfish-express-commons.md) 0.3.4

## Recent versions

- 0.3.5 (latest) — 2018-05-11
- 0.3.4 — 2018-05-11
- 0.3.3 — 2018-05-11
- 0.3.2 — 2018-05-10
- 0.3.1 — 2018-05-02
- 0.3.0 — 2018-05-02
- 0.2.1 — 2018-05-01
- 0.1.0 — 2018-04-20
- 0.0.13 — 2018-04-13
- 0.0.12 — 2018-04-13
- 0.0.11 — 2018-03-20
- 0.0.10 — 2018-02-22
- 0.0.9 — 2018-02-18
- 0.0.8 — 2018-02-13
- 0.0.7 — 2018-02-13
- … 6 more at https://npm.io/package/blueskyfish-express-mysql/versions

## README

![BlueSkyFish Express MySql](logo.png)

# BlueSkyFish Express MySql

> A database connector and middleware to mysql server for micro services

A middleware for the express microservices

**Breaking Change** switch to [yarn][yarn].

**Example**

```js
import * as express from 'express';
import { Http, Env } from 'bluesykfish-express-commons';

const app = express();

const dbConfig = {
    host: Env.fromEnv('DB_HOST') || 'localhost',
    port: Env.fromEnvNumber('DB_PORT', 3306),
    user: Env.fromEnv('DB_USER') || 'root',
    database: Env.fromEnv('DB_DATABASE'),
    password: Env.fromEnv('DB_PASSWORD')
};

app.use(withDB(dbConfig));

app.get('/users', async (req, res) => {
    const db = req.dbConn;
    const users = await db.query('SELECT * FROM users WHERE status = {status}', { status: 'ok'});
    Http.sendData(res, users);
});
```

## Requirements

* [NodeJS][nodejs] Version 8.x or higher.
* [Yarn][yarn]
* [Typescript][typescript] Version 2.6.2 or higher.
* [Express][express] Version 4.16 or higher
* [Node MySQL][node-mysql] Version 2.15.0 or higher.
* [BlueSkyFish Express Commons][bsf-ec].

Global installed typescript. `npm install --global typescript`.

The library is written in [Typescript][typescript]. During the installation of the library it will be compiled into Javascript **ES2015** modules.


## Installation

```bash
$ npm install -S blueskyfish-express-mysql
```


## Dependencies

All libraries from **blueskyfish-express-*** and depended applications should use the same version of the dependencies node modules.

| name                    | Version
|-------------------------|-------------
| `express`               | `4.16.3`
| `lodash`                | `4.17.10`
| `moment`                | `2.22.1`
| `mysql`                 | `2.15.0`
|-------------------------|-------------
| `mocha`                 | `5.1.1`
| `ts-node`               | `6.0.3`
| `typescript`            | `2.8.3`


## History

| Version    | Date       | Description
|------------|:----------:|--------------------------------------------
| `0.3.3`    | 2018-05-11 | update libraries.
| `0.3.2`    | 2018-05-10 | improve db error message. clean unused constants
| `0.3.1`    | 2018-05.02 | adjust tsc options
| `0.2.1`    | 2018-05-01 | switch to yarn
| `0.1.0`    | 2018-04-20 | add querySingleton method. improve the js documentation
| `0.0.13`   | 2018-04-13 | adjust the version of the depended node modules.
| `0.0.11`   | 2018-03-20 | NULL is a sql NULL
| `0.0.10`   | 2018-02-22 | adjust the version of the depended node modules.
| `0.0.9`    | 2018-02-18 | adjust the version of blueskyfish-express-commons
| `0.0.8`    | 2018-01-13 | log db configuration only in Trace log level
| `0.0.4`    | 2018-01-24 | get database connection from express request.
| `0.0.2`    | 2018-01-24 | fixed the typescript error for express type.
| `0.0.1`    | 2018-01-21 | Initial the library. It is extract from my other internal projects.


## License

```text
The MIT License

Copyright 2018 BlueSkyFish

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```


[nodejs]: https://nodejs.org/en/
[typescript]: https://www.typescriptlang.org/
[express]: https://expressjs.com/
[node-mysql]: https://github.com/mysqljs/mysql
[bsf-ec]: https://github.com/blueskyfish/blueskyfish-express-commons
[yarn]: https://yarnpkg.com/

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