Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dugajean/tsexpress-starter-typeorm
TypeORM integration for TSExpress Starter
https://github.com/dugajean/tsexpress-starter-typeorm
Last synced: about 1 month ago
JSON representation
TypeORM integration for TSExpress Starter
- Host: GitHub
- URL: https://github.com/dugajean/tsexpress-starter-typeorm
- Owner: dugajean
- License: mit
- Created: 2019-08-20T16:34:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-20T18:51:05.000Z (over 5 years ago)
- Last Synced: 2024-12-11T00:42:06.815Z (about 2 months ago)
- Language: TypeScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeORM for TSExpress Starter
Using TypeORM with TSExpress starter comes with a few helper classes that may help you interacting with your database.
Two subscribers are provided with this package:
1. `InsertStatus` so that your responses return a 201 status code, indicating a new resource.
2. `EntityValidation` so when you use the [`class-validator`](https://github.com/typestack/class-validator) package in your entity, we return with a 400 status and a proper failure message.## Getting started
First install this package, TypeORM and class-validator:
```bash
yarn add @tsexpress-starter/typeorm typeorm class-validator mysql
```> **Note!** You must edit your `.env` file with the necessary database information.
In your `server.ts` file, add the following lines:
```javascript
// src/server.ts
// ...
import { connect } from '@tsexpress-starter/typeorm';const app = new Application(__dirname, express());
app.beforeRoutes = () => connect(app);
app.start();
```And you're done!
## License
TSExpress Starter is released under the [the MIT License](LICENSE).