Update eject example to something more robust
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
- 領域
- cli, documentation
調査の方向性
この issue には eject のテンプレートファイルもテストも記載されていません。まず fastify-cli 内の eject の例を見つけ、生成されたアプリがどのようにプラグインを登録してサーバーを起動するかを確認してください。登録をリッスン開始前に検証し、.ready() を示すように例を更新してください。生成された例がこのフローを反映し、関連するチェックが通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Change the eject file example to validate everything before running the server and make use of the .ready() function.
Motivation
What made me think of this approach are:
- Fastify encapsulation concept, the server should not run if something goes wrong with
pluginsand are not loaded inside correctly inside Fastify. - The struggle I've been in the past few days trying to use Fastify in a complex real-world project and I didn't find clear examples.
- easier to handle errors, if something goes wrong Fastify will throw the valid error not some error buried deep inside the router or hooks
- the unclear error "cannot read properties of undefined (reading 'length')" which was happening for several reasons and I cannot detect them until i throw error on startup
Example
// Read the .env file.
import * as dotenv from "dotenv";
dotenv.config();
// Require the framework
import Fastify from "fastify";
// Require library to exit fastify process, gracefully (if possible)
import closeWithGrace from "close-with-grace";
// Instantiate Fastify with some config
const app = Fastify({
logger: true,
});
// make use of the `.ready()` to prevent going on race condition
fastify.register(app).ready((err) => {
// throw error if something happened on registering `plugins` or `routes`
if (err) throw err;
// delay is the number of milliseconds for the graceful close to finish
const closeListeners = closeWithGrace(
{
delay:
parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY as string) ||
500,
},
async function ({ signal, err, manual }) {
if (err) {
fastify.log.error(err);
}
await fastify.close();
} as closeWithGrace.CloseWithGraceAsyncCallback
);
fastify.addHook("onClose", async (instance, done) => {
closeListeners.uninstall();
done();
});
//server listen
const port = process.env.PORT || 8000;
// Start listening.
fastify.listen({ port: parseInt(port as string) }, (err: any) => {
if (err) {
fastify.log.error(err);
process.exit(1);
}
});
});
- 主要言語
- JavaScript
- スター
- 733
- フォーク
- 179
- 平均マージ
- 8日 12時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fastify/fastify-cli のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
fastify/fastify-cli#846 · コメント 2 件 ·
-
Options propagationオープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
fastify/fastify-cli#841 ·
-
Generated Fastify ESM/TS app has broken `npm test` command (FASTIFY_AUTOLOAD_TYPESCRIPT)対応中かも @GhaythBenAbid が 29 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
fastify/fastify-cli#835 · コメント 2 件 ·
-
Adding Path Alias Support in fastify-cli再び着手できるかも @ali139713 が 52 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
fastify/fastify-cli#806 · コメント 1 件 · リアクション 7 件 ·
-
Only watch specified directory (--watch CLI param)対応中かも @josephreilly22 が 242 日前に担当しました。 オープンgood first issue
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
fastify/fastify-cli#787 · コメント 5 件 · リアクション 2 件 ·
fastify/fastify-cli の issue をすべて見る
似ている issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
andromarces/agent-loops#886 ·
メンテナーはふだん 1 日以内に返信
-
bug effort:low model:light plan planner:gpt-6-1-sol tests
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
B: visual
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
FreeTubeApp/FreeTube#9929 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug: `--clear-screen` not very useful (at least not for dealing with large test/error output)オープンstatus: in triage type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
mochajs/mocha#6428 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
supabase/supabase-js#2768 ·
メンテナーはふだん 1 日以内に返信