Skip to content

ahmadnourallah/game-store-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game Store API

A full-fledged ecommerce RESTFul API, built with TypeScript, Express.js, and Prisma PostgreSQL.

Demo

Check out the live version deployed here.

Description

Built with modular Express.js and type-safe TypeScript, Game Store API is an ecommerce RESTFul API that offers all you need to display your game products to game enthusiasts: games, genres, platforms and publishers.

Game Store API is highly scalable and customizable, thanks to the unopinionated nature of Express.js. It supports role-based, JWT authentication and preview images upload.

Game Store API is built to be easily integrated into and used with any frontend system effortlessly.

Features

  • ✅ RESTFul API with support for games, genres, platforms and publishers.
  • ✅ Role-based, JWT authentication using Passport.js.
  • ✅ Preview images upload.
  • ✅ Support for JSON and multipart form data.
  • ✅ Effortless database migration and deployment with Prisma and a custom seeding and purging script (src/seed.ts).
  • ✅ Comprehensive input validation and sanitization.

Getting Started

Installation

  1. Clone the repository:
git clone https://github.com/ahmadnourallah/game-store-api
  1. Install dependencies:
npm install

Environment Variables

Before starting the server, you should make sure to define the following environment variables:

  • PORT: The port which the development server will listen on. Default: 3000.
  • DB_URL: The postgresql url of the database. A postgresql database url has the following format: postgres://username:password@hostname:5432/database.
  • JWT_SECRET: A confidential cryptographic key used to sign and verify JWTs for authentication. You can generate a random one using: node -e "console.log(require('crypto').randomBytes(32).toString('hex'));".
  • JWT_EXPIRATION_TIME: The period after which a generated JWT expires and has to be resigned. Default: 2d.
  • ADMIN_EMAIL: The autogenerated superuser's email. By running npm run seed, an admin account is generated using the values of this variable and the following ones. Default: admin@gmail.com.
  • ADMIN_PASS: The autogenerated superuser's password. Default: admin123!.
  • ADMIN_NAME: The autogenerated superuser's name. Default: Admin.

WARNING: Do NOT use the default values of ADMIN_EMAIL and ADMIN_PASS in production.

Deployment

You can fire up the development server using:

npm run dev

Building the application can be done by running:

npm run build

You can preview the production build through:

npm run start

Moreover, you can use npm run purge to empty all tables and npm run seed to create the default admin account. Moreover, npm run seed will create dummy game data and download preview images from the RAWG API.

Technologies

The system is built with the latest technologies:

  • TypeScript
  • Node.js
  • Express.js
  • Prisma
  • Passport.js
  • Express Validator

License

This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details.

About

A full-fledged ecommerce RESTFul API, built with TypeScript, Express.js, and Prisma PostgreSQL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors