LoginSignup
5
1

More than 5 years have passed since last update.

Nestのインストールと実行

Last updated at Posted at 2018-06-07

Nestとは

NestとはNode.jsのサーバーサイドアプリ構築用フレームワークで、Angularから影響を受けTypeScriptで構築されています。サーバーサイド版Angularの様なイメージでしょうか。

ドキュメント曰く、「すぐに使用できるアプリケーションアーキテクチャの提供を目指していて、テスト可能でスケーラブルであり、疎結合で簡単に保守可能なアプリケーションを手軽に作成できる」とあります。

インストール

ドキュメントに沿ってインストールしてみます。ドキュメントには「CLI」「GIT」「NPM」の3パターンありますが、今回は「GIT」で落とします。

$ git clone https://github.com/nestjs/typescript-starter.git app
$ cd app
$ npm install

アプリ実行

前回構築したDocker+NodeJS環境のマウントしたappフォルダにクローンし、コンテナを起動すると下記の様なログが出力され起動します

2018-06-07T03:23:20.117293200Z 
> nest-typescript-starter@1.0.0 start /home/node/app
> ts-node -r tsconfig-paths/register src/main.ts
2018-06-07T03:23:20.122012200Z 
[Nest] 21   - 6/7/2018, 3:23:27 AM   [NestFactory] Starting Nest application...
[Nest] 21   - 6/7/2018, 3:23:27 AM   [InstanceLoader] AppModule dependencies initialized +6ms
[Nest] 21   - 6/7/2018, 3:23:27 AM   [RoutesResolver] AppController {/}: +17ms
[Nest] 21   - 6/7/2018, 3:23:27 AM   [RouterExplorer] Mapped {/, GET} route +5ms
[Nest] 21   - 6/7/2018, 3:23:27 AM   [NestApplication] Nest application successfully started +1ms

私は「Docker for Windows」を使用してるので、デフォルトのlocalhost「http://localhost:3000 」に接続。

何とも簡素な「Hello World!」が確認できました。

まとめ

Nestは標準でTypeScriptが使え、Fastifyなども組み込めたりして個人的に面白そうなフレームワークだと思っています。
なのでこれから色々いじって記事に出来たらと思います。

5
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
5
1