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.
- 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
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
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
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
api\ # Folder where api is housed
client\ # Folder where frontend is housed
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