Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Develop export server with Node.js

Takumi Kaji
February 18, 2022
69

Develop export server with Node.js

Takumi Kaji

February 18, 2022
Tweet

Transcript

  1. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Develop export server with Node.js Takumi Kaji
  2. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 About me • Software Engineer ◦ 主にサーバサイド ◦ Ruby, Go 多め ◦ やりたいこととフェーズに合わせた適切な 技術選定出来るようになりたい • 最近海外のエンジニアとも仕事し始めた ◦ 日本チーム + 現地のベトナムチーム Takumi Kaji
  3. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 少し前に開発したもの • 画像にお絵描きして共有出来るシステム ◦ Web, iOS がある • お絵描きしたものを画面からPDFでダウンロード出来るようにした ◦ 描いたものも付いた状態で ◦ その位置と形は出来るだけクライアントと同じように合わせた
  4. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 開発要件 • Web, アプリの両方から書き出しを行えるようにしたい • 出力したものを紙に印刷して使ったりするので、出来るだけ綺麗に出力したい 当初Webフロントでスクショしたものを空のPDFに貼り付けて出そうかと思ったけど、諦めてサーバ 側で1から作っていくことにした ↓
  5. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 開発するにあたって思ったこと Web側でsvgタグの生成ロジックがあるからそれを真似して画像化して元々アップロードされていたPDFに貼り付ければ やりたいことが出来そう。しかし • メモリ・CPUをたくさん食いそう • 処理完了まで時間もかかりそう • Rubyに良さそうなライブラリが少なそう ◦ 実際に探してみたが、あまり良い事例が無さそうだった → 今あるRuby/Rails側に足していくのは得策では無いと判断
  6. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 調査した結果 • エクスポート用のサーバをNode.js で書こう ◦ やりたいことを実現するためのライブラリや実装例 が多かった ◦ TypeScriptで書けば型も付いて安全に修正してい けそう ◦ Webフロントが強いエンジニアも開発できそう • DBのレコード追加を起点にした非同期処理で作ろう ◦ Node サーバは一定時間ごとにDBにレコードあるか 見に行く形に ◦ スケールしてきたらpush型の仕 組みに変えてアプ リケーション内のポーリングをやめたい
  7. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 開発してみて • 発表者はNode.jsでサーバ作るのは初 ◦ JS, TSもReactちょっと書いたことありますくらい ◦ 自分で1から作っていくケースは初だった • 「仕事ですぐに使えるTypeScript」にだいぶ助けられた ◦ 特に環境構築とデプロイの仕方周り ◦ 良い資料ありがとうございます🙏
  8. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 作ってリリースしてみてどうだったか • 最初に計画していた時期にリリースが間に合った! • 割と使われているがしっかり動いている ◦ ユーザが画像にお絵描きするモチベーションにもなってそう • エンハンスにも対応しやすかった ◦ 他の出力形式だったり、新しい種類のお絵描きだったり追加で開発した ◦ ライブラリが多いので何かしら見つかる ◦ 型があるのである程度コードを書く際に安心感がある • ベトナムチームのエンジニアも手伝ってくれる ◦ めちゃ助かってる 🙏
  9. Copyright © 2020 Present ANDPAD Inc. This information is confidential

    and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Thank you for listening!