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`.
- Host: GitHub
- URL: https://github.com/samuelmarks/orm-mw
- Owner: SamuelMarks
- License: apache-2.0
- Created: 2017-08-18T13:48:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-14T01:00:36.000Z (about 2 years ago)
- Last Synced: 2025-01-28T04:32:00.615Z (over 1 year ago)
- Language: TypeScript
- Size: 692 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
orm-mw
======
[](https://opensource.org/licenses/Apache-2.0)

[](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.