[WIP] Feat/cloudflare#8
Conversation
ecomplus#6 * feat: creating cloudflare adapter * feat: cloudflare integration * feat: cloudflare integration * feat: cloudflare integration * feat: cloudflare integration * fix: ecom review ecomplus#1 * fix: ecom review ecomplus#1 * fix: ecom review ecomplus#3 * fix: ecom review ecomplus#4 * fix: ecom review ecomplus#4 * fix: ecom review ecomplus#5 * fix: ecom review ecomplus#6 * fix: ecom review ecomplus#7 * fix: ecom review ecomplus#8
| const respond = () => { | ||
| logger.log(`${storeId} ${key} ${bucket} All optimizations done`) | ||
| res.json({ bucket, key, uri, picture }) | ||
| key += `${v4()}-${filename}` |
There was a problem hiding this comment.
| key += `${v4()}-${filename}` | |
| key += `${Date.now()}-${filename}` |
acho que o uuid só pra isso aqui é exagero, principalmente porque ainda concatena com o filename original..
| // UUID Generator | ||
| const { v4 } = require('uuid') |
There was a problem hiding this comment.
| // UUID Generator | |
| const { v4 } = require('uuid') |
| const respond = (suc = true) => { | ||
| if (suc) { | ||
| logger.log(`${req.storeId} ${key} ${bucket} All optimizations done`) | ||
| res.json({ bucket, key, uri: picture['zoom'] ? picture['zoom'].url : '' , picture }) |
There was a problem hiding this comment.
na verdade se a zoom não existir teremos problemas haha
There was a problem hiding this comment.
aí a resposta não poderia ser 200
| const label = labels[labels.length - 1] | ||
|
|
||
| // Download image, zoom must be jpeg | ||
| download(vari, { 'Accept': label === 'zoom' ? 'image/jpeg,image/*,*/*;q=0.8' : 'image/webp,image/*,*/*;q=0.8' }, (err, imageBody) => { |
There was a problem hiding this comment.
| download(vari, { 'Accept': label === 'zoom' ? 'image/jpeg,image/*,*/*;q=0.8' : 'image/webp,image/*,*/*;q=0.8' }, (err, imageBody) => { | |
| download(vari, { 'Accept': label === 'zoom' ? 'image/png,image/jpeg,image/*,*/*;q=1' : 'image/webp,image/*,*/*;q=0.8' }, (err, imageBody) => { |
imagem zoom em qualidade 100%
| setTimeout(() => cloudflareClient.delete(`/images/v1/${id}`), 60000) | ||
| // Download the correct variations | ||
| variants.forEach(vari => { | ||
| if (vari.includes('normal') || vari.includes('zoom') || vari.includes('big') || vari.includes('w90')) { |
There was a problem hiding this comment.
problema é só que jogando pra cá você não considera mais o que vem do config
| // Download image, zoom must be jpeg | ||
| download(vari, { 'Accept': label === 'zoom' ? 'image/jpeg,image/*,*/*;q=0.8' : 'image/webp,image/*,*/*;q=0.8' }, (err, imageBody) => { | ||
| processed++ | ||
| if (err) logger.error(err) |
There was a problem hiding this comment.
não deveria encerrar o loop no erro?
| const contentType = label === 'zoom' ? 'image/jpeg' : 'image/webp' | ||
| const fileFormat = label === 'zoom' ? 'jpg' : 'webp' |
There was a problem hiding this comment.
ué mas a imagem original não necessariamente é jpg na verdade
| // async handle with callback URL | ||
| redisClient.setex(genRedisKey(id, true), 600, JSON.stringify(s3Options)) |
There was a problem hiding this comment.
isso aqui era só pra callback do cloudinary pra manipulação assíncrona na verdade, o cloudflare não envia esse webhook então isso não tem utilidade mais..
|
@Mazurco066 como tá no seu fork fica ruim pra eu editar umas coisas antes do merge, aí apesar dos comentários já vou dar merge e fixar os minors em outro commit em seguida... |
|
a25b8cf upload da |
Raw file