Code Monkey home page Code Monkey logo

gbl-demo-backend's Introduction

GBL Demo

This is a demo for GBL

MIT License

Documentation

Features

  • Typescript
  • Follows service-controller design pattern
  • Supported database - Postgres with knex query builder
  • Role based Authentication and Authorization
  • Middlewares
    • Authorization (Role based)
    • Ratelimiter
    • Joi Validator
    • Pino Logger
    • ErrorHandler
  • Redis / Memory cache support
  • Swagger documentation (Do /api-docs to see the docs)
  • Deployed on Heroku (Note: While using Knex, heroku run knex --knexfile build/database/knexfile.js migrate:latest --app gbl-demo Also, to fix the authentication issue: heroku config:set PGSSLMODE=no-verify --app gbl-demo )

Pre-reqs

To build and run this app locally you will need a few things:

Getting started

Clone the repository

git clone https://github.com/aarav22/gbl-demo-backend.
git --branch <branch-name> <project-name>

Install dependencies

cd <project-name>
# yarn is recommended
# install yarn if not installed already
npm i -g yarn@latest
yarn install

Configure your environment

Create .env file by replicating .env.example and fill as per needs. To properly run this project, you will need to setup following variables to your .env file.

  • Server
key default value description
SERVER_HOST localhost host on which server will run
SERVER_PORT 5000 port on which server will run
  • JWT
key default value description
JWT_EXPIRES 30d expiry for jwt-tokens, eg. 1d, 10d
JWT_SECRET a606f398-51e9-4ba8-b8bb-02326f666bdf secret from which tokens will be signed and verified
# you can use this command in cli to easily generate random base64 string
# and use it as secret string or you can use any secret-string as per your wish.
node -e "console.log(require('crypto').randomBytes(64).toString('base64'))"
  • Database credentials
key default value
DB_XXXX_HOST localhost
DB_XXXX_PORT 5432
DB_XXXX_DATABASE template
DB_XXXX_USER admin
DB_XXXX_PASS root

Change XXXX with either one of these DEV, TEST, PROD.

Depending on your environment or you can use all at once as-well

# Development
DB_DEV_DATABASE=template
DB_DEV_USER=postgres
DB_DEV_PASS=root

# TEST
DB_TEST_DATABASE=template_test
DB_TEST_USER=postgres
DB_TEST_USER=root

# Production
DB_PROD_DATABASE=template
DB_PROD_USER=username
DB_PROD_PASS=password
  • Logger
key default value description
LOG_LEVEL debug set default log-level

Run pre-reqs scripts

# migrate base tables
yarn knex:migrate

# seed database with genesis block
yarn knex:seed

Run locally and start the server

# start application with development environment
yarn start:dev

# you can use legacy if above command doesn't seems to work
# yarn start:dev-legacy
  • Tests
# unit testing with jest and supertest
yarn test:unit
  • Linting
# lint check
yarn lint

# lint fix
yarn lint --fix

Authors

gbl-demo-backend's People

Contributors

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