前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >The Things Network LoRaWAN Stack V3 学习笔记 2.7.1 Web 前端开发调试

The Things Network LoRaWAN Stack V3 学习笔记 2.7.1 Web 前端开发调试

作者头像
twowinter
发布2020-04-17 12:17:19
3760
发布2020-04-17 12:17:19
举报
文章被收录于专栏:twowintertwowinter

前言

上一篇研究了如果编译运行 Web 前端,这一篇研究如何在开发模式下调试 Web 前端。

小能手这段时间在学习 The Things Network LoRaWAN Stack V3,从使用和代码等角度对该 Stack 进行了分析,详细可点此查看

1 官方介绍

For development purposes, the frontend can be run using webpack-dev-server. After following the Getting Started section to initialize the stack and doing an initial build of the frontend via mage js:build, it can be served using:

代码语言:javascript
复制
export NODE_ENV=development
mage js:serve

The development server runs on http://localhost:8080 and will proxy all api calls to port 1885. The serve command watches any changes inside pkg/webui and refreshes automatically.

In order to set up the stack to support running the frontend via webpack-dev-server, the following environment setup is needed:

代码语言:javascript
复制
NODE_ENV=development
TTN_LW_LOG_LEVEL=debug
TTN_LW_IS_OAUTH_UI_JS_FILE=libs.bundle.js,oauth.js
TTN_LW_CONSOLE_UI_JS_FILE=libs.bundle.js,console.js
TTN_LW_CONSOLE_UI_CANONICAL_URL=http://localhost:8080/console
TTN_LW_CONSOLE_OAUTH_AUTHORIZE_URL=http://localhost:8080/oauth/authorize
TTN_LW_CONSOLE_OAUTH_TOKEN_URL=http://localhost:8080/oauth/token
TTN_LW_IS_OAUTH_UI_CANONICAL_URL=http://localhost:8080/oauth
TTN_LW_IS_EMAIL_NETWORK_IDENTITY_SERVER_URL=http://localhost:8080/oauth.js
TTN_LW_CONSOLE_UI_ASSETS_BASE_URL=http://localhost:8080/assets

Note: We recommend using an environment switcher like direnv to help you setting up environments for different tasks easily.

All of the configuration options above can also be set using configuration files or runtime flags. For more info in this regard, see this guide.

2 本地实践

2.1 脚本准备

我是将这么多环境变量整合到一个脚本 frontend_dev.sh 里。

代码语言:javascript
复制
export NODE_ENV=development
export TTN_LW_LOG_LEVEL=debug
export TTN_LW_IS_OAUTH_UI_JS_FILE=libs.bundle.js,oauth.js
export TTN_LW_CONSOLE_UI_JS_FILE=libs.bundle.js,console.js
export TTN_LW_CONSOLE_UI_CANONICAL_URL=http://localhost:8080/console
export TTN_LW_CONSOLE_OAUTH_AUTHORIZE_URL=http://localhost:8080/oauth/authorize
export TTN_LW_CONSOLE_OAUTH_TOKEN_URL=http://localhost:8080/oauth/token
export TTN_LW_IS_OAUTH_UI_CANONICAL_URL=http://localhost:8080/oauth
export TTN_LW_IS_EMAIL_NETWORK_IDENTITY_SERVER_URL=http://localhost:8080/oauth.js
export TTN_LW_CONSOLE_UI_ASSETS_BASE_URL=http://localhost:8080/assets

2.2 操作步骤

此前官方介绍的操作步骤有一定的误导作用,环境变量设置之后必须重新编译前端和stack才行,具体见我提的 issue

  1. source ./frontend_dev.sh
  2. ./mage js:build
  3. go build ./cmd/ttn-lw-stack
  4. Identity Server 配置
代码语言:javascript
复制
$ ./ttn-lw-stack is-db init
$ ./ttn-lw-stack is-db create-admin-user --id admin --email admin@localhost
$ ./ttn-lw-stack is-db create-admin-user --id admin --email admin@localhost --password admin
# ./ttn-lw-stack is-db create-oauth-client --id console --name "Console" --owner admin --secret console --redirect-uri 'https://localhost:8080/console/oauth/callback' --redirect-uri 'http://localhost:8080/console/oauth/callback' --redirect-uri '/console/oauth/callback'

END


iotisan 博客专家

发布了251 篇原创文章 · 获赞 253 · 访问量 84万+

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 1 官方介绍
  • 2 本地实践
    • 2.1 脚本准备
      • 2.2 操作步骤
      • END
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档