Set up Docker env for local development#27
Conversation
These values work with the local dev setup using docker compose.
| return {password: pw}; | ||
| }, | ||
|
|
||
| async 'replays/batch.json'(params) { |
There was a problem hiding this comment.
Strike the .json from the name, for loginserver APIs we don't use that.
| const ids: string[] = params.ids.split(','); | ||
| const results = await Replays.getBatch(ids); | ||
| console.log(params, ids, results); | ||
| this.response.setHeader('Content-Type', 'application/json'); |
There was a problem hiding this comment.
| this.response.setHeader('Content-Type', 'application/json'); |
This is already handled by the loginserver under the hood.
| const results = await Replays.getBatch(ids); | ||
| console.log(params, ids, results); | ||
| this.response.setHeader('Content-Type', 'application/json'); | ||
| return JSON.stringify(results); |
There was a problem hiding this comment.
| return JSON.stringify(results); | |
| return results; |
This is also handled by the loginserver under the hood.
| if (!params.ids) { | ||
| throw new ActionError("Invalid batch replay request, must provide ids"); | ||
| } | ||
| const ids: string[] = params.ids.split(','); |
There was a problem hiding this comment.
Probably this should be programatically capped in length here in addition to the query.
mia-pi-git
left a comment
There was a problem hiding this comment.
Please move the batch API endpoint into a new PR. Additionally, I've left feedback on that code.
| return replays.selectAll( | ||
| SQL`*` | ||
| )`WHERE private = 0 AND id IN (${idsForQuery}) LIMIT 51`.then(this.toReplays); |
There was a problem hiding this comment.
| return replays.selectAll( | |
| SQL`*` | |
| )`WHERE private = 0 AND id IN (${idsForQuery}) LIMIT 51`.then(this.toReplays); | |
| return replays.selectAll()`WHERE private = 0 AND id IN (${idsForQuery}) LIMIT 51`.then(this.toReplays); |
This is only necessary if you're not selecting * - it defaults to * otherwise.
SQL magic can just take a list, and the right thing will happen. No need to construct a string.
Prevents rebuild when writing e.g. logs to base dir.
|
I'll cherry-pick the batch endpoint changes onto a new branch. |
|
@mia-pi-git see #28 |
This PR adds a docker files and compose spec, to enable quickly setting up a dev environment for loginserver testing.
Right now, it starts a loginserver instance, mapping port 8080 on the container to the host, along with a cockroachdb instance.
By running
docker compose up --build --watchyou will build and start both services and can monitor their combined logs on the console. Changing the source files will trigger a rebuild (aka hot reloading).