-
Notifications
You must be signed in to change notification settings - Fork 1
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
add pdfs mutation + query #69
Conversation
also, use db users instead of env vars and simplify auth
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.
Two comments inline, will be back later 2 approve.
Going to mark it as approved in the meantime if you just wanna merge it and continue on with sweet contributions
}); | ||
|
||
const twoOrgs = await client.request(` | ||
query twoOrgs { |
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.
Dumb question, is the left align necessary here? makes it a little tough to skim but NBD
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'm very open to changing the indentation for these blocks!
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.
Yeah! I wondered if it was necessary for parsing or a convention for graphql but I'm not familiar. If it's not having it indented I think would help.
|
||
expect(res.pdfs.length).toBe(2); | ||
expect(res.pdfs[0].uuid).toEqual(thisUserPdf.uuid); | ||
expect(res.pdfs[1].uuid).toEqual(anotherUserPdf.uuid); |
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.
Wait, does it not randomize the test order?
In general I would expect each test to be self-contained in terms of setup and teardown.
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.
jest executes the tests within a suite sequentially - jestjs/jest#4386 - the files themselves will be run in a random order though
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.
Ah I'm so used to rails tests, which randomize order to enforce test isolation and catch random order-of-operations bugs.
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.
Lookin good! Thanks for doing this. A couple questions/comments but all good to go from me, nothing blocking.
}); | ||
|
||
const twoOrgs = await client.request(` | ||
query twoOrgs { |
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.
Yeah! I wondered if it was necessary for parsing or a convention for graphql but I'm not familiar. If it's not having it indented I think would help.
|
||
expect(res.pdfs.length).toBe(2); | ||
expect(res.pdfs[0].uuid).toEqual(thisUserPdf.uuid); | ||
expect(res.pdfs[1].uuid).toEqual(anotherUserPdf.uuid); |
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.
Ah I'm so used to rails tests, which randomize order to enforce test isolation and catch random order-of-operations bugs.
src/auth.ts
Outdated
@@ -49,13 +47,16 @@ export const authenticatedOnly = (handler, client: OAuth2Client) => ( | |||
|
|||
export const getTokenFromReq = req => req.headers['x-auth-token']; | |||
|
|||
export const getUserFromToken = async (tok: string, client: OAuth2Client) => { | |||
export const getUserFromToken = async ( | |||
tok: string, |
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.
could we call it token?
|
||
import { getUserFromToken } from '../../auth'; | ||
|
||
import { ledgerListArgs, MAX_LIMIT } from '../../helpers'; |
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.
Maybe not for this PR, but is there a way we can escape relative imports? I've done it in the past with CRA, but haven't with regular node -- looks like we may be able to by making the app a "type": "module"
in the package.json? [This could be an issue instead of a comment]
|
||
const ADMINS = [ | ||
{ name: 'Ben', email: 'anonyben@gmail.com' }, | ||
{ name: 'Matt', email: 'matthew.hampel@gmail.com' }, |
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.
could I be matt@matth.org?
Oh wait if it needs to be gmail, then mahatm@gmail.com
src/server.ts
Outdated
|
||
if (!organization) throw new Error('missing organization'); | ||
|
||
const user = input.user |
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.
QQ, so we can specify a user in the form/input, and then we fall back to the authenticated user?
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.
ooh yeah i think this should change -- we should be able to add a pdf without assigning a user right away.
also, use db users instead of env vars
and simplify auth