Coder Social home page Coder Social logo

ez_tickets_backend's Introduction

EZ Tickets Rest API built with NodeJs, Express and MySql

Node Build, Test And Lint CI Deploy To Heroku API Version GitHub issues GitHub forks GitHub stars GitHub license Docs badge
BadgeNodeJS BadgeExpress BadgeMySQL BadgeAWS BadgeHeroku

๐Ÿ“ Documentation

The documentation was generated using Postman and is divided into collections at the following URLs:

๐Ÿš€ Deployement

  • The database for this API is hosted using AWS RDS (Make sure to update the .env.prod file with your own Database Hosting Url, otherwise the production environment will be running on the local database as well)
  • The Production API is deployed using Heroku

IMPORTANT: The URLs for both of these deployments is kept private due to security reasons. You can use any services out there for your own hosting requirements.

The release branch contains workflow to deploy to my own Heroku Service and won't work on your fork. If you want to use heroku as well, see their instructions and update your github secrets with your own credentials to make the release branch CI work for you as well.

๐Ÿ“€ Installation

1. Getting Started

# Clone this repo to your local machine using
git clone https://github.com/arafaysaleem/ez_tickets_backend

# Get into the directory
cd ez_tickets_backend

# Make it your own
rm -rf .git && git init

2. Setting Up ENV Variables

# Copy example.env and create your own .env file in envs folder
cp .env.example envs/.env

# Move into the envs dir
cd envs

# Edit .env file and add your mysql username, password and db name, host,
# port, jwt_secret, sendgrid api key and sender email
vscode .env

# Create different .env.{NODE_ENV} file for each environment and override only your
# required variables. The missing ones will be loaded from .env by default.
# For example if you want dev and production environments:
cp .env .env.dev
cp .env.dev .env.production

# When the NODE_ENV variable is set while running, the correct .env loads automatically.
# e.g. Setting NODE_ENV=production is going to load the .env.production file

# Add a gitignore to ignore node_modules and your .env file
echo -e 'node_modules \n envs \n' >> .gitignore

3. Setup MySQL database

Import the ez_ticket.sql using your sql workbench to create the database.

4. Setting up node js

# Install dependencies
npm install

# Run the server locally with default .env file
npm start

# Run the server in dev mode with nodemon with .env.dev file
npm run dev

# While deploying to production with .env.production file
npm run production

๐Ÿ”„ Setup CI (Github Actions)

If you want to run the github testing and PR labelling workflows in the CI then:

Create the following repository secrets:

  • CONFIG_VARS: value should be the following .env file variables
DB_HOST= db_localhost
DB_USER= db_username
DB_PASS= db_password
DB_DATABASE= db_name
  • SENDGRID_API_KEY: value should be your .env file variable => sendgrid_api_key
  • SENDGRID_SENDER: value should be all your .env file variable => from_email
  • SECRET_JWT: value should be all your .env file variables => your_secret

๐Ÿ‘จโ€๐Ÿš€ (Optional) Setup Postman API

If you want to quickly setup the endpoints for testing:

  • Go to Postman to import backup
  • Upload the schema_backup or unzip postman_collections_backup.zip and upload the folder

๐Ÿ“• Important Notes

  • There are two types of users possible (admin, api_user)
  • Most of the POST/PATCH/DELETE endpoints are forbidden to the api_user and only admin can use them. So make sure you use the token from an admin account login for admin access.
  • Only some POST/PATCH endpoints are open to the api_user like updating his profile or creating a booking/payment.
  • The healthcheck endpoint is to ensure the status of the API from the CI so we can be sure we are deploying a working API only.
  • You need to make an account on Twillio and integrate Sendgrid to get your own SENDGRID_API_KEY and SENDER_EMAIL
  • If you add/remove/change the names of any folders/file extensions make sure to update the labeler.yml

Enjoy :)

๐Ÿ”ง Tech

This example uses a number of open source projects to work properly:

๐Ÿ“‘ License

EZ Tickets Backend ยฉ 2021 by Abdur Rafay Saleem is licensed under CC BY 4.0

ez_tickets_backend's People

Contributors

arafaysaleem avatar dependabot[bot] 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.