npm install –global windows-build-tools https://www.npmjs.com/package/windows-build-tools https://stackoverflow.com/questions/32457761/how-to-solve-node-gyp-rebuild-issue-on-windows-10

繼續閱讀

What this Error? Example: transaction A get nonce 1 transaction B get nonce 2 transaction C get nonce 3 But blockchain package B、C first, then package A. If happen this step, get error. With truffle? Because Normal const wallet = new HDWalletProvider(mnemonic, url, id); const AContract = new TruffleContract(Json_contract); AContract.setProvider(wallet); wallet.addresses[] AContract. use contract api Sometime you call contract “set/write” api two times. Example: Create contract first. Write data into contract second.

繼續閱讀

import module providers service So if you want use some controllers(this controllers is in some module), this time need to import module. ???? =========== https://github.com/zelazna/NestAPI/tree/master/src Impotant: constructor don’t use new(). Use this.usersService. src/auth/auth.service.ts import { Component } from '@nestjs/common'; import { UsersService } from '../users'; @Component() ?? Injectable export class AuthService { constructor( private readonly usersService: UsersService, ) { } async validateUser(signedUser): Promise { const { email, password } = signedUser; const user = await this.

繼續閱讀

https://ithelp.ithome.com.tw/articles/10195523 Controller,透過Nest.js把metadata映射到我們自定義的route,Nest.js本身也有提供很多裝飾器,而且是對應Express框架,讓我們可以更好上手,更容易了解Controller層,可以寫出很Express風格的Controller。 Component,Nest.js裏頭很多東西都是Component,如:Service,Repository,Factory,Helper…,再透過依賴注入的方式,將Component注入到其他地方使用。 Module,Module是Nest.js專案的根基,Nest.js可以寫出Module tree風格的專案,Component可以注入到Module,如此,該Module底下的Controller和Component就屬同作用域,然後就可以依賴注入使用該Component。 Middleware,用Express框架的朋友應該不陌生,這概念雷同,在程式處理請求前,我們可以做些事情,這就是Middleware的功用,但要記得要調用next(),不然程式會卡在那XD,導入Middleware的方式上跟Express略有不同,多注意一下就好。 Exception Filter,錯誤處理層其實還蠻常使用,統一格式回給Client端或進行錯誤Log處理,這都蠻重要。我們可以繼承HttpException,做一個客製化的HttpException回應給Client,也可以繼承ExceptionFilter,做更多的錯誤處理(如Log)。 Pipe,Pipe可以將input data轉換成我們想要的output data,它也可以扛下參數資料驗證工作,在參數資料不正確時拋HttpException出來,這個錯誤會被ExceptionsHandler或自定義的Exception Filter所捕捉。 Guard,Guard就是擔任路由警衛,決定程式在收到HTTP請求後,是否要執行 route handler。 注意:客戶發動請求的流程為 Request->Middleware->Guard->Pipe->route handler。 Interceptor,我們可以透過Interceptor做些事情,像在請求前,完整記錄post過來的data,或在給予Client回應前,攔截一下,做些處理再返回,另外Interceptor 拋出的錯誤仍然可以被Exception Filter捕捉處理。

繼續閱讀

https://juejin.im/entry/59a6325d6fb9a024932228e0 version: "2" services: app: build: ./ restart: always ports: - "5000:8000" links: - db - redis depends_on: - db - redis environment: WAIT_HOSTS: db:3306 redis:6379 CMD ./scripts/docker/wait-for.sh && npm run deploy #!/bin/bash set -e timeout=${WAIT_HOSTS_TIMEOUT:-30} waitAfterHosts=${WAIT_AFTER_HOSTS:-0} waitBeforeHosts=${WAIT_BEFORE_HOSTS:-0} echo "Waiting for ${waitBeforeHosts} seconds." sleep $waitBeforeHosts # our target format is a comma separated list where each item is "host:ip" if [ -n "$WAIT_HOSTS" ]; then uris=$(echo $WAIT_HOSTS | sed -e 's/,/ /g' -e 's/\s+/\n/g' | uniq) fi # wait for each target if [ -z "$uris" ]; then echo "No wait targets found.

繼續閱讀

https://github.com/jiayisheji/blog/issues/18 vs code推荐插件:(其他插件自己随意) Debugger for Chrome – 调试 ejs – ejs文件高亮 Beautify – 代码格式化 DotENV – .env文件高亮 Jest – nest默认测试框架支持 TSLint – ts语法检查 TypeScript Hero – ts提示 vscode-icons – icons

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan