apiで掲示板を作るまで
BlueMixを使う
- IBM Knowledge Center
- Herokuでbotを運用する時代は終わった。これからはIBM Bluemixを使って無料で運用する - Qiita
- Getting Started - API Connect
- my-notes サンプル
nodeの管理用 yarn
nodebrew
- こちらでアップデートしてみる
nodeが古い
$ nodebrew ls v6.9.1 v7.0.0 current: v6.9.1 $
最新版(v6.11.3)を探す
$ nodebrew ls-remote ... v6.0.0 v6.1.0 v6.2.0 v6.2.1 v6.2.2 v6.3.0 v6.3.1 v6.4.0 v6.5.0 v6.6.0 v6.7.0 v6.8.0 v6.8.1 v6.9.0 v6.9.1 v6.9.2 v6.9.3 v6.9.4 v6.9.5 v6.10.0 v6.10.1 v6.10.2 v6.10.3 v6.11.0 v6.11.1 v6.11.2 v6.11.3 ...
最新版(v6.11.3)をインストール
$ nodebrew install-binary v6.11.3 $ nodebrew ls v6.9.1 v6.11.3 v7.0.0 current: v6.9.1 $
最新版(v6.11.3)に切り替え
$nodebrew use v6.11.3
apic edit で謎のエラー
{ Error: Cannot find module './build/Release/DTraceProviderBindings' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/magnet/.nodebrew/node/v6.11.3/lib/node_modules/apiconnect/node_modules/dtrace-provider/dtrace-provider.js:18:23) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) code: 'MODULE_NOT_FOUND' }
- DtraceProviderBindings errors on OS X (maybe related to "mv") · Issue #424 · trentm/node-bunyan · GitHub
- bunyan のバージョンが低いらしい、(bunyan ってなんだ??)
MagsBook:~ magnet$ npm ls -g |grep bunyan npm ERR! missing: extend@3.0.0, required by superagent@1.8.5 npm ERR! missing: qs@^6.2.1, required by strong-remoting@2.32.3 npm ERR! missing: options@latest, required by sse@0.0.6 npm ERR! missing: generator-swiftserver@prerelease, required by apiconnect-cli-swiftserver@1.0.8 │ │ ├─┬ bunyan@1.8.12 │ │ │ │ ├── bunyan@1.8.12 deduped │ │ │ │ ├── bunyan@1.8.12 deduped MagsBook:~ magnet$
bunyan
- log出力ライブラリらしい
- ログ出力ライブラリ node-bunyan - まるまるこふこふ
- bunyan
- bunyan 1.8.12 は最新版(2017/10/21時点)
- DtraceProviderBinding :: module not found error · Issue #361 · trentm/node-bunyan · GitHub
- bunyan 内で、dtrace-provider を使っているらしいのだが、これが古いらしい
MagsBook:~ magnet$ npm ls -g |grep dtrace npm ERR! missing: extend@3.0.0, required by superagent@1.8.5 npm ERR! missing: qs@^6.2.1, required by strong-remoting@2.32.3 npm ERR! missing: options@latest, required by sse@0.0.6 npm ERR! missing: generator-swiftserver@prerelease, required by apiconnect-cli-swiftserver@1.0.8 │ │ │ ├─┬ dtrace-provider@0.8.5 │ │ │ │ ├─┬ dtrace-provider@0.7.1 MagsBook:~ magnet$
33 dtrace-providerの最新は、0.8.5(2017/10/21時点)
解消しないので、無視
ssl 証明書
qiita
- apiconnectに関する34件の投稿 - Qiita
- apiconnect v2.0.18における旧verとの差分 - Qiita
- API Connectの開発者ポータルをカスタマイズしてみよう! - Qiita
ApiDesigner でエラー
- explorer のサンプルを実行するとエラー
curl --request POST \ --url https://localhost:4002/api/Notes \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-ibm-client-id: default' \ --header 'x-ibm-client-secret: SECRET' \ --data '{"title":"zacud","content":"hamxxx"}'
No response received. Causes include a lack of CORS support on the target server, the server being unavailable, or an untrusted certificate being encountered. Clicking the link below will open the server in a new tab. If the browser displays a certificate issue, you may choose to accept it and return here to test again. https://localhost:4002/api/Notes
参考
gateway ではなく、アプリケーションに直接アクセスだと登録できる
- post
curl --request POST \ --url http://localhost:4001/api/Notes \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-ibm-client-id: default' \ --header 'x-ibm-client-secret: SECRET' \ --data '{"title":"zacud","content":"hamxxx"}'
- get
$ curl -XGET http://localhost:4001/api/Notes [{"title":"zacud","content":"hamezt","id":1},{"title":"zacud","content":"hamxxx","id":2}] $
apiconnect license をコマンドラインで許可する
- Any command to accept apiconnect license? - dWAnswers
- IBM API Connect のデベロッパーズ・ツールキットをインストール・バージョンアップする方法 - Qiita
- Bash - スクリプトでカーソル位置移動! - mk-mode BLOG
- tput を理解する
- https://www.ibm.com/support/knowledgecenter/en/SSMNED_5.0.0/com.ibm.apic.toolkit.doc/rapim_cli_command_summary.html
- apic --accept-license
2017-10-22T10:13:38.716151+00:00 heroku[web.1]: Starting process with command `apic --accept-license --disable-analytics edit` 2017-10-22T10:13:45.950744+00:00 app[web.1]: Express server listening on http://127.0.0.1:55094 2017-10-22T10:14:38.841235+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-10-22T10:14:38.841364+00:00 heroku[web.1]: Stopping process with SIGKILL 2017-10-22T10:14:38.965097+00:00 heroku[web.1]: Process exited with status 137 2017-10-22T10:14:38.979549+00:00 heroku[web.1]: State changed from starting to crashed
- port を変える必要あり
参考
- Node.jsのアプリをHerokuにデプロイするときポート番号に気をつけなくちゃいけない - Qiita
- 動的ポートの設定の仕方
- Heroku:(Application Errorにならないための)Node.jsアプリのデプロイ入門 - Qiita
- strongloop/strongloop-buildpacks - Buildpacks - Heroku Elements
- Heroku で ポート指定しないタイプの Node.js アプリをデプロイする時につまづいたこと - Qiita
- Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch) - Stack Overflow
- Herokuでデプロイエラーが起きた - KayaMemo
- node.js - Port timeout deploying Loopback app to Heroku - Stack Overflow
- config.json | LoopBack Documentation
- Node.js(Express) 事始め & Heroku へデプロイまでのメモ - Qiita
app.set('port', (process.env.PORT || 5000));