Steam controller support and easier setup for worker - #22
Merged
Conversation
Comment on lines
+131
to
+175
| ], async (req: Request, res: Response) => { | ||
| /* | ||
| #swagger.path = '/images/icon' | ||
| #swagger.tags = ['Images'], | ||
| #swagger.description = "Upload a custom application icon (png, jpg, webp, gif, avif, bmp, tiff, heic, etc.). Transparency is preserved where supported. Image is scaled to 256x256." | ||
| #swagger.responses[200] = { description: "Ok" } | ||
| #swagger.responses[400] = { description: "Bad request. See console for more info" } | ||
| #swagger.security = [ | ||
| {"apiKeyAuth": []}, | ||
| {"tokenAuth": []} | ||
| ] | ||
| */ | ||
| try { | ||
| if (!req.files?.file) { | ||
| res.status(400).send({ message: "No file named \"file\" was uploaded" }); | ||
| return; | ||
| } | ||
| const file = req.files.file as fileUpload.UploadedFile; | ||
|
|
||
| const allowedMimeTypes = [ | ||
| "image/png", "image/jpeg", "image/webp", "image/gif", | ||
| "image/bmp", "image/tiff", "image/avif", "image/svg+xml", | ||
| "image/heic", "image/heif", | ||
| ]; | ||
|
|
||
| if (!allowedMimeTypes.includes(file.mimetype)) { | ||
| res.status(400).send({ message: "Unsupported image format" }); | ||
| return; | ||
| } | ||
|
|
||
| const dataBuffer = readFileSync(file.tempFilePath); | ||
| const outputBuffer = await sharp(dataBuffer) | ||
| .resize(256, 256) | ||
| .png() | ||
| .toBuffer(); | ||
|
|
||
| const iconPath = resolve(this.protogen.imageDirectory + "/custom_icon.png"); | ||
| writeFileSync(iconPath, outputBuffer); | ||
|
|
||
| this.faviconCache = null; | ||
| res.send({ message: "Icon updated" }); | ||
| } catch (err) { | ||
| this.handleError(err, req, res); | ||
| } | ||
| }); |
| return; | ||
| } | ||
|
|
||
| const dataBuffer = readFileSync(file.tempFilePath); |
Comment on lines
+177
to
+201
| this.router.delete("/icon", this.authMiddleware, async (req: Request, res: Response) => { | ||
| /* | ||
| #swagger.path = '/images/icon' | ||
| #swagger.tags = ['Images'], | ||
| #swagger.description = "Clear the custom application icon, reverting to the default" | ||
| #swagger.responses[200] = { description: "Ok" } | ||
| #swagger.responses[404] = { description: "No custom icon set" } | ||
| #swagger.security = [ | ||
| {"apiKeyAuth": []}, | ||
| {"tokenAuth": []} | ||
| ] | ||
| */ | ||
| try { | ||
| const iconPath = resolve(this.protogen.imageDirectory + "/custom_icon.png"); | ||
| if (!existsSync(iconPath)) { | ||
| res.status(404).send({ message: "No custom icon is set" }); | ||
| return; | ||
| } | ||
| unlinkSync(iconPath); | ||
| this.faviconCache = null; | ||
| res.send({ message: "Icon cleared" }); | ||
| } catch (err) { | ||
| this.handleError(err, req, res); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.