Code Monkey home page Code Monkey logo

nba-historian's Introduction

nba-historian

This is an early version of the NBA Historian, an application that leverages the balldontlie API, which gives access to a modest amount of NBA information. In this application you can search for players by name, view more details on a specific player by clicking one of the results you get, and then if applicable based on the player, you can get their statistics from the 2019-2020 NBA season. The app also provides the available information on all 30 NBA teams that is in the balldontlie database. There currently is user authentication as well through creating an account with a username and password.

Table of Contents

API Features

  • ES9: latest ECMAScript features
  • NoSQL database: MongoDB object data modeling using Mongoose
  • Authentication and authorization: using jsonwebtoken
  • Token Blacklisting: using Redis real time storage
  • Validation: request data validation using Joi
  • Logging: using winston and morgan
  • Testing: unit and integration tests using Jest (for auth routes only, ballDontlie routes coming soon)
  • Error handling: centralized error handling mechanism
  • API documentation: with swagger-jsdoc and swagger-ui-express (for auth routes only, balldontlieroutes coming soon)
  • Process management: advanced production process management using PM2
  • Dependency management: with npm
  • Environment variables: using dotenv and cross-env
  • Security: set security HTTP headers using helmet
  • Santizing: sanitize request data against xss and query injection
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Compression: gzip compression with compression

Getting Started

REQUIRED: Mongodb installed locally and have mongod running REQUIRED: Redis installed locally REQUIRED: pm2 installed locally if you want to run api in production mode

Installation

Clone the repo:

git clone https://github.com/jmetz93/nba-historian
cd nba-historian

Install api dependencies:

cd api
npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)
# can leave PORT, JWT_ACCESS_EXPIRATION_MINUTES, JWT_REFRESH_EXPIRATION_DAYS as is
# need to replace '{name-of-db-here}' with an actual database name for MONGODB_URL
# can leave JWT_ACCESS_SECRET and JWT_REFRESH_SECRET as is for local work, but should generate something much more secure for production

Install client dependencies:

cd .. # if still in api directory
cd client
npm install

Commands

Running locally:

cd api
npm run dev

Open new terminal window for client:

cd client
npm start

Running api in production:

cd api
npm start

Project Structure

api\        # Folder where api is housed
client\     # Folder where frontend is housed

API Structure

src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers (controller layer)
 |--docs\           # Swagger files
 |--middlewares\    # Custom express middlewares
 |--models\         # Mongoose models (data layer)
 |--routes\         # Routes
 |--services\       # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--app.js          # Express app
 |--index.js        # App entry point

nba-historian's People

Contributors

jmetz93 avatar

Stargazers

Roman avatar

Watchers

James Cloos 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.