基於typescript 強大的 nestjs 框架試用

nestjs 一個nodejs 的graphql 框架node

安裝

npm i -g @nestjs/cli

初始化項目

nest new dalong

運行demo

使用yarngit

yarn start

添加graphql支持

參考官方demo sample/12-graphql-apollogithub

  • 運行
yarn && yarn start
  • 效果
  • 操做
    添加

    查詢

源碼結構說明

代碼比較簡單,寫過angular 的基本均可以看懂,主要是依賴注入,服務定義,以及graphql schema 定義,graphql resovler 編寫
同時代碼包含了一個subscription 的功能(基於ws 包, graphql 的實現基於apollo 以及express 代碼仍是很清晰的。

參考資料

https://docs.nestjs.com/
https://github.com/nestjs/nest/tree/master/sampleexpress

相關文章
相關標籤/搜索