-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up Docker env for local development #27
base: master
Are you sure you want to change the base?
Conversation
These values work with the local dev setup using docker compose.
@@ -904,7 +904,16 @@ export const actions: {[k: string]: QueryHandler} = { | |||
} | |||
return {password: pw}; | |||
}, | |||
|
|||
async 'replays/batch.json'(params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this should be programatically capped in length here in addition to the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the batch API endpoint into a new PR. Additionally, I've left feedback on that code.
src/replays.ts
Outdated
return replays.selectAll( | ||
SQL`*` | ||
)`WHERE private = 0 AND id IN (${idsForQuery}) LIMIT 51`.then(this.toReplays); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 --watch
you 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).