Skip to content
 
 

Repository files navigation

HowTo Website

  1. Run and seed the Mongo database with sample data.
  2. Build and run the Backend API.
  3. Build and run the Frontend.
  4. Test the API calls to the database.

Database setup guide

Starting from the repository root directory, setup and run the Mongo database.

Start the MongoDB Database

Select your operating system to start the MongoDB database:

Windows

Run MongoDB database on Windows.

. ./startDbServer.cmd
Linux/Mac

Make the script executable and run MongoDB database on Linux/Mac.

chmod +x start.DbServer.sh
./start.DbServer.sh

Connect and Populate the database

Open a new terminal and connect to the database using the database client.

Select your operating system to start the MongoDB client:

Windows

Run the database client on Windows.

mongosh --port 3000 --authenticationDatabase admin
Linux/Mac

Run the database client on Linux/Mac.

mongo --port 3000 --authenticationDatabase admin

Once connected to the database, run the following commands to populate the demo data.

load ('expressServer/src/createDB/createSampleData.js');

show dbs
use tutorialPlatform
show collections
db.tutorials.find()
db.comments.find()

load ('expressServer/src/createDB/createAdminUser.js');
show users
exit

Build and run the Backend and Frontend

This section combines the Backend API and Frontend sections.

Starting from the repository root directory, run the following commands to install npm packages, compile the node server, compile the angular server, run the backend and frontend.

npm install
npm run build
npm run start

Backend API

Starting from the repository root directory, install npm packages, compile the node server, run the unit tests, and run the node server.

Build

The following commands installs the npm packages, then compiles the node server and copy the pages to out/src/pages.

npm install

npm run build --workspace=expressServer

Run Test

There are both unit tests and integration tests for the backend API.

Unit Test

To run the unit tests, this step assumes the npm packages were installed using npm install in the previous step.

npm run test --workspace=expressServer

Integration Test End-to-End (E2E)

To run the integration tests, this step assumes the database and API server are running.

npm run e2etest --workspace=expressServer

Manual API Calls using Postman

To test the API calls to the database, this step assumes the database and API server are running.

Tutorial - GET all / POST - /app/tutorials

Tutorial - GET by Id - /app/tutorials/{tutorialId}

Comments - GET all / POST - /app/comments

Comments - GET by Id - /app/comments/{commentId}

Run the Server

The following command runs the node server on port 8080.

npm run start --workspace=expressServer

Frontend

Starting from the repository root directory, install npm packages, compile the Angular server, run the unit tests, and run the Angular server.

Build the frontend

The following commands installs the npm packages, then compiles the server.

npm install

npm run build --workspace=tutorial-application

Run frontend Unit Test

To run the unit tests, this step assumes the npm packages were installed using npm install in the previous step.

npm run test --workspace=tutorial-application

Run the Frontend

The following command runs the frontend server.

npm run start --workspace=tutorial-application

Manual End-To-End Test Guide

To test the frontend, backend, and the database, this step assumes the frontend, backend, and database are running.

Hifi Screen - Home Page

Clean

The following command removes the database files, the node_modules directory, and the compiled node server.

npm run clean --workspace=expressServer

Install MongoDB shell

Select your operating system to install the MongoDB shell.

Windows

Install the MongoDB shell on Windows using winget.

winget install -e --id MongoDB.Shell
Linux/Mac

Install the MongoDB shell on Linux/Mac using brew.

brew install mongosh

Connect to the Azure Mongo database

mongosh "mongodb+srv://tutorialplatformcluster.utubbq2.mongodb.net/" --apiVersion 1 --username dbAdmin --password test

Azure

git remote remove azure
git remote add azure https://tutorialplatformmac-f0e4a3faemd4b4e5.scm.westus-01.azurewebsites.net:443/tutorialplatformmac.git
git push azure personal/ansantan/Step-Up-PR5:master

Project Structure

The expressServer project uses a standard Node.js REST API project structure.

Repository-Root/
│
├── expressServer/ (project-root)
│   ├── node_modules/
│   ├── out/ (The compiled server runs from the out directory.)
│   │   ├── src/
│   │       ├── pages/
│   │       ├── App.js
│   │       ├── AppServer.js
│   ├── src/
│   │   ├── model/
│   │       ├── example.model.ts
│   │   ├── routes/
│   │       ├── example.route.ts
│   │   ├── App.ts
│   │   └── AppServer.ts
│   ├── test/
│   │   ├── unit/
│   │   ├── integration/
│   ├── package.json
│   └── tsconfig.json
│
├── tutorial-application/ (project-root)
│   ├── public/
│   ├── src/
│   │   ├── app/
│   ├── package.json
│   └── tsconfig.json
│
├── package.json
├── start.DbServer.cmd
├── start.DbServer.sh
├── startDbClient.admin.cmd
├── startDbClient.PopulateSampleData.cmd
├── .gitignore
└── README.md

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages