Open yukihirop opened 3 years ago
I thought it would be good to just provide a method to display the routing list of the server created by express in a nice way. I want to cut out the existing functions well.
$ yarn rue:mockserver:routes
yarn run v1.22.10
$ yarn rue:mockserver:gen:all && rue mock-server routes
$ rue mock-generate server
✨[Rue] 'backend/mock_server/db.json' updated.
✨[Rue] 'backend/mock_server/routes.json' updated.
┌─────────┬──────────┬───────────┬──────────────────────────────────────┬───────┐
│ (index) │ method │ resource │ uri pattern │ count │
├─────────┼──────────┼───────────┼──────────────────────────────────────┼───────┤
│ 0 │ 'DELETE' │ 'account' │ '/api/v1/accounts/:account_id' │ 1 │
│ 1 │ 'PUT' │ 'account' │ '/api/v1/accounts/:account_id' │ 1 │
│ 2 │ 'PATCH' │ 'account' │ '/api/v1/accounts/:account_id' │ 1 │
│ 3 │ 'POST' │ 'account' │ '/api/v1/accounts' │ 1 │
│ 4 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ 7 │
│ 5 │ 'GET' │ 'account' │ '/api/v1/accounts' │ 1 │
│ 6 │ 'GET' │ 'task' │ '/api/v1/tasks?accountId=:accountId' │ 1 │
│ 7 │ 'GET' │ 'task' │ '/api/v1/tasks/:task_id' │ 4 │
│ 8 │ 'GET' │ 'task' │ '/api/v1/tasks' │ 1 │
└─────────┴──────────┴───────────┴──────────────────────────────────────┴───────┘
✨ Done in 3.71s.
$ yarn rue:mockserver:routes -r account
yarn run v1.22.10
$ yarn rue:mockserver:gen:all && rue mock-server routes -r account
$ rue mock-generate server
✨[Rue] 'backend/mock_server/db.json' updated.
✨[Rue] 'backend/mock_server/routes.json' updated.
┌─────────┬──────────┬───────────┬────────────────────────────────┬──────────────────────┐
│ (index) │ method │ resource │ uri pattern │ path │
├─────────┼──────────┼───────────┼────────────────────────────────┼──────────────────────┤
│ 0 │ 'DELETE' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/1' │
│ 1 │ 'PUT' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/2' │
│ 2 │ 'PATCH' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/1' │
│ 3 │ 'POST' │ 'account' │ '/api/v1/accounts' │ '/api/v1/accounts' │
│ 4 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/7' │
│ 5 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/6' │
│ 6 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/5' │
│ 7 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/4' │
│ 8 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/3' │
│ 9 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/2' │
│ 10 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/1' │
│ 11 │ 'GET' │ 'account' │ '/api/v1/accounts' │ '/api/v1/accounts' │
└─────────┴──────────┴───────────┴────────────────────────────────┴──────────────────────┘
✨ Done in 3.10s.
$ yarn rue:mockserver:routes -m get -r account
yarn run v1.22.10
$ yarn rue:mockserver:gen:all && rue mock-server routes -m get -r account
$ rue mock-generate server
✨[Rue] 'backend/mock_server/db.json' updated.
✨[Rue] 'backend/mock_server/routes.json' updated.
┌─────────┬────────┬───────────┬────────────────────────────────┬──────────────────────┐
│ (index) │ method │ resource │ uri pattern │ path │
├─────────┼────────┼───────────┼────────────────────────────────┼──────────────────────┤
│ 0 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/7' │
│ 1 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/6' │
│ 2 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/5' │
│ 3 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/4' │
│ 4 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/3' │
│ 5 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/2' │
│ 6 │ 'GET' │ 'account' │ '/api/v1/accounts/:account_id' │ '/api/v1/accounts/1' │
│ 7 │ 'GET' │ 'account' │ '/api/v1/accounts' │ '/api/v1/accounts' │
└─────────┴────────┴───────────┴────────────────────────────────┴──────────────────────┘
✨ Done in 3.63s.
$ yarn rue:mockserver:run 3333
yarn run v1.22.10
$ yarn rue:mockserver:gen:all && rue mock-server --port 3333
$ rue mock-generate server
✨[Rue] 'backend/mock_server/db.json' updated.
✨[Rue] 'backend/mock_server/routes.json' updated.
🚀[Rue] Start mock server on http://localhost:3333
Resources
account | DELETE http://localhost:3333/api/v1/accounts/1
account | PUT http://localhost:3333/api/v1/accounts/2
account | PATCH http://localhost:3333/api/v1/accounts/1
account | POST http://localhost:3333/api/v1/accounts
account | GET http://localhost:3333/api/v1/accounts/7
account | GET http://localhost:3333/api/v1/accounts/6
account | GET http://localhost:3333/api/v1/accounts/5
account | GET http://localhost:3333/api/v1/accounts/4
account | GET http://localhost:3333/api/v1/accounts/3
account | GET http://localhost:3333/api/v1/accounts/2
account | GET http://localhost:3333/api/v1/accounts/1
account | GET http://localhost:3333/api/v1/accounts
task | GET http://localhost:3333/api/v1/tasks?accountId=1
task | GET http://localhost:3333/api/v1/tasks/4
task | GET http://localhost:3333/api/v1/tasks/3
task | GET http://localhost:3333/api/v1/tasks/2
task | GET http://localhost:3333/api/v1/tasks/1
task | GET http://localhost:3333/api/v1/tasks
Summary
The
agreed
is not currently maintained and there are many problems. I came to the conclusion that I should make a mock server normally with express.