Skip to content
This repository was archived by the owner on Nov 16, 2024. It is now read-only.

kkamara/nodejs-reactjs-boilerplate

Repository files navigation

nodejs-crm5.png

nodejs-crm2.png

nodejs-crm.png

nodejs-reactjs-boilerplate2.png

nodejs-reactjs-boilerplate

(2021) NodeJS, MySQL, Redis, ReactJS.

Supported databases: MySQL, PostgreSQL, SQLite, MariaDB.

Installation

cp .env.example .env
yarn install

Add sequelize args for use with this project.

export SEQUELIZE_ARGS="--config='./config.json' --models-path='src/models' --migrations-path='src/migrations' --seeders-path='src/seeders'"
# Example usage:
# npx sequelize-cli init $SEQUELIZE_ARGS
Sequelize tutorial
# Docs:
#   https://sequelize.org/docs/v6/other-topics/migrations/
# Running a specific database seeder
npx sequelize-cli db:seed --seed 20230814135938-demo-user.js $SEQUELIZE_ARGS
# Creating a model & migration
npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string $SEQUELIZE_ARGS
# Creating a migration
npx sequelize-cli migration:generate --name migration-skeleton $SEQUELIZE_ARGS
# Running migrations
npx sequelize-cli db:migrate $SEQUELIZE_ARGS
# Revert the most recent migration
npx sequelize-cli db:migrate:undo $SEQUELIZE_ARGS
# Revert to a specific migration
npx sequelize-cli db:migrate:undo:all --to XXXXXXXXXXXXXX-create-posts.js $SEQUELIZE_ARGS
# Creating a seed (fake database data) to simulate production environment
npx sequelize-cli seed:generate --name demo-user $SEQUELIZE_ARGS
# Running seeds
npx sequelize-cli db:seed:all $SEQUELIZE_ARGS
# Undo the latest seed
npx sequelize-cli db:seed:undo $SEQUELIZE_ARGS
# Undo all seeds
npx sequelize-cli db:seed:undo:all $SEQUELIZE_ARGS

See package.json for helpful commands related to using the database.

...
"migrate": "npx sequelize-cli db:migrate --config='./config.json' --models-path='src/models' --migrations-path='src/migrations' --seeders-path='src/seeders'",
"migrate:undo": "npx sequelize-cli db:migrate:undo --config='./config.json' --models-path='src/models' --migrations-path='src/migrations' --seeders-path='src/seeders'",
"seed": "npx sequelize-cli db:seed:all --config='./config.json' --models-path='src/models' --migrations-path='src/migrations' --seeders-path='src/seeders'",
"seed:undo:all": "npx sequelize-cli db:seed:undo --config='./config.json' --models-path='src/models' --migrations-path='src/migrations' --seeders-path='src/seeders'"
...

Usage

Run database migrations
yarn migrate
Run database seeders
yarn seed
Run start
yarn start # Runs Start-script `yarn node src/app.js`
# Serves app to http://localhost:3000/.
# Serves api to http://localhost:3000/api/v1.
#   Example api route: http://localhost:3000/api/v1/test.
Reload server on project files change
yarn dev # Runs Dev-script `nodemon src/app.js`
# We can also `APP_ENV=development nodemon src/app.js`.

Using docker?

docker-compose up --build -d

To run api tests

yarn test

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

BSD

About

(Live Link) (2021) With code integration (CI) API testing. NodeJS, MySQL, Redis, ReactJS 16.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages