This is a todo application for building GraphQL in Node.js using ES6 and Express with JWT Authentication & typescript
Clone the repo:
git clone git@github.com:GeekRishabh/ExpressTS-Graphql-todo.git
cd ExpressTS-Graphql-todo
Install yarn:
npm install -g yarn
Install Mongo:
brew install mongodb
Install dependencies:
yarn
Set environment (vars):
cp .env.example .env
Note:- Create a .logs
folder at the root level of project & Mongodb is running.
Start server:
# Start server
yarn start
# Selectively set DEBUG env var to get logs
DEBUG=express-graphql-todo:* yarn start
Refer debug to know how to selectively turn on logs.
# compile to ES5
1. yarn build
# upload dist/ to your server
# install production dependencies only
2. yarn --production
# Use any process manager to start your services
3. pm2 start dist/index.js
In production you need to make sure your server is always up so you should ideally use any of the process manager recommended here. We recommend pm2 as it has several useful features like it can be configured to auto-start your services if system is rebooted.
# service restarts on file change
bash bin/development.sh
# To use this option you need to make sure mongodb is listening on port 27017
# Build docker
docker build -t express-graphql-todo .
# Run docker
docker run -p 4040:4040 express-graphql-todo
• Public Graphql Endpoint
http://localhost:4040/graphql/public
• Protected Graphql Endpoint
Note: Please download GraphiQL to get the protected route working .
Note: Need to pass Authorization Bearer Token in Header to access this endpoint obtained from public endpoint while Signup/Login.
http://localhost:4040/graphql/protected
• Click Me