-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up api #4
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
base: master
Are you sure you want to change the base?
Conversation
src/server/routes/auth.js
Outdated
| @@ -0,0 +1,23 @@ | |||
| const apiClient = require('../../gateway/codeship'); | |||
|
|
|||
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.
since this is a file inside the routes folder it should return a router
src/gateway/codeship.js
Outdated
| const password = process.env.CODESHIP_PASSWORD; | ||
| let authorization; | ||
|
|
||
| async function postAuth() { |
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.
rename the function to authenticate
src/gateway/codeship.js
Outdated
| return authorization; | ||
| } | ||
|
|
||
| function listProjects(organizationId) { |
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.
rename function to getProjects
src/gateway/codeship.js
Outdated
| }); | ||
| } | ||
|
|
||
| function listBuilds(organizationId, projectId) { |
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.
rename function to getBuilds, also check how you can only fetch the last build as opposed to all of them?
src/gateway/codeship.js
Outdated
| @@ -0,0 +1,61 @@ | |||
| require('dotenv').load(); | |||
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 should be moved to the config.js file, and should only happen when the NODE_ENV is development
src/gateway/codeship.js
Outdated
| const apiUrl = process.env.CODESHIP_API_URL; | ||
| const username = process.env.CODESHIP_USERNAME; | ||
| const password = process.env.CODESHIP_PASSWORD; | ||
| let authorization; |
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.
rename to authenticationResponse.
src/server/routes/auth.js
Outdated
| let projects = (await apiClient.listProjects(orgId)).projects; | ||
|
|
||
| // Embed the latest builds into each project | ||
| projects = await Promise.all(projects.map(async (project) => { |
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.
extract this function, and name it addBuildsToProject
| const router = require('express').Router(); | ||
|
|
||
| router.get('/', async (req, res) => { | ||
| async function appendBuildsToProjects(project) { |
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.
can you move this function out of the router function?
punitrathore
left a comment
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 look at the final comment :)
No description provided.