walter-backend v2.1.4
General
This is the main repo for the backend of Walter.
Features
- Nexus framework: The server uses the nexus-framework which provides a lot of features out of the box that we don't need to integrate like testing, subscriptions and logging. It also easily integrates graphql-shield, jwt-auth for authenticating and Prisma as ORM with a plugin.
In this project the Nexus framework is the GraphQL API, Prisma is an programming API to use in our code to interact with the database.
For a fully-fledged GraphQL & Node.js tutorial, visit How to GraphQL
Software requirements
- You need NodeJS installed (version >= 14). Suggestion use the n-install script to manage Node versions.
- You need Yarn classic 1.x installed. See your OS install steps here
- You need Docker installed. See your OS install steps here
- You need Docker compose installed. See your OS install steps here
Getting started
Setup
Our application requires 2 .env
files. One that Prisma is looking for under ./prisma
and another for configuring everything else.
- Create the
./prisma/.env
file and in it putDATABASE_URL=postgresql://postgres:k0fpEoFJetxkObPD@localhost:5432/walter
. This login credential is the one you can find indocker-compose.yml
- Ask a coworker for environment variables to fill in
.env
file at the root of the project. It needs it to know where to connect to Redis and configure different third parties. - Download the file from https://drive.google.com/file/d/1OXMIht11Yngxew8WoeeOY6ZVxj9ffxaF/view?usp=sharing saved under the name
staging-walter-backend-storage.json
to be at the root of the project and add the following to your .env file. This is used for file upload from your machine to staging for some API calls.
PROJECT_ID=staging-288420
KEY_FILENAME=staging-walter-backend-storage.json
FILES_BUCKET_NAME=walter-staging
Starting up
# Start the required database (the -d option is to run it in daemon mode, in the background)
docker-compose up -d
# 1. Install depedencies
yarn install
# 2. Generate prisma code based on schema (datamodel.prisma).
yarn prisma generate
# 3. Create the database structure without data
yarn db:up
# 4. Add some seed data. Once the script is done, in the output of the console, take note of your manager and resident user names and of the manager user password once the script is done and of the instructions on where to use the provided credentials. To generate a manager user with a managing company, you can also start the manager-web frontend, go to http://localhost:3000/auth/register, then register a company and take note of your user email in the user profile (the password will be 12345678 by default).
yarn seed
# 5. Start dev server
yarn dev
Commands
yarn dev
starts GraphQL server onhttp://localhost:5000
yarn worker-dev
Run worker jobs locallyyarn build
Build the code for production. It creates a .nexus folder with JS code and it's own node_modules.yarn test:unit
runs the unit tests onlyyarn test:int
runs the integration tests and needs the Postgres database to be accessible locally to workyarn test
do both the above
Project structure
File name | Description | |
---|---|---|
├── .env | Defines environment variables | |
├── .graphqlconfig.yml | Configuration file based on graphql-config (e.g. used by GraphQL Playground). | |
└── prisma (directory) | Contains all files that are related to the Prisma database service | \ |
├── prisma/.env | Prisma looks for this file for environment variables | |
└── prisma/schema.prisma | Defines your data model (written in GraphQL SDL) | |
└── api (directory) | Contains the source files for your GraphQL server | |
├── api/app.ts | The entry point for your GraphQL server | |
├── schema.graphql | The application schema defining the API exposed to client applications | |
├── api/resolvers (directory) | Contains the implementation of the resolvers for the application schema | |
└── api/generated (directory) | Contains generated files | |
└── prisma.grapghql | The Prisma database schema defining the Prisma GraphQL API |
Documentation
For further documention please look this project Wiki or the wiki tab above.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago