Git Product home page Git Product logo

web_programming_project's Introduction

Web Programming Project

This is a Web Programming project using Node.js and MongoDB, designed to run in a Docker container.

Project Setup

Follow these steps to set up and run the project:

Prerequisites

Cloning the Repository

First, clone the repository to your local machine:

git clone https://github.com/your-username/Web_Programming_Project.git
cd Web_Programming_Project

Build and Run the Containers

Build the docker and run the containers

docker-compose up --build

This command will build the Docker image and start both the application and the MongoDB container. The Node.js application will be accessible at http://127.0.0.1:9000.

Additional Notes

Environment Variables

Ensure you have a .env file in the root of the project with the following contents:

PORT=9000
MONGODB=mongodb://mongo:27017/pizzaAPI
SECRET_KEY=a7db7ashd7ashd7ahsd7ashd7ashd7hasd7g2367f4e219er
ACCESS_KEY=klcdbg3of78hrovi-+fdgfdb-*gfd/bc32
ACCESS_EXPIRES=30m
REFRESH_KEY=drjh23rgoh9856-+543y647*/brte/vfdh654*
REFRESH_EXPIRES=3d
PAGE_SIZE=25

Accessing the Application

Open your web browser and go to

http://localhost:9000

MongoDB

The MongoDB instance will be accessible inside the Docker network at mongodb://mongo:27017/pizzaAPI.

Stopping the Containers

To stop the containers, press Ctrl+C in the terminal where the containers are running. Alternatively, you can use the following command in another terminal:

docker-compose down

Testing the API with Thunder Client

Install Thunder Client Extension:

  • Open Visual Studio Code.
  • Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
  • Search for "Thunder Client" and click "Install".

Create a New Request:

  • Open Thunder Client by clicking on the Thunder Client icon in the Activity Bar.
  • Click on "New Request".
  • Select the request method (POST) and enter the URL (http://127.0.0.1:9000/users).

Set Request Headers and Body:

  • Headers:

    • Click on the "Headers" tab and add the following key-value pair:
      • Key: Content-Type
      • Value: application/json
  • Body:

    • Click on the "Body" tab and select "JSON".

    • Enter the following JSON data for a user registration request:

      {
        "username": "testuser",
        "password": "Test?123",
        "email": "[email protected]"
      }

Send the Request:

  • Click the "Send" button to send the request.
  • View the response in the "Response" section.

Viewing user information with user id

Copy the User id from the response and use it to view user information.

Set Request Headers and Body:

  • Body:

    • Click on the "Body" tab and select "JSON".

    • Enter the following JSON data for a user registration request:

      {
        "username": "testuser",
        "password": "Test?123",
        "email": "[email protected]"
      }

With this route you can try other get and post actions with inspecting code.

web_programming_project's People

Contributors

selltrack avatar realrazor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.