Giter Site home page Giter Site logo

apollo-gql-api's Introduction

Apollo Server 3.0 + GraphQL + Prisma + TypeScript

This is a node.js graphql project using Apollo Server 3, TypeScript, Prisma 2, argon2, class-validator, TypeGraphQL, express-session, and ioredis.

Features

  • Register
  • Login
  • Add todo
  • List todos
  • Get a single todo
  • Update todo
  • Delete a todo
  • SECURITY!!! (and auth!)

A note

This app is not exactly feature complete. When the secret is compromised and the server can figure out that it is, it will try its best to defend, but it does not notify you. You definitely want to change this and send an email to yourself, or automatically regenerate the secret.

DB

This project uses PostgreSQL, though it could be very easily switched to use SQLite, MongoDB, or MySQL. You will have to edit the providers field of the datasource in the prisma schema, and then recreate the migrations.

Redis Sessions

This project uses sessions (express-session), and uses Redis to store the sessions. To configure the redis instance URL, set the REDIS_URL env var in .env.

Inspecting data

You can run yarn prisma studio to inspect the data in the database.

Env vars

Rename .env.example to .env. Get you db connection URL, paste it in. To get the SECRET var, follow the instructions below. Paste your redis instance url in as well.

Generating SECRET env var

You can use the following snippet to generate the SECRET env var.

python3 -c 'from secrets import choice;import string;print("".join([choice(string.ascii_uppercase + string.digits) for _ in range(100)]))' | openssl base64

Take it, put it in .env, and remove all whitespace in the generated var.

Usage

NOTE: This project uses yarn 2 and requires yarn to be installed. However, you could get it to work with npm as well.

Generate client using yarn prisma generate. Run yarn prisma migrate dev to both generate the client and run migrations.

Run build using yarn build.

Start by running yarn start.

Run watch build using yarn build:watch.

Run dev server by running yarn dev.

That's all!

apollo-gql-api's People

Contributors

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