Giter VIP home page Giter VIP logo

graphql-api-starter's Introduction

๐Ÿš€ GraphQL API Starter Pack

This project is a lightweight boilerplate, crafted to kick-start GraphQL API projects using TypeScript, TypeORM, PostgreSQL, GraphQL, Apollo Server, Type-GraphQL, and Docker. It's a robust and flexible foundation, ideal for swiftly building backend applications with some cool tech! ๐ŸŒ๐Ÿ”ง

In this project:
  • Simple book CRUD example
  • Basic JWT authentication (SignUp and Login)
  • Custom decorator example to protect resolver
  • Script to reset database and create data fixtures

๐Ÿ“‹ Prerequisites

Make sure you have Node.js and/or Docker installed on your machine to use this app.

๐Ÿณ Installation with Docker

  1. Clone the Project git clone https://github.com/096benjaminbenoit/backend-boilerplate

  2. Start the application in a Docker container docker compose up

Go to http://localhost:4000 to access the Apollo Sandbox, ET VOILA ๐Ÿ”ฅ

๐Ÿ›  Installation without Docker

  1. Clone the Project

    git clone https://github.com/096benjaminbenoit/backend-boilerplate

  2. Install Dependencies npm install

  3. Configure Environment

    • Create a .env file at the root of the project based on .env.example.
    • Add the necessary environment variables (for your database connection and JWT secret key). ๐Ÿ”‘

  4. Start the Application npm start

Go to http://localhost:4000 to access the Apollo Sandbox, ET VOILA ๐Ÿ”ฅ

๐Ÿ”„ To reset database and create data fixtures

Simply type this command (in terminal or in Docker shell): npm run resetDB

You can add some data fixtures by modifying the resetDb.ts file.

๐Ÿ“ Project Structure

The project structure is deliberately simple, but there's nothing to stop you from adding to it as you see fit!

โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ database
โ”‚   โ”‚   โ””โ”€โ”€ DataSource.ts // Database connection
โ”‚   โ”œโ”€โ”€ entities // All entities
โ”‚   โ”‚   โ”œโ”€โ”€ Book.ts
โ”‚   โ”‚   โ””โ”€โ”€ User.ts
โ”‚   โ”œโ”€โ”€ inputs // All inputs/dto
โ”‚   โ”‚   โ”œโ”€โ”€ BookInput.ts
โ”‚   โ”‚   โ”œโ”€โ”€ LoginInput.ts
โ”‚   โ”‚   โ””โ”€โ”€ UserInput.ts
โ”‚   โ”œโ”€โ”€ resolvers
โ”‚   โ”‚   โ”œโ”€โ”€ BookResolver.ts // A resolver example with CRUD
โ”‚   โ”‚   โ””โ”€โ”€ UserResolver.ts // User management (SignUp, Login, ...)
โ”‚   โ”œโ”€โ”€ types
โ”‚   โ”‚   โ””โ”€โ”€ interfaces.ts // All interfaces
โ”‚   โ””โ”€โ”€ utils
โ”‚       โ”œโ”€โ”€ auth.ts // Password management and user authentication
โ”‚       โ”œโ”€โ”€ jwt.ts // JWT management
โ”‚       โ””โ”€โ”€ security.ts // Custom decorators to protect resolvers
โ”œโ”€โ”€ env.ts
โ”œโ”€โ”€ index.ts
โ””โ”€โ”€ resetDb.ts // Little script to reset database and create data fixtures

Made with love โค๏ธ

graphql-api-starter's People

Contributors

096benjaminbenoit 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.