gbili / bp-nomonychas-reama

Boilerplate Node Mocha NY Chai Semantic-Realease Express Apollo MySQL Auth

Home Page:https://guillermo.at

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boilerplate NoMoNyChaS-REAMA

code coverage

A working base setup in August 2019 using Nodejs, Mocha, Nyc, Istanbul, Chai, Semantic-Release, Travis-ci, Codecov.io, Apollo, Express, Mysql and Authentication (with JWT: json web tokens)

Note: About Travis and Codecov.io, if you are developing a private project, it may make sense to switch to other services like CircleCi and something to replace codecov.io if you are on a tight budget.

Usage

Create a repo on github.com / bitbucket.com and use that name in place of your-project-name. Clone this repo into your computer

$ git clone git@github.com:gbili/bp-nomonychas-reama your-project-name
$ git remote remove origin
$ git remote add origin git@github.com:your-name/your-project-name

Then change the name.

vim package.json
:.,$s/bp-nomonychas-reama/your-project-name/g <enter>
:.,$s/gbili/your-name/g <enter>
:wq

Adapt the code in src/ and test/

Create a database and add the connection settings to the .env file like so:

DB_HOST=localhost
DB_USER=myuser
DB_PASSWORD=mypwd
DB_NAME=dbname

This will let the database undump command create the appropriate table. Of course you should then adapt the models and schema.sql table definitions to your own domain. For your tests you should create a separate database and pass the credentials through the .env file as well:

TEST_DB_HOST=localhost
TEST_DB_USER=test_user
TEST_DB_PASSWORD=test_password
TEST_DB_NAME=dbname_test

To create the database and users in MySQL run:

$ mysql -u root -p
$ ***** # enter your password

$ mysql> create database dbname_test;
$ mysql> create user 'test_user'@'localhost' identified by 'test_password';
$ mysql> ALTER USER 'test_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test_password'
$ mysql> grant all on dbname_test.* to 'user_test'@'localhost';
$ mysql> flush privileges;

Then initialize and build

npm init
npm install
npm run build

Once installed, you can run:

npm run db:undump

Which should create the required tables defined in schema.sql.

Finally make commit and push changes

git commit -Am "feat: setup base project"
git push origin master

About

Boilerplate Node Mocha NY Chai Semantic-Realease Express Apollo MySQL Auth

https://guillermo.at


Languages

Language:JavaScript 98.9%Language:TSQL 1.1%