-
Notifications
You must be signed in to change notification settings - Fork 25
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
[#175072065] EXPERIMENTAL: Start io-backend as Azure Function #722
base: master
Are you sure you want to change the base?
Conversation
Affected stories
New dependencies added: @azure/functionsAuthor: Microsoft Description: Azure Functions types for Typescript Homepage: http://npmjs.com/package/@azure/functions
|
Created | over 1 year ago |
Last Updated | 4 days ago |
License | MIT |
Maintainers | 4 |
Releases | 88 |
Direct Dependencies | @azure/cosmos , applicationinsights , azure-storage , cidr-matcher , fp-ts , helmet , helmet-csp , io-functions-express , io-ts , italia-ts-commons , node-fetch , nodemailer , nodemailer-sendgrid , referrer-policy , rehype-stringify , remark-frontmatter , remark-parse , remark-rehype , request-ip , ulid , unified and winston |
README
io-functions-commons
Common code across Azure functions of project IO.
To release a new package on GitHub and npm:
yarn release-it <minor|major|patch>
Upgrading from 13.x to 14.x
Version 14.x is the first version that uses italia-utils 5.x,
a major upgrade to the package that generates the provided Typescript definitions.
This translates in the fact that you must upgrade italia-utils to a version >= 5.x
if you want to upgrade your deps using io-functions-common 14.x.
@types/mime
Author: Unknown
Description: TypeScript definitions for mime
Homepage: http://npmjs.com/package/@types/mime
Created | over 4 years ago |
Last Updated | about 2 months ago |
License | MIT |
Maintainers | 1 |
Releases | 17 |
Direct Dependencies |
README
Installation
npm install --save @types/mime
Summary
This package contains type definitions for mime (https://github.com/broofa/node-mime).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mime.
Additional Details
- Last updated: Wed, 22 Jul 2020 18:12:53 GMT
- Dependencies: none
- Global values:
mime
,mimelite
Credits
These definitions were written by Jeff Goddard, and Daniel Hritzkiv.
Generated by 🚫 dangerJS
// Parse an urlencoded body. | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
// Parse an urlencoded body. | ||
app.use(bodyParser.urlencoded({ extended: true })); |
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.
does SPID login work without this?
src/app.ts
Outdated
|
||
// | ||
// Define the folder that contains the public assets. | ||
// | ||
|
||
app.use(express.static("public")); | ||
app.get(/(\.html|\.svg|\.png)$/, async (req, res, next) => { |
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 guess the result of this call can be cached using appcache, what about this?
src/app.ts
Outdated
try { | ||
const path = "public" + req.path; | ||
if (!fs.existsSync(path)) { | ||
return next(); | ||
} | ||
const stat = await fs.promises.stat(path); | ||
if (stat.isDirectory()) { | ||
return next(); | ||
} | ||
const type = mime.lookup(path); | ||
if (type) { | ||
const charset = mime.charsets.lookup(type); | ||
res.setHeader( | ||
"Content-Type", | ||
// tslint:disable-next-line: restrict-plus-operands | ||
type + (charset ? `; charset=${charset}` : "") | ||
); | ||
} | ||
const content = await fs.promises.readFile(path); | ||
res.setHeader("Content-Length", stat.size); | ||
res.status(200).send(content); | ||
} catch (err) { | ||
log.error(`static|Error retrieving static file asset|error:%s`, err); | ||
return next(err); | ||
} |
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.
It's not clear to me why we introduced this behaviour. Besides that, we can put this in a middleware function (req, res, next)=>void
and we can give this chunk an explicit meaning.
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 logic is required because the express default static
folder (ref) doesn't work inside Azure functions. Here we emulate what static
middleware does. We can create a specific middleware, but this code will be used only on this endpoint.
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.
we can just move it in a function declared inside the same module
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.
Fixed in 94282ce
@@ -175,7 +173,7 @@ describe("SessionLockController#unlockUserSession", () => { | |||
mockRedisUserMetadataStorage | |||
); | |||
|
|||
const response = await controller.lockUserSession(req); | |||
const response = await controller.unlockUserSession(req); |
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.
😅
* update spid-commons * revert typo * update spid-commons
* [#175679733] Add GetSupportToken API * [#175679733] Add tests + minor refactoring * [#175679733] env.example update * [#175679733] Refactor over review * [#175679733] Minor refactor over review * [#175679733] Fix tests * [#175679733] Remove useless attribute * [#175679733] Minor refactor over review * [#175679733] refactor env variable decoding * [#175679733] Fix tests
* [#176003320] Return 500 instead of 401 on system errors * Fix done param Co-authored-by: danilo spinelli <danilo.spinelli@pagopa.itt>
Co-authored-by: pasqualedevita <>
Co-authored-by: pasqualedevita <>
Co-authored-by: pasqualedevita <>
Codecov Report
@@ Coverage Diff @@
## master #722 +/- ##
==========================================
- Coverage 79.67% 79.13% -0.55%
==========================================
Files 68 68
Lines 2298 2320 +22
Branches 375 375
==========================================
+ Hits 1831 1836 +5
- Misses 454 471 +17
Partials 13 13
Continue to review full report at Codecov.
|
No description provided.