Take advantage of typescript with express js, sequelize, sequelize-cli, socket.io yarn and built-in tasks
These dependencies must be installed globally as the initial step to configure the project environment.
- yarn
- typescript
So you must follow the next steps in order to correctly initialize this project.
You can achieve this by executing the following command:
Notice: You must prepend the
sudocommand in case you are running on a UNIX-based system.
npm i -g yarn@1.3.2 typescript@2.6.1
You must execute the yarn install command in order to install this project's dependencies.
Provide required config files by typing in shell following command:
yarn provision
- ./.env [ Main environment file ].
- ./forever.json [ forever settings for execution in production mode ]
- ./persistence/config.js [ Database config settings for sequelize-cli ]
In this file (./.env) is mandatory to add the main execution environment settings such as Environment, Port, Database configurations, as well as other environment configurations.
Provide the Database structure by typing the following shell command:
yarn init-persistence
Script Explanation: This command will try to create ONE database, corresponding to the prefix of
NODE_ENVand to one of the following environment variablesDEVELOPMENT_DB_DATABASE,TEST_DB_DATABASE,PRODUCTION_DB_DATABASE, which were defined in step named: Update .env file; Subsequently will create and/or update the structure of that database according to the schematic definitions described in the files of the directory./migrations/, then will execute initial data population by running described by files under./seeders/directory.
You can customize the production options by updating the ./forever.json file with your own production settings.
If you have successfully arrived at this step, you can launch the project for the first time by typing the following command in the terminal:
yarn start
Notice: some of the following scripts may accept name or attributes parameters and you must provide them with the following syntax:
yarn [script] --mod=rest-handler,controller,poco,repository,model --name=some-name --attributes=attribute1:dataType,attrib2:dataType
startTry to Run cleanup, lint, build-ts, serve-nodemon scripts sequentially.developRun cleanup lint build-ts serve-development script sequentially (shall continue even if error was returned).productionTry to Run cleanup lint _build-t_s serve-prod scripts sequentially.build-tsRun Typescript Transpile.watch-tsRun Typescript Transpile and keep watching for changes in ./src/ folder.lintExecutes tslint according to tslint.json, tsconfig.json config files.cleanupRun parallel tasks clean-logs and clean-transpilated.clean-logsDelete forever log files ./logs/**.log.clean-transpilatedDelete transpilated files.provisionRun parallel provide-env, provide-forever-config, provide-dbconfig, scripts.provide-dbconfigCreates the database config settings for sequelize-cli in ./persistence/config.js.provide-envCreates the main Environment file in ./.env.provide-forever-configCreates the forever execution config file in ./forever.json.init-persistenceRun create-database, run-migrations, run-seeds scripts sequentially.generatehelps you create a new 'rest-handler', 'controller', 'poco', 'repository', 'model'; accepting the parameters --mod --name --attributes.create-controllerCreate A new controller according accepting: --name and --attributes parameters.create-modelCreate A new model according accepting: --name and --attributes parameters.create-pocoCreate A new poco according accepting: --name and --attributes parameters.create-repositoryCreate A new repository according accepting: --name and --attributes parameters.create-rest-handlerCreate A new rest handler according accepting: --name and --attributes parameters.create-databaseShorthand for node [sequelize-cli-Path]/sequelize db:create command.drop-databaseShorthand for node [sequelize-cli-Path]/sequelize db:drop command.run-migrationsShorthand for node [sequelize-cli-Path]/sequelize db:seed:all command.revert-migrationsShothand for node [sequelize-cli-Path]/sequelize db:seed:undo:all command.run-seedsShorthand for node [sequelize-cli-Path]/sequelize db:migrate command.revert-seedsShothand for node [sequelize-cli-Path]/sequelize db:migrate:undo:all command.serve-developmentRun parallel serve-nodemon-debug, watch-ts scripts.serve-nodemonLaunch transpilated files using the "nodemon" module watching changes in ./.env and ./dist/.serve-nodemon-debugSimilar to the serve-nodemon script but with the --inspect flag that adds the debugging capability.serve-prodLaunch the transpilated service using the "forever" module.sequelizeShorthand for node [sequelize-cli-Path]/sequelize cli.nodemonShorthand for node [nodemon-cli-Path]/nodemon cli.foreverShorthand for node [sequelize-cli-Path]/forever cli.