supertestモジュールを使うとexpressのrouteのテストがすごく楽にかけます。 実装サンプルを載せてみました。 環境 express4.2 supertest0.1.3 mocha 1.20.0 shoud 4.0.0 テスト用express作成 本編とは関係ないですが、テスト用にアプリを作ります。 $ npm install express-generator $ express hoge $ cd hoge $ npm install テストコード作成 ルートディレクトリにtestという名前でディレクトリを作り、そこにテストコードを置いていきます。 $ mkdir -p test/routes ジェネレータで自動生成されるroutes/users.jsをテストしてみます。 ※アプリの立ち上げは必要ありません。 $ vim test/routes/users.test.js
Name-based Virtual Hosting とは バーチャルホスト(Virtual Host)とは1つのサーバで複数のドメインを運用する技術のことで、Webサーバ、メールサーバなどで利用される。 (中略) 名前ベースバーチャルホストは、利用するドメイン名すべてに同じIPアドレスを使用し、1つのサーバコンピュータに必要なIPアドレスが1つで済む。 クライアントが接続したドメインにかかわらず同じIPアドレスへ接続してくるため、IP層の情報だけではドメインの判別ができない。 ドメインを判別するためにはアプリケーションプロトコルの側に接続先ドメインを判別する情報が含まれている必要がある。HTTPの場合はHostヘッダ、SMTPの場合はRcpt Toに含まれるメールアドレスのドメインで判別を行なう。 バーチャルホスト - Wikipedia Apache では、 NameVirtualHo
今回の環境。 OS: Mac OS X Yosemite 10.10.2 Node.js はインストール済み。 $ node --version v0.10.29 npm install で swig モジュールと express モジュールをインストールする。 $ npm install swig swig@1.4.2 node_modules/swig ├── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.10) └── uglify-js@2.4.19 (uglify-to-browserify@1.0.2, async@0.2.10, source-map@0.1.34, yargs@3.5.4) $ npm install express express@4.12.3 node_modules/express ├── merge-des
Embedded below is essentially the simplest Express app you can create. It is a single file app — not what you’d get if you use the Express generator, which creates the scaffolding for a full app with numerous JavaScript files, Jade templates, and sub-directories for various purposes. const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('H
Installing Assuming you’ve already installed Node.js, create a directory to hold your application, and make that your working directory. Express 4.x requires Node.js 0.10 or higher. Express 5.x requires Node.js 18 or higher. $ mkdir myapp $ cd myapp Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s pa
Express application generator Use the application generator tool, express-generator, to quickly create an application skeleton. You can run the application generator with the npx command (available in Node.js 8.2.0). $ npx express-generator For earlier Node versions, install the application generator as a global npm package and then launch it: $ npm install -g express-generator $ express Display t
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く