https://github.com/mikaelvesavuori/triplecheck-repository-fauna
Database utility for using FaunaDB with the TripleCheck broker.
https://github.com/mikaelvesavuori/triplecheck-repository-fauna
consumer-contracts consumer-driven-contracts contract-testing pacts triplecheck
Last synced: about 2 months ago
JSON representation
Database utility for using FaunaDB with the TripleCheck broker.
- Host: GitHub
- URL: https://github.com/mikaelvesavuori/triplecheck-repository-fauna
- Owner: mikaelvesavuori
- License: mit
- Created: 2021-05-15T15:28:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-18T08:30:44.000Z (almost 4 years ago)
- Last Synced: 2025-01-16T16:22:22.967Z (4 months ago)
- Topics: consumer-contracts, consumer-driven-contracts, contract-testing, pacts, triplecheck
- Language: TypeScript
- Homepage:
- Size: 842 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# triplecheck-repository-fauna

## TripleCheck: FaunaDB database repository
Database utility for using FaunaDB with the [TripleCheck broker](https://github.com/mikaelvesavuori/triplecheck-broker). It implements the repository base at [triplecheck-core](https://github.com/mikaelvesavuori/triplecheck-core).
## Instructions
- In Fauna, create a database called `triplecheck-broker`.
- Under `Security`, create a key for the database and set the role to `Server`
- Paste the key's value into the `.env` file like this: `FAUNA_KEY=some-secret-random-key`
- Create a new collection (call it `triplecheck`)
- Create an index called `Key` and set the term to `data.key`; also enable `Serialized` and `Unique`
- By default the Fauna repository will pick up an environment variable called `FAUNA_KEY` (as per above), so use something like [dotenv](https://www.npmjs.com/package/dotenv) to simplify getting that value## Basic implementation
```TypeScript
import { TripleCheckBroker } from 'triplecheck-broker';
import { FaunaRepository } from 'triplecheck-repository-fauna';import dotenv from 'dotenv';
dotenv.config();const repository = FaunaRepository();
const request = "Get this from your API request and transform it as needed";
const payload = "Body";
const { responseData, status, headers } = await TripleCheckBroker(request, payload, repository);
```