Skip to content

Express sequelize rest boilerplate with typescript for working with existing db (import models) powered by webpack

Notifications You must be signed in to change notification settings

idolgoff/express-sequelize-rest-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

npm run server:dev

For dev build with webpack

npm run dev

For production build with webpack

npm run build

Sequelize

Import model from existing database

sequelize-auto -h <host> -d <database> -u <user> -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

 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;
 };

About

Express sequelize rest boilerplate with typescript for working with existing db (import models) powered by webpack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published