Skip to content
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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

MCGallaspy
Copy link

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).

@MCGallaspy MCGallaspy marked this pull request as draft October 17, 2024 17:26
@@ -904,7 +904,16 @@ export const actions: {[k: string]: QueryHandler} = {
}
return {password: pw};
},

async 'replays/batch.json'(params) {
Copy link
Member

@mia-pi-git mia-pi-git Oct 20, 2024

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');
Copy link
Member

@mia-pi-git mia-pi-git Oct 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(',');
Copy link
Member

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.

Copy link
Member

@mia-pi-git mia-pi-git left a 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
Comment on lines 244 to 246
return replays.selectAll(
SQL`*`
)`WHERE private = 0 AND id IN (${idsForQuery}) LIMIT 51`.then(this.toReplays);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
@MCGallaspy
Copy link
Author

I'll cherry-pick the batch endpoint changes onto a new branch.

@MCGallaspy
Copy link
Author

@mia-pi-git see #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants