0.1.4 • Published 5 years ago

@tsexpress-starter/typeorm v0.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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 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:

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:

// 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.