Giter Site home page Giter Site logo

ibrahimelmokhtar / ts-online-store-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 186 KB

Build a Storefront Backend - Advanced Web Development egFWD - Second Project

TypeScript 95.35% Shell 0.33% JavaScript 4.32%
advanced-web-developer api-server egfwd jwt-authentication nodejs rest-api typescript db-migration postgresql

ts-online-store-api's Introduction

Online Store API

Build a Storefront Backend - Advanced Web Development egFWD - Second Project

This project was structured from scratch, with ZERO starter files.

Table of Contents

Installation

(Back to top)

To use this project, you need to follow the commands below:

  1. Clone the repository into your local machine:

    git clone https://github.com/ibrahimelmokhtar/ts-online-store-api.git
  2. Redirect inside the cloned repository:

    cd ts-online-store-api/
  3. Install the required packages:

    npm install
  4. Copy example.env file into .env file.

  5. Fill the created .env file with corresponding/appropriate information.

  6. For applying configured styling, run the following commands:

    • Prettier styling:

      npm run prettier
    • ESLint styling:

      npm run lint
  7. For manipulating the database, run the following commands:

    • Run Up Migrations:

      npm run migration:run
    • Run Down Migrations:

      npm run migration:reset
  8. For working on the development phase, run the following commands:

    • Live debugging while development:

      npm run watch
    • Jasmine Testing:

      npm run test
  9. For working with the production phase, run the following commands:

    • Build the project:

      npm run build

      Then, Run the compiled server:

      node build/server.js
    • OR simply, Start the server with one command:

      npm run start
  10. Open the local website on http://127.0.0.1:5000/{endpoint}/{:queryParameters}, more information about {endpoint} and {:queryParameters} will be explained in API Docmentation

Development

(Back to top) This section will explain how the code works and how everything is put together.

Architecture

(Back to top)

This project has the structure shown below:

Project Structure
├─── docs/
    ├─── REQUIREMENTS.md
├─── migrations/
    ├─── sqls/
        ├─── 20220505125703-users-table-down.sql
        ├─── 20220505125703-users-table-up.sql
        ├─── 20220507132301-products-table-down.sql
        ├─── 20220507132301-products-table-up.sql
        ├─── 20220508135120-orders-table-down.sql
        ├─── 20220508135120-orders-table-up.sql
        ├─── 20220508135656-order-products-table-down.sql
        ├─── 20220508135656-order-products-table-up.sql
    ├─── 20220505125703-users-table.js
    ├─── 20220507132301-products-table.js
    ├─── 20220508135120-orders-table.js
    ├─── 20220508135656-order-products-table.js
├─── spec/
    ├─── support/
        ├─── jasmine.json
├─── src/
    ├─── config/
        ├─── env.config.ts
        ├─── server.config.ts
    ├─── constants/
        ├─── order.type.constant.ts
        ├─── orderProduct.type.constant.ts
        ├─── product.type.constant.ts
        ├─── unique.uuid.constant.ts
        ├─── user.type.constant.ts
    ├─── controllers/
        ├─── dashboard.controller.ts
        ├─── orderProducts.controller.ts
        ├─── orders.controller.ts
        ├─── products.controller.ts
        ├─── users.controller.ts
    ├─── database/
        ├─── __tests__/
            ├─── index.spec.ts
        ├─── index.ts
    ├─── helpers/
        ├─── guards/
            ├─── compare.ts
            ├─── encrypt.ts
        ├─── testing/
            ├─── reporter.ts
    ├─── middlewares/
        ├─── authentication.middleware.ts
        ├─── validation.middleware.ts
    ├─── models/
        ├─── __tests__/
            ├─── index.spec.ts
            ├─── order.model.spec.ts
            ├─── orderProduct.model.spec.ts
            ├─── product.model.spec.ts
            ├─── user.model.spec.ts
        ├─── order.model.ts
        ├─── orderProduct.model.ts
        ├─── product.model.ts
        ├─── user.model.ts
    ├─── routes/
        ├─── __tests__/
            ├─── dashboard.routes.spec.ts
            ├─── index.spec.ts
            ├─── orderProducts.routes.spec.ts
            ├─── orders.routes.spec.ts
            ├─── products.routes.spec.ts
            ├─── users.routes.spec.ts
        ├─── api/
            ├─── dashboard.routes.ts
            ├─── orderProducts.routes.ts
            ├─── orders.routes.ts
            ├─── products.routes.ts
            ├─── users.routes.ts
        ├─── index.ts
    ├─── schemas/
        ├─── orderProducts.schemas.ts
        ├─── orders.schemas.ts
        ├─── products.schemas.ts
        ├─── users.schemas.ts
    ├─── services/
        ├─── __tests__/
            ├─── dashboard.services.spec.ts
        ├─── dashboard.services.ts
    ├─── types/
        ├─── __tests__/
            ├─── index.spec.ts
            ├─── order.type.spec.ts
            ├─── orderProduct.type.spec.ts
            ├─── product.type.spec.ts
            ├─── user.type.spec.ts
        ├─── dashboard/
            ├─── ordersPerUser.type.ts
            ├─── productsInOrder.type.ts
            ├─── topProduct.type.ts
        ├─── order.type.ts
        ├─── orderProduct.type.ts
        ├─── product.type.ts
        ├─── user.type.ts
    ├─── server.ts
├─── .eslintrc
├─── .gitignore
├─── .prettierrc
├─── database.json
├─── example.env
├─── package.json
├─── README.md
├─── tsconfig.json

API Documentation

(Back to top)

For more information about available endpoints, check this REQUIREMENTS.md file.

Installed NPM Packages

(Back to top)

These packages are required to run this project smoothly without any errors.

Production Packages

These packages can be found in the "dependencies" object inside the package.json file.

  • bcrypt - A bcrypt library for NodeJS.
  • cors - Node.js CORS middleware.
  • db-migrate - Database migration framework for node.js.
  • db-migrate-pg - A postgresql driver for db-migrate.
  • dotenv - Loads environment variables from .env file.
  • express - Fast, unopinionated, minimalist web framework.
  • express-validator - Express middleware for the validator module.
  • helmet - Help secure Express/Connect apps with various HTTP headers.
  • jsonwebtoken - JSON Web Token implementation (symmetric and asymmetric).
  • morgan - HTTP request logger middleware for node.js.
  • pg - PostgreSQL client.
  • uuid - RFC4122 (v1, v4, and v5) UUIDs.

Development Packages

These packages can be found in the "devDependencies" object inside the package.json file.

Useful Resources

(Back to top)

ts-online-store-api's People

Contributors

ibrahimelmokhtar avatar

Stargazers

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