Skip to content

The backend of the QuizTest Website was built using the Nest.js framework

Notifications You must be signed in to change notification settings

katelovestocode/backend-internship

Repository files navigation

Backend project using Nest.js

1. Prerequisites:

Before running the application, make sure you have the following dependencies installed:

  • Node.js: Download and Install Node.js
  • npm (Node Package Manager): It comes with Node.js, so no need to install separately.

2. Installation:

Clone the repository and install project dependencies.

git clone https://github.com/katelovestocode/backend-internship.git
cd your-project-directory
npm install

3. Running the Application:

Start your Nest.js application on port 3002 using the following command:

npm run start:dev

4. Environment Configuration:

To configure your Nest.js application, you will need an environment (.env) file. This file is used to store sensitive data and configuration settings. Here's how you can set up your .env file:

  1. Create an .env file in the root of your project directory.

  2. Define your environment variables in the .env file. You need to specify values for variables like PORT, database connection URLs, API keys, and other configuration settings. For example:

    PORT=3002

5.Prerequisites to run the Application in Docker

Before you can run the application in Docker, make sure you have the following dependencies installed on your machine:

6. Build the Docker image using the provided Dockerfile:

FOR Tests:

docker build -t docker-image-test --progress=plain --no-cache --target test .

FOR Production:

docker build -t docker-image-prod --progress=plain --no-cache --target prod .

7. Run the Application

Now that you have built the Docker image, you can run the application within a Docker container. Use the following command:

FOR Tests:

docker run -d -p 3002:3002 --name docker-container-test docker-image-test

FOR Production:

docker run -d -p 3002:3002 --name docker-container-prod docker-image-prod

8. Accessing the Application

Once the container is up and running, you can access the application in your web browser by navigating to:

http://localhost:3002

9. Stopping and Cleaning Up

To stop the Docker container, use the following command:

docker stop docker-container-prod
docker stop docker-container-test

To remove the Docker container and image when you're done, run:

docker rm docker-container-prod
docker rmi docker-container-prod

docker rm docker-container-test
docker rmi docker-container-test

10. Generating Migration

To create a new database migration, use the following command:

npm run migration:generate -- db/migrations/<migration-name>

Replace with a descriptive name for your migration. This will generate the necessary files for applying changes to the database schema.

11. Run Migration

Once you've generated a migration, you can apply the changes to your database by running the migration:

npm run migration:run

12. Revert Migration

If you need to revert a migration (roll back changes to the previous state), you can use the following command:

npm run migration:revert

This will undo the most recent migration and revert your database schema to the previous state.

About

The backend of the QuizTest Website was built using the Nest.js framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages