EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

OpenID hydra dex

F... Now follow step run, Get level=error msg="An error occurred" debug="No CSRF value available in the session cookie" description="The request is not allowed" error=request_forbidden hint="You are not allowed to perform this action."

If you run same broswer and restart docker or clear cookie, do many way. Just try broswer private mode.



Try dex docker or binary failed, it's be pass.

Hydra docker-compose

1、get https://github.com/ory/hydra



docker-compose -f quickstart.yml -f quickstart-postgres.yml up --build

注意 quickstart.yml



run docker on host or run binary on host. hydra 5 minutes demo "IP Used" is 127.0.0.1



version: '3'

services:

  hydra:
    image: oryd/hydra:latest
    ports:
      - "4444:4444" # Public port
      - "4445:4445" # Admin port
      - "5555:5555" # Port for hydra token user
    command:
      serve all --dangerous-force-http
    environment:
      - URLS_SELF_ISSUER=http://127.0.0.1:4444
      - URLS_CONSENT=http://127.0.0.1:3000/consent
      - URLS_LOGIN=http://127.0.0.1:3000/login
      - URLS_LOGOUT=http://127.0.0.1:3000/logout
      - DSN=memory
      - SECRETS_SYSTEM=youReallyNeedToChangeThis
      - OIDC_SUBJECT_TYPES_SUPPORTED=public,pairwise
      - OIDC_SUBJECT_TYPE_PAIRWISE_SALT=youReallyNeedToChangeThis
    restart: unless-stopped

  consent:
    environment:
      - HYDRA_ADMIN_URL=http://hydra:4445
    image: oryd/hydra-login-consent-node:latest
    ports:
      - "3000:3000"
    restart: unless-stopped


run VM or real server is real ip. Ex: 192.168.99.100 (docker-machine)




version: '3'

services:

  hydra:
    image: oryd/hydra:latest
    ports:
      - "4444:4444" # Public port
      - "4445:4445" # Admin port
      - "5555:5555" # Port for hydra token user
    command:
      serve all --dangerous-force-http
    environment:
      - URLS_SELF_ISSUER=http://192.168.99.100:4444
      - URLS_CONSENT=http://192.168.99.100:3000/consent
      - URLS_LOGIN=http://192.168.99.100:3000/login
      - URLS_LOGOUT=http://192.168.99.100:3000/logout
      - DSN=memory
      - SECRETS_SYSTEM=youReallyNeedToChangeThis
      - OIDC_SUBJECT_TYPES_SUPPORTED=public,pairwise
      - OIDC_SUBJECT_TYPE_PAIRWISE_SALT=youReallyNeedToChangeThis
    restart: unless-stopped

  consent:
    environment:
      - HYDRA_ADMIN_URL=http://hydra:4445
    image: oryd/hydra-login-consent-node:latest
    ports:
      - "3000:3000"
    restart: unless-stopped


If have cors problems. see https://github.com/ory/hydra/blob/master/quickstart-cors.yml


Check hydra OpenID startup or not 確認是否正常啟動


http://192.168.99.100:4444/.well-known/jwks.json  


Create clients


Download hydra binary.

https://www.ory.sh/docs/next/hydra/install#download-binaries
https://github.com/ory/hydra/releases
https://github.com/ory/hydra/releases/tag/v1.0.0-rc.15

PS: Maybe version renew, so try to get best new.


hydra clients create --endpoint http://192.168.99.100:4445/ --id auth-code-client --secret secret --grant-types authorization_code,refresh_token --response-types code,id_token --scope openid,offline --callbacks http://127.0.0.1:5555/callback

! new version use endpoint, different before auth-url and token-url, But I think you still can use old way... Maybe

! scope "openid,offline" next step must use same. So scope is definend by yourself.

Thanks https://dotblogs.com.tw/liguobao/2018/12/30/132746


Check clients 查看clients


hydra clients list --endpoint http://192.168.99.100:4445 


Emu all step OpenID


Fllow website that run command pop website. If no pop, http://127.0.0.1:5555/



hydra token user --client-id auth-code-client --client-secret secret --endpoint http://192.168.99.100:4444 --port 5555 --scope openid,offline

This step will run server on port 5555

! here scope "openid,offline" must same before create.








Get userinfo. Copy Access Token replace string after Bearer



curl -X GET http://192.168.99.100:4444/userinfo -H 'Accept: application/json' -H 'Authorization: Bearer MmadDHs3VdWC7LZTIdBKUHyzgsWHe2XbzHpwjKrF7Rs.tXlg7rShEEbkcczNWJGS84sIvokTF6Ae7bhSQZfHMgA' 

Get json
{"sid":"c7d5665b-76e7-475a-95a8-cc521352663b","sub":"foo@bar.com"}


Modify edit add userinfo info.


https://github.com/ory/hydra-login-consent-node/blob/master/routes/login.js
subject: 'foo@bar.com', -> subject: 'foo@bar.com-success',


This docker test
1. docker ps
2. get oryd/hydra-login-consent-node:v1.0.0-rc.10 containerid
3. docker exec -it containerid /bin/sh
4. vi bin/www change port 3000 - > 3001
5. vi routes/login.js subject: 'foo@bar.com', => subject: 'foo@bar.com--success',
5. node ./bin/www &
6. ps
7. kill old node (be exit container)
8. docker exec -it containerid /bin/sh
9. vi bin/www change port 3001 - > 3000
10. node ./bin/www &
11. kill old node (be exit container)
12. docker exec -it containerid /bin/sh
13. netstat -nlp (check port 3000)


====================
https://mileschou.github.io/auth-notes/src/hydra/user-login-and-consent-flow.html#oauth-2-0-%E8%88%87-open-id-connect
====================
https://dotblogs.com.tw/liguobao/2018/12/30/132746
OAUTH2_ISSUER_URL hydra所在的地址
OAUTH2_CONSENT_URL 授权页面地址
OAUTH2_LOGIN_URL 登录页面地址

XX应用请求授权
-> 跳转到OAUTH2_LOGIN_URL地址
-> 登录成功
->跳转到OAUTH2_CONSENT_URL授权页面
-> 授权成功
->回调XX应用地址并且返回相关授权code/token
-> XX应用使用code/token获取用户信息或者其他操作

[轉]鋪柏油路

我是退休的營造工程師,我自己也開營造廠。 做營造的人不會穿皮鞋,就算工程師>工地主任>工程部經理,真的在做營造工程的只會穿運動鞋/安全鞋,很少機會去穿西裝皮鞋,說不好聽的你去看上酒店喝酒的一線營造業還是只穿運動鞋(當年真是天天花天酒地除了星期日)。
台灣的工程常常都是做完賺經驗,就是前面的設計仿歐美失敗,然後失敗中學經驗再修改,政府很多土木工程都是從設計就不是完美,大部分馬路自今還是設計缺陷,沒有因台灣環境去真的更改,還是沿用古老的傳統。

營造業基本上有在標政府工程的大概都知道工程的黑幕,高雄從謝長廷開始就是大黑特黑,不是陳菊。重點是不是他們的人你有錢還標不了工程。
懂理論與實際工程經驗不一樣,確實 料 一直是營造工程最真實的問題,不是一天兩天是3X年前我第一次進工地就知道的問題,另外 3cm的柏油做不起來很快會龜裂不耐用,最低都是5cm沒有3cm的。
柏油路 最重要的除了是原料之外還有路基,下面的給配有無確實的夯實才是耐用王道,因為載力是往下傳;破壞力是往前延伸。

一般馬路與高速公路的使用方式不同,高速公路是高速行駛在上面說最庶民語言就是飛過去,馬路是碾壓在上面,因為各種車子的起步與慢速最傷馬路,所以設計要不同。
香港的馬路有雙層巴士,這是數量最多的大型車輛,當然其他連結車 貨車都有。但是單論台灣 香港一般馬路最多的大型車就是公車,兩地的馬路除了工程破壞從鋪不論之外,香港的馬路真的就是比台灣好比台灣耐用,我看1X年了到今年2019年5月還再看有公車行駛的山坡地他們怎麼鋪馬路,說真的台灣做不到。

香港的馬路基本配置法(大部分的馬路皆一樣),基本有三層,原始層(這部分做得很確實夯實)/路基(標準30cm)/柏油(30cm),只要看到他們挖馬路的時候,挖起來的柏油就是30cm,大部分的馬路。有部分馬路統一不用柏油例如公車站,這就要用剛性路面(硬),就是台灣收費站的區域你不會看到柏油的原因<<<<這才是重點 重點 重點。
香港我有住的地方是一般街市(公屋/菜市場),我附近的馬路我知道的就已經10年沒重新鋪過,路還是一樣的平,只是退色會變灰白色。

李四川副市長是真的懂工程的人,以前他在台北市的時候,我剛好在做北市X期汙水工程的工地主任。















您好、我做過柏油工程及自來水管工程及當過水泥預拌混凝土司機,這3個工作共10幾年。 我對柏油路有一些看法。 您影片中只是一小部分原因,還有更多原因,那我簡單分享一下,讓大眾了解為何柏油路面無法鋪好。 1: 柏油路面下有很多工程。如自來水、電信、寬頻、瓦斯、第四台等管線,在做這些工程時會挖開柏油路面,把這些管線埋在地底1米-1米多不等,重點在於「回填」,地底的紮實度,直接影響路面狀況。 2: 依工程規定必須叫水泥預拌車用(clsm水泥回填),地底才會紮實,大車開過才不會塌陷,及水泥不會被雨水滲透流失。 可以試想一下,下面土是軟的、上面是柏油(就算上面鋪再厚),地底還是軟的,大車開過或下大雨後,導致柏油路面坍塌或地底被雨水掏空後直接柏油路面破洞。 很多工程都未依規定,直接「原土」回填,為了省「水泥」的錢,相當可觀唷。 或原土回填後上面鋪薄薄的水泥拍照📷,來騙公家機關(其實官官相護就是收回扣)。 或用品質很差的clsm(水泥)來回填,跟如您影片中很差的柏油品質一樣。

ethereum smart contract 基本


uint256 => 2^256
byte32 => 2^8^32 (byte=2^8) or 32個byte 放32字元(ascii)

0x => HEX 16進位

0x64 => 6 * (16^1) + 4 * (16^0) = 100

0x0164 => 1 * (16^2) + 6 * (16^1) + 4 * (16^0) = 365

0x HEX 16進位 最小0 最大F


回到最上面byte32 轉成 0x HEX 為了避免太長,2^8 = 256 => 16^2 => 16位元顯示要兩位 0~256 => 00~FF || FF => 15 * (16^1) + 15 * (16^0)
所以 0x0164,通常都是兩位處理 0x 01 64


unit256 = byte32
000000000000000000000000000000000000000000000000006a94d74f430000
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2

Hex number: 6a94d74f430000

Decimal number: 30000000000000000

Binary number: 1101010100101001101011101001111010000110000000000000000
Binary number: 110 1010 1001 0100 1101 0111 0100 1111 0100 0011 0000 0000 0000 0000

Decimal calculation:
0 = (0 × 16⁶³) + (0 × 16⁶²) + (0 × 16⁶¹) + (0 × 16⁶⁰) + (0 × 16⁵⁹) + (0 × 16⁵⁸) + (0 × 16⁵⁷) + (0 × 16⁵⁶) + (0 × 16⁵⁵) + (0 × 16⁵⁴) + (0 × 16⁵³) + (0 × 16⁵²) + (0 × 16⁵¹) + (0 × 16⁵⁰) + (0 × 16⁴⁹) + (0 × 16⁴⁸) + (0 × 16⁴⁷) + (0 × 16⁴⁶) + (0 × 16⁴⁵) + (0 × 16⁴⁴) + (0 × 16⁴³) + (0 × 16⁴²) + (0 × 16⁴¹) + (0 × 16⁴⁰) + (0 × 16³⁹) + (0 × 16³⁸) + (0 × 16³⁷) + (0 × 16³⁶) + (0 × 16³⁵) + (0 × 16³⁴) + (0 × 16³³) + (0 × 16³²) + (0 × 16³¹) + (0 × 16³⁰) + (0 × 16²⁹) + (0 × 16²⁸) + (0 × 16²⁷) + (0 × 16²⁶) + (0 × 16²⁵) + (0 × 16²⁴) + (0 × 16²³) + (0 × 16²²) + (0 × 16²¹) + (0 × 16²⁰) + (0 × 16¹⁹) + (0 × 16¹⁸) + (0 × 16¹⁷) + (0 × 16¹⁶) + (0 × 16¹⁵) + (0 × 16¹⁴) + (6 × 16¹³) + (10 × 16¹²) + (9 × 16¹¹) + (4 × 16¹⁰) + (13 × 16⁹) + (7 × 16⁸) + (4 × 16⁷) + (15 × 16⁶) + (4 × 16⁵) + (3 × 16⁴) + (0 × 16³) + (0 × 16²) + (0 × 16¹) + (0 × 16⁰) = 30000000000000000



=====

address last 20 bytes Byte20 換成 Hex 就40位元(characters)加上0x,就有42 characters
EX: cd2a3d9f938e13cd947ec05abc7fe734df8dd826

[轉][Solidity] 壓縮智能合約的輸入資料

https://medium.com/joyso/solidity-%E5%A3%93%E7%B8%AE%E6%99%BA%E8%83%BD%E5%90%88%E7%B4%84%E7%9A%84%E8%BC%B8%E5%85%A5%E8%B3%87%E6%96%99-65a870d1f04e

ethereum smart contract private value not safe

https://hackernoon.com/your-private-solidity-variable-is-not-private-save-it-before-it-becomes-public-52a723f29f5e


上面範例中,play(100)被呼叫後,從transcation data內得知

0x6587f6ec0000000000000000000000000000000000000000000000000000000000000064

然後先取得play()這部份的data

bytes4(keccak256('play(uint)'))

然後得知 0000000000000000000000000000000000000000000000000000000000000064 就是 uint部份,得到的這個值是經過hex才顯示的
byte32:00 為1個byte(16 bits),共32個

64=> 6 * (16^1) + 4 * (16^0) = 100


uint256 => 2^256 => 8^32 => byte32

ubuntu 18 sudo 卡頓

https://ywnz.com/linuxjc/2024.html


在Ubuntu Server 18.04 LTS下遇到了sudo速度非常慢的问题,具体表现是在提交命令之后大概需要10秒左右才有输入sudo密码或者开始运行,su命令同样也非常慢。这在升级前使用Ubuntu Server 16.04 LTS并没有,显然可能是Ubuntu Server 18.04 LTS版本的问题。



问题的原因

Ubuntu Server被设计成一种类似于分布式的操作系统网结构,允许/etc/sudoers中的成员不在本机上。从而sudo时会先从网络上寻找可能的sudoer然后才是本地,而这10s左右的时间就是整个DNS流程的最长时间。



解决办法

首先输入hostname,得到本机当前的互联网名称(大概跟windows下的计算机名称差不多)。然后使用su或sudo打开/etc/hosts,添加一行:

127.0.0.1计算机名计算机名.localdomain

关闭并保存。这样处理后sudo速度恢复正常。

有人問docker

1、用docker-machine建立開發環境 (VM),vm內的docker 環境是完整的,自己灌很浪費時間
http://sueboy.blogspot.com/search/label/docker-machine
然後 記得vm裡面跑 portainer.io 管理docker用,web介面
會省下你一大堆時間!
以上這個步驟是快速建立可以跑docker環境,然後又可以用圖形管理看log、砍image等等

2、docker 一般操作網路上都有,一定要看,就算有圖形化介面,有些時候你還是需要指令
記得一件事,要學docker-compose,然後基本上專案用docker,更正確來說,是要會用、會寫docker-compose
docker-compose 會比 單純用docker,好用很多
http://sueboy.blogspot.com/2018/12/ethereum-poa-docker-compose-docker.html

3、注意iptables,用docker後,常常會碰到iptables的問題,網路有問題,不能連,連不上,解答:把docker服務重開,就會重新設定iptables…這一堆人死在這上面
如果docker服務重開後,網路還是不行,我建議是用docker-machine重建一台vm比較快,再用docker-compose重新執行,比較快,省時間


4、通常用了docker的後端,十之八九就會想上K8s (kubernets)
到這階段就是超級大坑了!!!
非常大的坑! 會死人的坑! 到這階段千萬要避開,一定要避開!

坑指自架

node-gyp rebuild failed windows 10

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

truffle truffle-hdwallet-provider Error: Error: the tx doesn't have the correct nonce. account has nonce of: 3 tx has nonce of: 2


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. This two step are in one function. This mean is you call two time "new HDWalletProvide". Usually you think “New“ two time is ok, get "new" instance. But

https://github.com/trufflesuite/truffle-hdwallet-provider/blob/master/index.js


function HDWalletProvider(
  mnemonic,
  provider,
  address_index=0,
  num_addresses=1,
  shareNonce=true,
  wallet_hdpath="m/44'/60'/0'/0/"
) {


shareNonce default is true. new HDWalletProvide use same Nonce.

Answer is shareNonce => false, when you set/update data into to contract use api.





[???]nestjs Cross modules dependency injection

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.usersService.findOneByEmail(email);
    return await EncryptorService.validate(password, user.password);
  }


Impotant:

exports need UsersService

src/users/users.module.ts

import { UsersService } from './users.service';

@Module({
    controllers: [UsersController],
    components: [UsersService],
    imports: [TypeOrmModule.forFeature([User])],
    exports: [UsersService],
})

[轉]Nestjs framework 30天初探:Day30 總結Nest.js

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捕捉處理。

[轉]2018 年了,你还是只会 npm install 吗?

https://juejin.im/post/5ab3f77df265da2392364341


本地模块引用 這段不錯

nest.js 是 nodejs 服务运行时,要等待数据库服务启动完毕,也就是有一个启动等待的需求

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." >&2;

  else

  for uri in $uris
  do
    host=$(echo $uri | cut -d: -f1)
    port=$(echo $uri | cut -d: -f2)
    [ -n "${host}" ]
    [ -n "${port}" ]
    echo "Waiting for ${uri}."
    seconds=0
    while [ "$seconds" -lt "$timeout" ] && ! nc -z -w1 $host $port
    do
      echo -n .
      seconds=$((seconds+1))
      sleep 1
    done

    if [ "$seconds" -lt "$timeout" ]; then
      echo "${uri} is up!"
    else
      echo "  ERROR: unable to connect to ${uri}" >&2
      exit 1
    fi
  done
echo "All hosts are up"
fi

echo "Waiting for ${waitAfterHosts} seconds."
sleep $waitAfterHosts

exit 0

nestjs vs code推荐插件

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

nest.js TypeORM Database

https://medium.com/@shaibenshimol/nestjs-and-mysql-in-10-minutes-711e02ec1dab

ormconfig.json



{
  "type": "mysql",
  "host": "localhost",
  "port": 3306,
  "username": "root",
  "password": "root",
  "database": "my_nestjs_project",
  "entities": ["src/**/**.entity{.ts,.js}"],
  "synchronize": true,
  "extra": { connectionLimit: 10, ... }
}

Very Important !!


app.module


import { Module } from '@nestjs/common';
import { UsersModule } from './users/users.module';
import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot(),
    UsersModule
  ],
})
export class AppModule {}


=====nest command can use or not=====

nest g module users
nest g service users
nest g controller users
nest g class users/user.entity

Use TypeORM Active Record
https://github.com/typeorm/typeorm/blob/master/docs/active-record-data-mapper.md

user.entity.ts



import {BaseEntity, Entity, PrimaryGeneratedColumn, Column} from "typeorm";

@Entity()
export class User extends BaseEntity {
       
    @PrimaryGeneratedColumn()
    id: number;
    
    @Column()
    firstName: string;
    
    @Column()
    lastName: string;
    
    @Column()
    isActive: boolean;

    static findByName(firstName: string, lastName: string) {
        return this.createQueryBuilder("user")
            .where("user.firstName = :firstName", { firstName })
            .andWhere("user.lastName = :lastName", { lastName })
            .getMany();
    }
}


How to use


import { User } from './user.entity';

const timber = await User.findByName("Timber", "Saw");

===== Use Other way ====

Users module



app.module.ts


import { Module } from '@nestjs/common';
import { UsersModule } from './users/users.module';
import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot(),
    UsersModule
  ],
})
export class AppModule {}


users.module.ts


import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersService } from './users.service';
import { UsersController } from './users.controller';
import { User } from './user.entity';

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  providers: [UsersService],
  controllers: [UsersController],
})

export class UsersModule { }


users.controller.ts


import { Controller, Post, Body, Get, Put, Delete,Param} from '@nestjs/common';
import { UsersService } from './users.service';
import { User } from './user.entity';

@Controller('users')
export class UsersController {

    constructor(private service: UsersService) { }

    @Get(':id')
    get(@Param() params) {
        return this.service.getUser(params.id);
        //return timber = await User.findByName("Timber", "Saw");
    }

    @Post()
    create(@Body() user: User) {
        return this.service.createUser(user);
    }

    @Put()
    update(@Body() user: User) {
        return this.service.updateUser(user);
    }

    @Delete(':id')
    deleteUser(@Param() params) {
        return this.service.deleteUser(params.id);
    }
}


users.service.ts This file maybe don't need because use Active Record.


import { Injectable, Inject } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './user-entity';

@Injectable()
export class UsersService {

    constructor(@InjectRepository(User) private usersRepository: Repository) { }

    async getUsers(user: User): Promise {
        return await this.usersRepository.find();
    }

    async getUser(_id: number): Promise {
        return await this.usersRepository.find({
            select: ["fullName", "birthday", "isActive"],
            where: [{ "id": _id }]
        });
    }

    async updateUser(user: User) {
        this.usersRepository.save(user)
    }

    async deleteUser(user: User) {
        this.usersRepository.delete(user);
    }
}


https://blog.entrostat.com/setting-up-a-database-module-in-nest-js/

k8s kubernetes Lesson 7 ingress-nginx kubernetes

https://sueboy.blogspot.com/2019/01/ingress-nginx-kubernetes-ingress-with.html

Real site is


https://kubernetes.github.io/ingress-nginx/deploy/


kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml


Verify installation

https://kubernetes.github.io/ingress-nginx/deploy/#verify-installation


kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch


Detect installed version

https://kubernetes.github.io/ingress-nginx/deploy/#detect-installed-version


shell script

POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}')
kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version


=========

Other nginx-ingress

https://kubernetes.github.io/ingress-nginx/deploy/#using-helm

[轉]How To Create a Kubernetes Cluster Using Kubeadm on Debian 9

https://www.digitalocean.com/community/tutorials/how-to-create-a-kubernetes-cluster-using-kubeadm-on-debian-9

geth add peers static-nodes.json

https://medium.com/taipei-ethereum-meetup/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E7%A7%81%E7%B6%B2%E5%BB%BA%E7%AB%8B-%E4%B8%80-43f8677fc9f8

如果要組成一個私人網路,同樣按照上面的流程建立其他節點。如果沒有下--nodiscover參數的話,最後節點應該會找到彼此。如果有下的話就必須用手動的方式加入其他節點,加入的方式有三種:

一是在geth指令加入--bootnodes參數;

二是進到console裡使用 admin.addPeer();

三是存成static-nodes.json檔,讓geth自動連線。

不管是使用哪一種,我們都要先知道要連到


static-nodes.json 裡面使用domain,可能會有問題,要自行更換ip


Example:

geth --data ~/data

cp static-nodes.json ~/data/geth/static-nodes.json


static-nodes.json  like this

[
   "enode://53999cc519079c5190798b1114bd16a05a8d5190796cc51907988a4e80ebda7b6c519079e56b0b161da3475c4dc62f6b51907967a6e327e46aa56329c519079f@192.168.0.10:30303"
]