以下は、express を使用した単純な node.js です。
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);
デフォルトでは というフォルダーがありplugins
、node.js の起動時に自動的に登録されるなど、プラグインイン アーキテクチャを実装したいのですが、メインを変更する必要はありません。server.js
foo
プラグインの例、例えば
PluginManager.register("init, function(app) {
app.get('/foo', function(req, res){
res.send('Hello from foo plugin');
});
});
次に、私server.js
の中には、次のようなものがあります
// TODO: Scan all scripts under the folder `plugins`
// TODO: Execute all the `init` hook before the app.listen
app.listen(3000);
私の問題は、プラグイン コードがすべて非同期であることです。 の前にブロックする方法がありapp.listen()
ません。より良いプラグイン アーキテクチャの実装について何か考えはありますか?
ありがとう。