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

#42 Creating Gitcoin Endpoints #49

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

DrewMcArthur
Copy link
Contributor

closes #42

@DrewMcArthur DrewMcArthur marked this pull request as draft February 23, 2023 06:51
@netlify
Copy link

netlify bot commented Feb 23, 2023

Deploy Preview for whimsical-cuchufli-3a5565 failed.

Name Link
🔨 Latest commit efee1e8
🔍 Latest deploy log https://app.netlify.com/sites/whimsical-cuchufli-3a5565/deploys/6428992adbff0c0008cf9109

@DrewMcArthur
Copy link
Contributor Author

DrewMcArthur commented Apr 1, 2023

okay @thelastjosh just got a chance to sit down with this! sorry for the delay, but ready for a round of review now. there's a few TODOs that i tossed in there to get some of your input on. i'll leave my own comments to start some conversation!

one general question i had - how can i run this api server locally & test these endpoints? i'm thinking i'd just use postman to try a few queries out. i don't see any place to npm start though, so pointing me in the right direction would be awesome 😁

Copy link
Contributor Author

@DrewMcArthur DrewMcArthur left a comment

Choose a reason for hiding this comment

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

notes

Comment on lines -3 to -14
import fetch from 'node-fetch'

function apiRequest(path: string, method: string, data: any) {
return fetch(path, {
headers: {
'Content-Type': 'application/json',
},
method,
redirect: 'follow',
body: JSON.stringify(data),
}).then((res) => res.json())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can revert this if y'all want, so i'm not touching the other existing endpoints - should probably be done in a separate refactoring PR 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i saw this function was getting reused, so i figured pulling it out to be imported would be better. let me know if this should go somewhere else though!

Copy link
Member

Choose a reason for hiding this comment

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

looks good to me, just wanted to flag this for you @ipatka since the function affects the aave repo

@@ -0,0 +1,13 @@
import fetch from 'node-fetch';
import { HttpMethod } from './config';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo: should use the library that other files are importing

Comment on lines +1 to +3
export enum HttpMethod {
POST='POST',
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo: this should use a library rather than being our own custom enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i should maybe revert this change, but i do see some npm audit fixs we should do

@@ -16,6 +16,7 @@ export const handler: APIGatewayProxyHandlerV2 = async (event) => {
const eventId = event?.pathParameters?.id;
if (!eventId) return { statusCode: 400 };

// TODO: this could be pulled out to a generic file.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'd definitely like to pull out as many of these types as we can - especially makes it easier for someone writing their own endpoints, to be able to fill in a few specificities, rather than having to write the entirety of these functions

@thelastjosh
Copy link
Member

one general question i had - how can i run this api server locally & test these endpoints? i'm thinking i'd just use postman to try a few queries out. i don't see any place to npm start though, so pointing me in the right direction would be awesome 😁

My impression is that this should be straightforward supposing that the endpoints are up on The Graph. @ipatka ?

Copy link
Member

@thelastjosh thelastjosh left a comment

Choose a reason for hiding this comment

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

Looked through the PR; the body of it looks good! If you could share an example of the JSON pulled through the endpoint that would be excellent.

@DrewMcArthur DrewMcArthur marked this pull request as ready for review April 8, 2023 01:22
@DrewMcArthur
Copy link
Contributor Author

one general question i had - how can i run this api server locally & test these endpoints? i'm thinking i'd just use postman to try a few queries out. i don't see any place to npm start though, so pointing me in the right direction would be awesome 😁

My impression is that this should be straightforward supposing that the endpoints are up on The Graph. @ipatka ?

@thelastjosh @ipatka
so i can cd Implementations/API && npm install && npm start, but it asks for either a stage, or it will use my ~/.aws/credentials by default. I don't have that setup, though i could setup a personal account, i'd guess that it would need some permissions?

ideally, there should be a "local-only" development version that i can run, but i don't see how to do that.

@Rashmi-278
Copy link
Member

Hi @DrewMcArthur,
Could we work on this together to complete and merge this?

@DrewMcArthur
Copy link
Contributor Author

@Rashmi-278 yeah would love to! i've messaged you on slack.

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.

Endpoints for Gitcoin DAO
3 participants