0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Express 4におけるmiddlewareの扱い

Posted at

きっかけ

Express.jsをドットインストールで勉強してたが、動画のExpressは3系だった。手元のExpressのバージョンは4なのでいくつかの相違点があり、特にmiddlewareの使い方が大きく変わっている事がわかった。

結論

ほとんどのmiddleware(loggerなど)は個別にインストールする必要がある。


//ロガーの例
// Express 3
app.use(express.logger('dev'))

// Express 4
// まず`npm install morgan`が必要
logger = require('morgan')
app.use(logger('dev'))

参考

Express入門
https://dotinstall.com/lessons/basic_expressjs

Connect
https://github.com/senchalabs/connect#middleware

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?