Giter VIP home page Giter VIP logo

ecommerce_api's Introduction

Ecommerce API

  • An api to faciliatate buying and selling goods built using typescript, expressjs, and mongodb

Follow steps below

  • Clone this repository

Setup environment variables

  • Create a .env file in the root of your project with the following variables
DATABASE=<connection-string-to-your-mongodb-database>

TEST_DATABASE=<connection-string-to-your-mongodb-testdatabase>

JWT_SECRET=<secret>
JWT_EXPIRY_TIME=

EMAIL_PORT=
EMAIL_AUTH_USERNAME=<google_auth_user_name>
EMAIL_AUTH_PASSWORD=<google_auth_password>
EMAIL_FROM=
  • The api uploads images to cloudinary. Create an account and pick configuration from the dashboard to fill below
CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
  • To facilitate facebook and google auth

Get Facebook app id and secret

FACEBOOK_APP_ID=
FACEBOOK_APP_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
  • Used to run on localhost else change it to point to your host

  • Used by Oauth strategies to redirect back to the api

BASE_URL=http://localhost:3000/ 

    OR 

BASE_URL=https://api.herokuapp.com/

  • The api supports paypal payment using braintree by receiving a nonce from a client.

  • Go to braintree developer home page and get details below.

  • You'll be prompted to create an account if you don't have one. The same applies to any site mentioned above.

BRAINTREE_MERCHANT_ID=2c34stzd8dh7rzxb
BRAINTREE_PUBLIC_KEY=xb4vq7dc6d5kmd96
BRAINTREE_PRIVATE_KEY=fe6a0aa5736ecedaf6bddde990407611

Run the API

  • Execute npm run start:dev to run in development

  • Execute npm run start:prod:local to run a local production build. It performs a deletion of dist folder, creates a new one and starts the server

  • Note that npm start alone will not work locally unless you run npm run build first. However, it will work on heroku. Heroku takes care of running npm run build and npm start on it's own. I created them separately that purpose and also that heroku will fail anything attempt to delete folders or files.

  • Execute npm test to run the automated tests

Features

  • Sign in and sign up using email,password, google and facebook
  • Send mail on successfull sign up
  • Route protection and restriction according to role and login status
  • Forgot and reset password
  • Add product image - upload to cloudinary
  • Update user email and name
  • Add,remove,modify delete and fetch products (Random selection on every API request)
  • Process paypal payment using nonce from client and save order
  • Receive order from client and save e.g if client used stripe_payment flutter to process payment from frontend and return order details on successfull payment An example is my ecommerce flutter client which performs stripe payment and sends order after success. It also carries out paypal payment by sending a nonce to this api to process it
  • Retrieve orders
  • Add,remove, and fetch categories
  • Search by product name, and name or category
  • Add ,remove, and fetch user's cart
  • General error hanlding

ecommerce_api's People

Contributors

knehe avatar

Stargazers

 avatar  avatar  avatar

Watchers

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