-
Notifications
You must be signed in to change notification settings - Fork 0
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
Minimum viable product (Closes #11) #20
Conversation
Actually not so minor. SSE now works, REAL TIME updates achieved (race condition here we come). Also there is lots of cleaning needing to be done. PLease contanct Simon Mechler for tidying services :D
TODO: Fix full/partial schemas, add/remove pubs/themes/keys, secure sse, add queue status (maybe), styling
Some big issues needs to be fixed before the MVP is complete. The smaller ones and styling will be left for further development
Improve development guide
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.
Overall, I think it looks very good! 😄
I added a few comments and suggestions (some are quite nitpicky, sorry.. 😅). So just address them and go ahead and merge. 👍
if (cookies.get("adminKey") !== ADMIN_KEY) { | ||
return fail(401, { message: "Unauthorized" }); | ||
} |
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.
Authorisation is performed on every action so maybe extract that to a separate function?
const formData = Object.fromEntries(await request.formData()); | ||
|
||
const result = pubKeyIdPairSchema.pick({ | ||
pubKey: true, | ||
pubId: true, | ||
}) | ||
.safeParse(formData); | ||
|
||
if (!result.success) { | ||
const { fieldErrors } = result.error.flatten(); | ||
|
||
return fail(400, { | ||
errors: fieldErrors, | ||
values: result.data, | ||
}); | ||
} |
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 sequence is also very repeated:
const formData = ...
const result = ...
if (!result.success) { ... }
Perhaps make some kind of helper function like:
async function parseForm<T>(request: Request, schema: ZodSchema<T>) {
const formData = Object.fromEntries(await request.formData());
const result = schema.safeParse(formData);
if (!result.success) {
const { fieldErrors } = result.error.flatten();
return fail(400, { errors: fieldErrors, values: result.data });
}
return result.data;
}
const pubKey: PubKey = cookies.get("pubKey"); | ||
const pubKeyIdPairs: PubKeyIdPairs = await getPubKeyIdPairs(); | ||
|
||
if (!pubKey || !pubKeyIdPairs.has(pubKey)) { | ||
return fail(401, { message: "Unauthorized" }); | ||
} |
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.
I would probably extract this to avoid repetition. 😄
DEtta är bra Co-authored-by: Simon Mechler <[email protected]>
Sounds good to me Co-authored-by: Simon Mechler <[email protected]>
This is on you if it fails >:) Co-authored-by: Simon Mechler <[email protected]>
Sounds good, will implement before merging Co-authored-by: Simon Mechler <[email protected]>
Minimum viable (barely) product finished. Issues on what needs to be done further will be created shortly.
Future work includes: