Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronpowell/supercharging-web-dev-toolbox
https://github.com/aaronpowell/supercharging-web-dev-toolbox
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/aaronpowell/supercharging-web-dev-toolbox
- Owner: aaronpowell
- License: mit
- Created: 2021-05-25T02:51:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-26T22:45:20.000Z (over 3 years ago)
- Last Synced: 2024-11-17T19:47:03.464Z (about 2 months ago)
- Language: TypeScript
- Size: 521 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL + TypeScript workshop - Completed
Here is the completed application for the workshop, including the integration with CosmosDB to store the application data.
## Running The Application
_Before running the first time, you'll need to configure the data store, see below._
From a terminal run `npm start` from both the repository root and `api` folder to start the two servers, the web application will be on `http://localhost:3000` and the API on `http://localhost:7071`. Alternatively, you can use the VS Code launch of `Run full stack` to run both together with debuggers attached.
## Configuring the data store
Before the first run you will need to either configure the GraphQL server to work with CosmosDB, or to use the in-memory store.
### Using the in-memory store
To use the in-memory store, you need to open the [`api/graphql/data.ts`](api/graphql/data.ts) and comment out the `export` of the CosmosDB store implementation and instead use the `MockDataStore`:
```typescript
// export const dataStore = new CosmosDataStore(
// new CosmosClient(process.env.CosmosDB)
// );export const dataStore = new MockDataStore();
```**Note**: With the in-memory store, all game data will be reset to defaults when the server is restarted.
### Using the CosmosDB store
To use the [CosmosDB](https://docs.microsoft.com/azure/cosmos-db/serverless?WT.mc_id=javascript-13112-aapowell) store, you'll need to [create a CosmosDB resource using the SQL API](https://docs.microsoft.com/azure/cosmos-db/create-cosmosdb-resources-portal?WT.mc_id=javascript-13112-aapowell) and [add some data](https://docs.microsoft.com/azure/cosmos-db/create-cosmosdb-resources-portal?WT.mc_id=javascript-13112-aapowell#add-data-to-your-database) (easiest approach is to upload [`api/trivia.json`](api/trivia.json)), then add the `Primary Connection String` (found in the Portal -> Keys for the resource) to [`api/local.settings.json`](api/local.settings.json) as the value of the `CosmosDB` field.
**Note**: If you don't have an Azure account, you can sign up [for free](https://azure.microsoft.com/free/?WT.mc_id=javascript-13112-aapowell).