https://www.lifehacker.jp/article/141128jsonjson_generator/
https://medium.com/veltra-engineering/dummy-json-8d21e35f6e45
https://swfz.hatenablog.com/entry/2021/03/17/021617
https://qiita.com/wf-yamaday/items/f890f3523eeacbe71153
npm install -g dummy-json
vim a.hbs
[
{{#repeat min=3 max=3}}
{
"col1": {{add @index 1}},
"col2": {{int 1 100}},
"col3": "{{date '2010' '2020' 'YYYY-MM-DD'}}",
"col4": "{{firstName}}",
"col5": "{{add (step 10) 0}}.png",
"col6": "{{random 'foge' 'fuga' 'piyo' 'foo' 'bar' 'baz'}}",
"col7": "{{color}}",
"col8": "{{guid}}",
"col9": "{{ipv4}}"
}
{{/repeat}}
]
dummyjson a.hbs
dummyjson a.hbs | jq '.[]' -cr
-- モックサーバ作成
vim a.sh
#!/bin/bash
PORT=4000
function response() {
echo "HTTP/1.0 200 OK"
echo "Content-Type: text/plain"
echo ""
dummyjson a.hbs
}
# main
# ctrl+cで無限ループを抜けれるようにする
trap exit INT
# 無限ループでリクエストを受け取る
while true; do
response | nc -l "$PORT" -w 1
done
chmod +x a.sh
./a.sh