Express
デファクトスタンダードなNode.jsのserver library
昔から使われているのと、利用者が多いのとで、転がっている記事の質があまり良くない印象がある

TSではなくJSを使っていたり、書き方が粗雑だったりする
TypeScript firstではないので、チラホラ
運用でカバーが必要な箇所が散見される

例えば next()
の呼び忘れとか、到達しないroute関数の存在は、静的に気付けない
examples
middlewareを追加すると、reqにpropertyが生えるので、それを入れる必要がある
例.tsdeclare global {
namespace Express {
interface Request {
timedout: number;
}
}
}
tsdeclare module 'express' {
interface Request {
timedout: number;
}
}
そのmiddlewareがts firstになっていれば、libraryを入れれば上のような定義が自動で入っているはず
rootのファイルにroutingをベタベタ書いていくの、どうにかならんのか?
できれば型で定義したいんだけど

こんな感じに書くか
tsmain();
function main() {
const app = express();
settings(app);
routes(app);
run(app);
}
function settings(app: Express) {
app.use(cors());
}
function routes(app: Express) {
app.use('/users', users);
}
function run(app: Express) {
app.listen(3001, () => console.log('Server is running'));
}
appがinstanceなので、全然純粋じゃなくてキモい
関連するlibraryとか
ひな形を生成する
jadeとか要らんもの入ってくるの嫌だな

JSだし

めちゃくちゃ小さいので、参考にはなるが使う必要なくない?という気がする

typescript版
Next.jsの拡張基盤とすることもできるらしい
ベスプラ
routingの静的解析ツール
logger
nodejsのベスプラ