sequelize-ts-boilerplate
v0.0.40
Published
A REST API scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema design
Downloads
15
Maintainers
Readme
sequelize-ts-boilerplate
A REST API / Data-Access-Layer scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema.
npm install -g sequelize-ts-boilerplate
sequelize-ts-boilerplate your-config.json
JSON configuration file your-config.json
will default to config.json
if not present as arg.
npm install
--> tsc
--> npm run dev
If you are looking for an enterprise framework, nest is highly recommended. Angular and Java Spring developers will feel at home.
This tool is specifically designed to scaffold a routes -> controllers -> services -> daos
project architecture using Sequelize, Typescript, and Sequelize-Typescript ORM while trying to maintain a Node.js feel.
Implementation
config.json
file:
{
"ENV": "dev", // make name of ENV a property in DATABASE_CONNECTION_SETTINGS
"DATABASE_CONNECTION_SETINGS": {
"dev": {
"host": "your-host-url",
"db": "your-db-name",
"username": "your-username",
"password": "your-password",
"dialect": "mysql | mssql",
"port": "3306"
}
},
"ORM_GENERATE": {
"caseSensitiveProps": [],
"skipTables": [],
"manyToManyIdentifiers": ["map"],
"lookup": { // creates transient properties for CONSTANT | ENUM style table
"tableName": "Lookup",
"identifier": "lkp",
"sliceOut": "Oid"
},
"pkIdentifier": "id",
"path": {
"ormWrapper": "optional/path/to/generated/orm/wrapper/file.ts",
"daos": "optional/path/to/generated/daos/folder",
"services": "optional/path/to/generated/services/folder",
"interface": "optional/path/to/generated/interface/file.ts"
}
},
"CRUD_GENERATE": {
"shouldGenerate": true,
"framework": "express",
"ignoreTables": []
}
}
Folders generated:
- Controllers
- Services
- DAOS
Files generated:
- all Node framework plumbing
- interfaces file containing all database entities (for use on front-end)
- ORM wrapper (provides namespace, intellisense, etc for accessing DAOS)
- Controller and Service files will not be overwritten on subsequent generations. DAOS will be regenerated every time.
TODO
- Better docs and readme!
- Support other Node.js frameworks - Hapi, Koa, etc. (currently only Express)
- Support other SQL dialects (currently, the data-access layer only supports SQL Server and MySQL)
- Various opt-in packages - i.e Auth, ACL, more complex CRUD endpoints, better support handling complex data table relationships (many:many), etc
- CLI tool
- Better package.json generation
A quick note: this was made quickly and without tests. I am happy to continue contributing and fixing issues, however, I enjoy doing things other than coding in my free time as well :)... contributions welcome.
Github: https://github.com/dlemburg/sequelize-ts-boilerplate