-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#175441170] Add Organization and Service logo's upload #110
Conversation
Affected stories
New dependencies added: @types/jestAuthor: Unknown Description: TypeScript definitions for Jest Homepage: http://npmjs.com/package/@types/jest
|
Created | over 8 years ago |
Last Updated | 15 days ago |
License | MIT |
Maintainers | 8 |
Releases | 261 |
Direct Dependencies | @jest/core , import-local and jest-cli |
Keywords | ava, babel, coverage, easy, expect, facebook, immersive, instant, jasmine, jest, jsdom, mocha, mocking, painless, qunit, runner, sandboxed, snapshot, tap, tape, test, testing, typescript and watch |
README
Jest
🃏 Delightful JavaScript Testing
-
👩🏻💻 Developer Ready: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project.
-
🏃🏽 Instant Feedback: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files.
-
📸 Snapshot Testing: Jest can capture snapshots of React trees or other serializable values to simplify UI testing.
Read More: https://jestjs.io/
ts-jest
Author: Kulshekhar Kabra
Description: A preprocessor with source maps support to help use TypeScript with Jest
Homepage: https://kulshekhar.github.io/ts-jest
Created | about 4 years ago |
Last Updated | 8 days ago |
License | MIT |
Maintainers | 3 |
Releases | 133 |
Direct Dependencies | @types/jest , bs-logger , buffer-from , fast-json-stable-stringify , jest-util , json5 , lodash.memoize , make-error , mkdirp , semver and yargs-parser |
Keywords | jest, typescript, sourcemap, react and testing |
Generated by 🚫 dangerJS
src/app.ts
Outdated
withRequestMiddlewares( | ||
getApiClientMiddleware(), | ||
getUserFromRequestMiddleware(), | ||
RequiredParamMiddleware("serviceId", NonEmptyString), |
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 we use ServiceId
as type instead of NonEmptyString
?
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.
thanks
src/app.ts
Outdated
withRequestMiddlewares( | ||
getApiClientMiddleware(), | ||
getUserFromRequestMiddleware(), | ||
RequiredParamMiddleware("organizationFiscalCode", NonEmptyString), |
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 we use ÒrganizationFiscalCode
as type ?
src/controllers/services.ts
Outdated
.chain(user => | ||
checkAdminTask(user).chain(() => | ||
uploadOrganizationLogoTask(organizationFiscalCode, serviceLogo).map( | ||
result => result | ||
) | ||
) |
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 we flat this chain's pipeline ? i.e:
.chain(user => | |
checkAdminTask(user).chain(() => | |
uploadOrganizationLogoTask(organizationFiscalCode, serviceLogo).map( | |
result => result | |
) | |
) | |
.chain(user => | |
checkAdminTask(user) | |
).chain(() => | |
uploadOrganizationLogoTask(organizationFiscalCode, serviceLogo) | |
) |
src/controllers/services.ts
Outdated
return getApimUserTask(apiClient, authenticatedUser) | ||
.chain(user => | ||
checkAdminTask(user).chain(() => | ||
uploadOrganizationLogoTask(organizationFiscalCode, serviceLogo).map( |
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.
Why map
without change right's value?
src/middlewares/upload_logo.ts
Outdated
response.isSome() | ||
? taskEither.of(response.value) | ||
: fromLeft( | ||
ResponseErrorNotFound( | ||
"API user not found", | ||
"Cannot find a user in the API management with the provided email address" | ||
) | ||
) |
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 response
is an option we should name it as maybeResponse
. Aside can we use fold
?
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.
Thanks,
fold
is better.
src/middlewares/upload_logo.ts
Outdated
).foldTaskEither( | ||
error => fromLeft(error), | ||
errorOrResponse => | ||
errorOrResponse && errorOrResponse.status === 201 |
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 errorOrResponse
be undefined
?
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.
Yes, can be undefined according to uploadServiceLogo
defined in api_client.ts.
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.
Ok so if it can ben undefined, maybe we can wrap it into an option with fromNullable
:)
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.
That's something that does not sound good to me. I think that the response body could be undefined
, so the entire either errorOrResponse
could not imho.
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.
The methods defined in api-client.ts
return :
Promise<IResponseType<404, Error, never> | ... 4 more ... | undefined>
so the entireerrorOrResponse
can be undefined.
The code to avoid undefined could impact all methods ofapi-client.ts
(maybe we could do it in a dedicated PR)
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.
To use this definition I have to change apiResponseDecodeer
, or maybe I create one to use only for new methods ?
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.
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.
In this project there is already a client that is not generated with io-utils
. I added the service to this but the problem is that in case of 400, the body is decoded as Error
while in the model generated with io-utils
is decoded as ProblemJson
.
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.
However undefined
depends on how the client is defined in this project, there is a utility method that does a similar thing:
io-developer-portal-backend/src/api_client.ts
Line 197 in 8b5ef26
export function toEither<T>( |
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.
Ok, for the moment let's use the utility to avoid directly check undefined
response. Btw, when it's possible, we have to do another PR with io-utils upgrade 👍
src/middlewares/upload_logo.ts
Outdated
).foldTaskEither( | ||
err => fromLeft(err), | ||
errorOrResponse => | ||
errorOrResponse && errorOrResponse.status === 201 |
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.
ditto
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.
Yes, (as for uploadServiceLogo
) can be undefined according to uploadOrganizationLogo
defined in api_client.ts
.
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.
ditto
ping :) |
👆 |
if it's ok as I used |
needs rebasing (see conflicts) |
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.
LGTM, fromNullable
it's ok for now.
This PR introduces two new endpoints, according to the following definition: