# <%=projectName%>

## Prerequisites

1. Make sure you have [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md), [docker](https://docs.docker.com/engine/install), and [yarn](https://yarnpkg.com/) installed.
2. We are using private npm packages from our [monorepo](https://github.com/theorchard/orchard-suite) registry, which requires a valid access token. Follow this guide to configure NPM access.
   https://www.notion.so/Javascript-Package-Management-Setup-9553d5d491c94835aa787fdf0fc4838d
3. Familiarize yourself with [GraphQL at The Orchard](https://github.com/theorchard/docs/tree/master/graphql) before contributing!

## Running locally

### Running outside of Docker:

1. Make sure that you have `nodejs` and `yarn` installed on your system

2. Follow [Javascript Package Management Setup](https://github.com/theorchard/docs/blob/master/javascript/packages.md)

3. Copy the `.env.shadow` file to `.env`:

```
$ cp .env.shadow .env
```

4. Set `GITHUB_NPM_TOKEN` environment variable in the current shell to a working token.

5. Install project dependencies

```
$ yarn install
```

6. Run local server.

```
$ yarn start
```

7. Open your web browser [http://localhost:8080/graphql](http://localhost:8080/graphql) and make some queries.

### Running in Docker:

1. Make sure you have docker installed.

2. Authenticate to ECR in the AWS account containing parent images (specified in Dockerfile)

3. Replace any unset environment variables in docker-compose.yaml for the service with real values

4. Set `GITHUB_NPM_TOKEN` environment variable in current shell to a working token.

5. Run one or more services using docker compose:

```
docker compose up --build service
```

Alternatively, separate the build and run steps:

```
docker-compose build --no-cache service
docker-compose up service
```

6. Open your web browser [http://localhost:8080/graphql](http://localhost:8080/graphql) and make some queries.

**NOTE:**
**Running the project locally requires an active VPN connection.**

## Tests

### `yarn test:unit --watch`

Runs the jest unit tests in watch mode. In watch mode type `p` to enter a filter.

### `yarn test:integration`

Runs the jest integration tests against a local instance. **Note** that you need to run `yarn start` in a different process first.

### `yarn test`

Runs unit and integration tests. Run this before creating a PR.

### `yarn lint`

Runs the js and graphql schema linter. Run this before creating a PR.

### `yarn build`

Builds the app for production to the `build` folder.<br />

Note that this command is not required to run locally, it is run during the docker build steps.
