feat(gzip): add gzip compression on update bot#137
Conversation
|
|
||
| import { JsonObject, Component } from "merapi"; | ||
| import { IHelper } from "interfaces/main"; | ||
| const pkg = require("../../package.json"); |
There was a problem hiding this comment.
ak kurang yakin apakah kita benar2 perlu ini 😅
There was a problem hiding this comment.
ini buat ambil sourcing version nya kan?
| this.timeout = this.helper.getProp("timeout") as number || 300000; | ||
| this.gzip = this.helper.getProp("gzip") as string || "false"; |
There was a problem hiding this comment.
ini seperti hidden features di sini 😂
mungkin kita perlu mendokumentasikannya lebih baik untuk options yg bisa dipakai oleh user
There was a problem hiding this comment.
iya. aku kepikiran ide, kalo saat push, file size nya dibaca dulu, baru user bs milih mau di push pake di-compress atau nggak, gimana mas? wkkk
| this.spinner = ora({ | ||
| discardStdin: false, | ||
| spinner: "line", | ||
| }) |
There was a problem hiding this comment.
ini untuk progress barnya. ak memilih spinner yg line karena hanya itu saja yg disupport di Windows
There was a problem hiding this comment.
iya gpp lah mas. padahal yg dots lebih ai-ketching ya lol
| const url = `${this.api.apiClient.basePath}/projects/${projectId}/bot/revisions/${latestBotRevision}`; | ||
| const requestConfig: AxiosRequestConfig = { | ||
| headers: { | ||
| "Authorization": this.api.bearer.apiKey, | ||
| "user-agent": `kata-cli@${this.api.version}`, | ||
| }, | ||
| timeout: this.api.timeout, | ||
| } |
There was a problem hiding this comment.
kita pke axios untuk custom requestnya. agak tedious pada saat ngebuild url nya
There was a problem hiding this comment.
gpp mas, sementara gini aja dulu. nanti di kata-cli yg baru dibikin schema api call buat axios request nya biar g tedious
| const botString = JSON.stringify(data); | ||
| headers["content-encoding"] = "deflate"; | ||
| headers["content-type"] = "application/json"; |
There was a problem hiding this comment.
api gateway kita perlu dua headers ini supaya bisa decompress data yg terkirim
| const botString = JSON.stringify(data); | ||
| headers["content-encoding"] = "deflate"; | ||
| headers["content-type"] = "application/json"; | ||
| const gzip = zlib.deflateSync(botString, { }); |
There was a problem hiding this comment.
kita menggunakan stdlib compression punya nodejs karena saat ini api gateway kita masih belum bisa handle compression dari library lain
| @@ -0,0 +1,83 @@ | |||
| { | |||
| "name": "kata-cli", | |||
| "version": "2.5.0", | |||
There was a problem hiding this comment.
ini harusnya 2.5.1, bs di tsc lagi dulu
this PR will add gzip compression on update bot method. Why use gzip on update bot? Sometimes our users have enormous size of bot definitions and the http library (on zaun library) only has 60sec timeout by default (sadly we can't change it tho). Thus we need to change the update bot mechanism using another http client library