Created
October 1, 2017 19:55
-
-
Save mattiasholmqvist/2d8ad10b7a26cfa747f621ceaa29e7d5 to your computer and use it in GitHub Desktop.
client.js in Serialized Todo Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var axios = require('axios') | |
| // Setup client to use access key headers from environment variables | |
| var client = axios.create({ | |
| baseURL: 'https://api.serialized.io', | |
| headers: { | |
| 'Serialized-Access-Key': `${process.env.SERIALIZED_ACCESS_KEY}`, | |
| 'Serialized-Secret-Access-Key': `${process.env.SERIALIZED_SECRET_ACCESS_KEY}` | |
| } | |
| }); | |
| function loadList(listId) { | |
| return client.get(`/aggregates/list/${listId}`) | |
| } | |
| function findListProjections() { | |
| return client.get('/projections/single/lists/') | |
| } | |
| function findListStats() { | |
| return client.get('/projections/aggregated/list-stats') | |
| } | |
| function findListProjection(listId) { | |
| return client.get(`/projections/single/lists/${listId}`) | |
| } | |
| function saveListEvents(aggregateId, events) { | |
| var request = { aggregateId: aggregateId, events: events } | |
| return client.post('/aggregates/list/events', request) | |
| } | |
| module.exports = { loadList, findListStats, findListProjection, findListProjections, saveListEvents } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment