GithubHelp home page GithubHelp logo

malaka98 / food-ordering-system Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 3.0 111 KB

Backend Base URL

Home Page: https://full-stack-backend.herokuapp.com/api

TypeScript 97.38% JavaScript 1.56% Dockerfile 1.06%
ci-cd circleci dependency-injection express express-docker express-webpack full-stack-web-development heroku-deployment jest-tests mean-stack

food-ordering-system's Introduction

CircleCI

CircleCI

Full Stack Project Backend - PUSL3120

This web service has been developed using Express

Also, the "Inversion Of Control" principle, which is a very useful design principle, has been used here.

This is a response from ChatGPT

Inversion of Control (IoC) is a design principle that allows a component to receive its dependencies, rather than creating them itself. This separates the concerns of creating and managing dependencies from the component that uses them, and allows for greater flexibility and testability.

There are two main types of IoC:

Dependency Injection (DI): This is the process of providing an object with its dependencies. 
                           The object doesn't create or look up its dependencies, but instead they are passed to it.

Service Locator: An object that "locates" or retrieves other objects, 
                 often used to decouple a class from the process of creating its dependencies.

Inversify is a popular library for implementing IoC in JavaScript and TypeScript projects, it uses a modular approach to build a lightweight and powerful inversion of control container for JavaScript & Node.js applications.

Inversion of control is often used in software development to increase flexibility and testability of the code. By using IoC, it is possible to change the behavior of a component by replacing its dependencies without modifying the component itself. This makes it easier to test components in isolation and to change the implementation of a component without affecting the rest of the system.

The inversify library has been used to implement an IOC container on a node express server

Installation

Full Stack Project Backend system requires Node.js v16+ to run.

Install the dependencies and devDependencies and start the server.

cd Full Stack Project Backend
npm install

Add the following environment variables in the .env file:

  MONGO_USER=<MongoDb Username>
  MONGO_PASSWORD=<MongoDb Password>
  MONGO_PATH=cluster0.6pjjs4p.mongodb.net/<atless db name>?retryWrites=true&w=majority
  PORT=<PORT Number>
  JWT_SECRET=<my-secret>
  ORIGIN_URL=<http://localhost:4200>

To run the application in the development environment:

npm dev

To run ESLint code analysis:

npm lint

To run the test cases:

npm test

To build the application:

npm build

To run the built application:

npm start

Docker

Full Stack Project Backend is very easy to install and deploy in a Docker container.

By default, the Docker will expose port 8080, so change this within the Dockerfile if necessary. When ready, simply use the Dockerfile to build the image.

cd Full Stack Project Backend
sudo docker build -t my-app .
sudo docker run -p 4000:4000 my-app

API documentation

BASE_URL/api/user [Method: POST]

Add User (sample request)

    http://localhost:4000/api/user
    {
        "firstName": "Malaka",
        "lastName": "Jayakodi",
        "username": "rootx",
        "email": "[email protected]",
        "address": "Kuliyapitiya",
        "password": "123456",
        "phoneNumber": "07771234567"
    }

BASE_URL/api/user/login [Method: POST]

Login (sample request)

    http://localhost:4000/api/user/login
    {
        "username": "rootx",
        "password": "123456"
    }

BASE_URL/api/user [Method: GET]

Check user is logged (sample request)

   http://localhost:4000/api/user

BASE_URL/api/user/:userId [Method: GET]

Get User By Id (sample request)

   http://localhost:4000/api/user/63e0a78a8b31416179ac08d0

BASE_URL/api/user/:email [Method: DELETE]

Delete user by email (sample request)

  http://localhost:4000/api/user/[email protected]

food-ordering-system's People

Contributors

malaka98 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.