https://github.com/idolgoff/express-sequelize-rest-boilerplate
Express sequelize rest boilerplate with typescript for working with existing db (import models) powered by webpack
https://github.com/idolgoff/express-sequelize-rest-boilerplate
api express finale rapid-development rest sequelize sequelize-auto typescript webpack
Last synced: 2 months ago
JSON representation
Express sequelize rest boilerplate with typescript for working with existing db (import models) powered by webpack
- Host: GitHub
- URL: https://github.com/idolgoff/express-sequelize-rest-boilerplate
- Owner: idolgoff
- Created: 2017-12-07T06:18:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-07T07:06:27.000Z (over 8 years ago)
- Last Synced: 2024-04-14T09:03:17.032Z (about 2 years ago)
- Topics: api, express, finale, rapid-development, rest, sequelize, sequelize-auto, typescript, webpack
- Language: TypeScript
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Server side boilerplate with TypeScript, Sequelize...
This is a boilerplate for development rest api using existing database
It allows to generate models from db and use them after with minimum hand correction
It uses express, finale, sequelize, sequelize-auto, typescript
Powered by webpack or ts-node-dev with server auto-reload
## Structure
```bash
> ./_import_models/ - auto imported models
> ./db/ - models after hand correction
> ./rest.ts - apply finale-rest
> ./index.ts - main file
```
## Scripts
For everyday development and live reloading
```bash
npm run server:dev
```
For dev build with webpack
```bash
npm run dev
```
For production build with webpack
```bash
npm run build
```
## Sequelize
Import model from existing database
```bash
sequelize-auto -h -d -u -x [password] -p [port] --dialect [dialect] -c [/path/to/config] -o [/path/to/models] -t [tableName] -C
```
## Auto import
Import works pretty well but after that be careful with table def.types
Adding _as_ lets it work with ts-node-dev server without errors
```typescript
export const getModels = function(seq:sequelize.Sequelize):ITables {
const tables:ITables = {
spCats: seq.import(path.join(__dirname, './sp_cats')) → as def.spCatsModel ←,
spPurchases: seq.import(path.join(__dirname, './sp_purchases')) → as def.spPurchasesModel ←,
};
return tables;
};
```