An open API service indexing awesome lists of open source software.

https://github.com/samuelmarks/orm-mw

Generic--connect, restify, express--middleware adding connection to 0-k ORMs to a `.getDb` method on `req`.
https://github.com/samuelmarks/orm-mw

Last synced: 3 months ago
JSON representation

Generic--connect, restify, express--middleware adding connection to 0-k ORMs to a `.getDb` method on `req`.

Awesome Lists containing this project

README

          

orm-mw
======
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![npm-publish](https://github.com/SamuelMarks/orm-mw/workflows/npm-publish/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@offscale/orm-mw.svg)](https://www.npmjs.com/package/@offscale/orm-mw)

Generic--connect, restify, express--middleware adding connection to 0-k ORMs to a `.getDb` method on `req`.

Supported ORMs:

- [Sequelize](https://github.com/sequelize/sequelize)
- [TypeORM](https://github.com/typeorm/typeorm)
- [Waterline](https://github.com/balderdashy/waterline)

Supported cursors:

- [Redis](https://github.com/luin/ioredis)

## Install

npm i -S @offscale/orm-mw

## Usage

import { ormMw } from '@offscale/orm-mw';

server.use(ormMw(/*IOrmMwConfig*/));

### Explicit cleanup

Essentially only useful for tests:

import { tearDownConnections } from '@offscale/orm-mw';

tearDownConnections(/*ormsInArgs*/, err => {
if (err != null) throw err;
});

## Configuration

See `IOrmMwConfig` interface in [orm-mw.d.ts](https://github.com/SamuelMarks/orm-mw).

## Extending

Adding a new ORM? - Expand the `IOrmMwConfig` interface, and add a new short-function that implements it. See others for reference.

### Development setup

Install the latest Node.JS, `npm i -g typings typescript`, then:

git clone https://github.com/SamuelMarks/orm-mw
cd orm-mw
typings i
npm test

## Future work

- Add more ORMs and cursors

## License

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or )

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.