Skip to content

Commit

Permalink
document mocked routes
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Nov 13, 2024
1 parent bef2b17 commit d9eb39b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 55 deletions.
54 changes: 0 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,3 @@

The Burrito API serves all the server data (app versions, notifications, flags, sessions)
and is the communication bridge between the bus driver application and user application.

## Running the server

### For development

Because sqlx checks the queries at compile time, the development databse must be running.
The easiest way is to run the development db container with.

```bash
# See docker-compose.yml
docker compose up --build
```

Once you have the database running, then you start the server with

```bash
cargo run
```

### For production

The production container can be started with

```bash
# See docker-compose.prod.yml
docker compose -f docker-compose.prod.yml up --build
```

Please make sure to double check that your .env variables and Docker variables are set
correctly.

## Management

The only thing you'll ever need to manage are database migrations. For this purpose, there
is the [sqlx cli](https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md).

```bash
cargo install sqlx-cli

# Run migrations
sqlx migrate run

# Reset the database and migrations
sqlx database reset --force
```

## Mocking routes for showcasing purposes

No bus driver working today? No problem! You can mock the routes by setting `IS_MOCKED=true` in
the env file. The mocked route will be read from `static/mocks/*.json`. See `mock.rs` for more
details.

Once you have set `IS_MOCKED=true`, you can start the server as usual. Mocking works by sending
`POST /driver` requests to ourselves, iterating over the mocked route records.
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- markdownlint-disable MD033 MD045 -->
<!-- markdownlint-disable MD033 MD045 MD014 -->

# Server deployment

Expand Down
16 changes: 16 additions & 0 deletions docs/using_mocked_route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Using a mocked bus route

No bus driver? No problem! You can start the app with a mocked route
by setting `IS_MOCKED=true` in the env file.

The mocked route will be read from `static/mocks/*.json`. See `mock.rs` for more
details.

Once you have set `IS_MOCKED=true`, you can start the server as usual.
Mocking works by sending `POST /driver` requests to ourselves,
iterating over the mocked route records.

## Why would I use this?

This feature is useful for showcasing the app without having to rely on
a real bus driver, or testing purposes.

0 comments on commit d9eb39b

Please sign in to comment.