Welcome to your new API! Read the docs.
TODO:
- Context-based authorization on subscriptions.
To get started:
-
Clone this repository.
-
Remove
.git
.
rm -rf .git
- Initialize a new git repository.
git init
git remote add origin <your-new-git-repo>
- Push to your new repo.
git add .
git commit -m "First commit"
git push --set-upstream origin master
This API generator uses yarn along with package.json to manage much of the scaffolding and service of the API. For example, running yarn cli create:entity book
will create a GraphQL schema and a database entity for the book
object.
This API has a number of relevant, life-enhancing features:
- Authentication
- Username/password login
- Password reset via email
- JWT auth in the GraphQL routes
- JWT invalidation after password resets
- Authorization
- Role-based permissions
- Docker
- Dockerfile
- Multiple docker-compose files for ease of development
- Cron jobs
- Logging
- Uses a logger instead of
console.log
; no more writing and deleting logs, just keep them in the code and adjust them according to the log level
- Uses a logger instead of
- Environment variables
- Set in development using the
.env
file - Interface with the application using a single settings file
- Set in development using the
- Global settings
- Tests!
- Documentation! (You're looking at it.)
/auth/*
- standard express routes handling authentication on theUser
entity./graphql
- graphql endpoint
After cloning the repository, install all dependencies:
yarn
# or
npm install
Running the dev server is simply:
yarn dev
There is also a full docker-compose development file (docker-compose.development.yml). Running this will spin up a full development environment. All code will be tested against this dev environment.
docker-compose up
Run the following from the root of the api:
yarn cli create:entity <entityName>
This will add a new directory under /src/api/data containing a new, working entity. GraphQL will automagically pick it up and register it with the schema.