Skip to content

Take advantage of typescript with express js, sequelize, sequelize-cli, socket.io yarn and built-in tasks

License

Notifications You must be signed in to change notification settings

virgenherrera/nobaty-sql

Repository files navigation

nobaty-sql

Take advantage of typescript with express js, sequelize, sequelize-cli, socket.io yarn and built-in tasks

Project Setup

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.

Step 0: Install global dependencies

You can achieve this by executing the following command:

Notice: You must prepend the sudo command in case you are running on a UNIX-based system.

  • npm i -g yarn@1.3.2 typescript@2.6.1

Step 1: Install project dependencies

You must execute the yarn install command in order to install this project's dependencies.

Step 2: Generate environment configuration files

Provide required config files by typing in shell following command:

  • yarn provision

This will create the following environment files:

  • ./.env [ Main environment file ].
  • ./forever.json [ forever settings for execution in production mode ]
  • ./persistence/config.js [ Database config settings for sequelize-cli ]

Step 3: Update .env file

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.

Step 4: Initialize-Provide Data Persistence

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_ENV and to one of the following environment variables DEVELOPMENT_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.

Step 5 (optional):

You can customize the production options by updating the ./forever.json file with your own production settings.

Final Step: First run

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

Available script Description

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

The following is a list of available yarn/npm scripts and a brief description:

  • start Try to Run cleanup, lint, build-ts, serve-nodemon scripts sequentially.
  • develop Run cleanup lint build-ts serve-development script sequentially (shall continue even if error was returned).
  • production Try to Run cleanup lint _build-t_s serve-prod scripts sequentially.
  • build-ts Run Typescript Transpile.
  • watch-ts Run Typescript Transpile and keep watching for changes in ./src/ folder.
  • lint Executes tslint according to tslint.json, tsconfig.json config files.
  • cleanupRun parallel tasks clean-logs and clean-transpilated.
  • clean-logs Delete forever log files ./logs/**.log.
  • clean-transpilated Delete transpilated files.
  • provision Run parallel provide-env, provide-forever-config, provide-dbconfig, scripts.
  • provide-dbconfig Creates the database config settings for sequelize-cli in ./persistence/config.js.
  • provide-env Creates the main Environment file in ./.env.
  • provide-forever-config Creates the forever execution config file in ./forever.json.
  • init-persistence Run create-database, run-migrations, run-seeds scripts sequentially.
  • generate helps you create a new 'rest-handler', 'controller', 'poco', 'repository', 'model'; accepting the parameters --mod --name --attributes.
  • create-controller Create A new controller according accepting: --name and --attributes parameters.
  • create-model Create A new model according accepting: --name and --attributes parameters.
  • create-poco Create A new poco according accepting: --name and --attributes parameters.
  • create-repository Create A new repository according accepting: --name and --attributes parameters.
  • create-rest-handler Create A new rest handler according accepting: --name and --attributes parameters.
  • create-database Shorthand for node [sequelize-cli-Path]/sequelize db:create command.
  • drop-database Shorthand for node [sequelize-cli-Path]/sequelize db:drop command.
  • run-migrations Shorthand for node [sequelize-cli-Path]/sequelize db:seed:all command.
  • revert-migrationsShothand for node [sequelize-cli-Path]/sequelize db:seed:undo:all command.
  • run-seeds Shorthand for node [sequelize-cli-Path]/sequelize db:migrate command.
  • revert-seeds Shothand for node [sequelize-cli-Path]/sequelize db:migrate:undo:all command.
  • serve-development Run parallel serve-nodemon-debug, watch-ts scripts.
  • serve-nodemon Launch transpilated files using the "nodemon" module watching changes in ./.env and ./dist/.
  • serve-nodemon-debug Similar to the serve-nodemon script but with the --inspect flag that adds the debugging capability.
  • serve-prod Launch the transpilated service using the "forever" module.
  • sequelize Shorthand for node [sequelize-cli-Path]/sequelize cli.
  • nodemon Shorthand for node [nodemon-cli-Path]/nodemon cli.
  • forever Shorthand for node [sequelize-cli-Path]/forever cli.

About

Take advantage of typescript with express js, sequelize, sequelize-cli, socket.io yarn and built-in tasks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published