This is the Fragments back-end microservice project. This project serves as the foundation for my work in the upcoming weeks. Below instructions to set up development environment, run the server, and leverage various scripts.
I had to make sure to have the following software installed and working on my development machine:
- Node.js (LTS version)
- VSCode with the following extensions:
- ESLint
- Prettier - Code Formatter
- Code Spell Checker
- Git CLI
- Curl
- WSL2 and Windows Terminal (for Windows)
- I created a private GitHub repo named
fragments
. - I cloned
fragments
repo to my local machine. - Then navigated to the cloned repo:
cd fragments
.
- Initialize the project as an npm project:
npm init -y
. - Open the project in VSCode:
code .
. - Modify the
package.json
file as described in the instructions. - Run
npm install
to validate and install dependencies. - Commit the changes to git:
git add package.json package-lock.json
andgit commit -m "Initial npm setup"
.
- Install Prettier as a Development Dependency:
npm install --save-dev --save-exact prettier
. - Create
.prettierrc
and.prettierignore
files as described in the instructions. - Install the Prettier - Code Formatter VSCode Extension.
- Create a
.vscode/settings.json
file with the provided settings. - Commit the changes to git:
git add .prettierrc .prettierignore .vscode/settings.json
andgit commit -m "Add prettier"
.
- Install ESLint:
npm install --save-dev eslint
. - Run
npx eslint --init
and configure ESLint as described in the instructions. - Install the ESLint VSCode Extension.
- Add a lint script to
package.json
. - Run ESLint and commit the changes to git:
git add .eslintrc.js package-lock.json package.json
andgit commit -m "Add eslint"
.
- Create a
src/logger.js
file with the provided content. - Run
git add src/logger.js
andgit commit -m "Add pino logger"
.
- Install required packages for Express:
npm install --save express cors helmet compression
. - Create a
src/app.js
file with the provided content. - Run
git add src/app.js
andgit commit -m "Initial work on express app"
.
- Install the
stoppable
package:npm install --save stoppable
. - Create a
src/server.js
file with the provided content. - Run
git add src/server.js
andgit commit -m "Initial work on express server"
.
Run ESLint to check for code style and potential issues:
npm run lint
Run the server in production mode:
npm start
Run the server with nodemon, watching for changes:
npm run dev
Run the server with nodemon and enable the Node.js inspector on port 9229:
npm run debug