- Node.js >=16.17.0
- NPM >=8.15.0
- MySQL
-
Clone the application from the repository.
-
Install dependencies:
npm ci
-
Create the .env file by copying the .env.example file:
cp .env.example .env
-
Specify the port, JWT key and database URL in the .env file.
-
Create database:
sudo mysql -uuser -ppass > CREATE DATABASE `fastify-articles-app` CHARACTER SET utf8 COLLATE utf8_general_ci; > exit
Replace user and pass with your username and password, respectively.
-
Run migrations and seeds:
npm run migrate npm run db:seed
The next steps will be different for development and production modes.
-
Install nodemon globally:
sudo npm i -g nodemon
-
Launch the application:
npm run start:dev
-
Install pm2 globally:
sudo npm i -g pm2
-
Launch the application:
npm run start:prod
-
Create the .env.test file by copying the .env.example file:
cp .env.example .env.test
-
Specify the port, JWT key and database URL in the .env.test file.
-
Create database:
sudo mysql -uuser -ppass > CREATE DATABASE `fastify-articles-app_test` CHARACTER SET utf8 COLLATE utf8_general_ci; > exit
Replace user and pass with your username and password, respectively.
-
Run tests:
npm run test