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

[#170333527] Service logo upload function #10

Merged
merged 28 commits into from
Feb 11, 2020
Merged

Conversation

alexgpeppe
Copy link
Contributor

This PR aims to add a new function to upload the logo of an existing service.

@digitalcitizenship
Copy link

digitalcitizenship commented Feb 10, 2020

Affected stories

  • 🌟 #170333527: Come frontend voglio poter caricare un nuovo logo dell'ente su uno storage permanente

New dependencies added: @types/lolex and lolex.

@types/lolex

Author: Unknown

Description: TypeScript definitions for lolex

Homepage: http://npmjs.com/package/@types/lolex

Createdover 3 years ago
Last Updated7 days ago
LicenseMIT
Maintainers1
Releases22
Direct Dependencies
README

Installation

npm install --save @types/lolex

Summary

This package contains type definitions for lolex (https://github.com/sinonjs/lolex).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lolex.

Additional Details

  • Last updated: Fri, 15 Nov 2019 20:14:14 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Wim Looman (https://github.com/Nemo157), Josh Goldberg (https://github.com/joshuakgoldberg), Rogier Schouten (https://github.com/rogierschouten), and Yishai Zehavi (https://github.com/zyishai).

lolex

Author: Christian Johansen

Description: Fake JavaScript timers

Homepage: http://github.com/sinonjs/lolex

Createdabout 5 years ago
Last Updated7 days ago
LicenseBSD-3-Clause
Maintainers4
Releases44
Direct Dependencies@sinonjs/commons
This README is too long to show.

Generated by 🚫 dangerJS

@codecov-io
Copy link

codecov-io commented Feb 10, 2020

Codecov Report

Merging #10 into master will decrease coverage by 1.06%.
The diff coverage is 81.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
- Coverage    86.5%   85.44%   -1.07%     
==========================================
  Files           7        8       +1     
  Lines         126      158      +32     
  Branches        8       10       +2     
==========================================
+ Hits          109      135      +26     
- Misses         17       23       +6
Impacted Files Coverage Δ
utils/middlewares/service.ts 85.71% <66.66%> (-14.29%) ⬇️
UploadServiceLogo/handler.ts 82.75% <82.75%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cd66db...cc0f226. Read the comment docs.

@alexgpeppe alexgpeppe changed the base branch from 170127598-extended-service-model to master February 10, 2020 11:25
}

// tslint:disable-next-line:no-object-mutation
context.bindings.logo = Buffer.from(logoPayload.logo, "base64");
Copy link
Contributor

Choose a reason for hiding this comment

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

can Buffer.from() fail ?

Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like you have to wrap it around a tryCatch() block:
https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't be necessary, because according to the documentation a TypeError will be thrown if logoPayload.logo is not an appropriate type, but its type is already checked and validated by the LogoPayload middleware inside the middlewaresWrap.

>;

export function UpdateServiceLogoHandler(
_GCTC: CustomTelemetryClientFactory,
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like the telemetryclient is unused

const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const logosHost = getRequiredStringEnv("LOGOS_HOST");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const logosHost = getRequiredStringEnv("LOGOS_HOST");
const logosHost = getRequiredStringEnv("SERVICE_LOGOS_HOST");

Copy link
Contributor

Choose a reason for hiding this comment

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

we must document this variable and the logos storage connection string into the readme (I know that it is empty atm)

}

export default httpStart;
import { Context } from "@azure/functions";
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like these files differs only for newlines, may you revert them ?

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'm sorry, I tried to revert, but I couldn't manage. 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

can you try removing the file and checkin it out again ? (or copyingit from another clone)

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 tried to copy it from another clone, also changing the core.autocrlf git setting for the project, but I couldn't manage to revert the line endings anyway... 😕

@alexgpeppe alexgpeppe requested a review from gunzip February 10, 2020 15:50
}

export default httpStart;
import { Context } from "@azure/functions";
Copy link
Contributor

Choose a reason for hiding this comment

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

can you try removing the file and checkin it out again ? (or copyingit from another clone)

README.md Outdated
| Variable name | Description | type |
| -------------------------------------- | --------------------------------------------------------------------------------- | ------- |
| SERVICE_LOGOS_HOST | The host name of the service logos storage | string |
| StorageConnection | The connectiong string used to connect to Azure Storage services | string |
Copy link
Contributor

Choose a reason for hiding this comment

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

is this is for the services logs I'd use a more explicit name as 'LogosStorageConnection'


return ResponseSuccessRedirectToResource(
{},
`${logosHost}/services/${serviceId}.png`,
Copy link
Contributor

Choose a reason for hiding this comment

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

naming: if this embeds https prefix then it's logosUrl (not an hostname), same states for the name of the environment variable

@gunzip gunzip merged commit 083b8c7 into master Feb 11, 2020
@gunzip gunzip deleted the 170333527-logo-upload branch February 11, 2020 16:01
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.

4 participants