5.6절에서 만든 테스트 프로그램을 실행해 전체 API가 정상적으로 동작하는지 확인해 보겠습니다. test.js 파일이 있는 경로에서 다음과 같이 실행합니다.
> node test.js
============================== members ==============================
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'DELETE',
path: '/members?username=test_account' } '{"key":2,"errorcode":0,"errormessage":"success"}'
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'POST',
path: '/members' } '{"key":3,"errorcode":0,"errormessage":"success"}'
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'GET',
path: '/members?username=test_account&password=1234' } '{"key":4,"errorcode":0,
"errormessage":"success","userid":1}'
============================== goods ==============================
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'POST',
path: '/goods' } '{"key":5,"errorcode":0,"errormessage":"success"}'
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'GET',
path: '/goods' } '{"key":6,"errorcode":0,"errormessage":"success","results":[{"id":1,
"name":"test Goods","category":"tests","price":1000,"description":"test"}]}'
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'DELETE',
path: '/goods?id=1' } '{"key":7,"errorcode":0,"errormessage":"success"}'
============================== purchases ==============================
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'POST',
path: '/purchases' } '{"key":8,"errorcode":0,"errormessage":"success"}'
{ host: '127.0.0.1',
port: 8000,
headers: { 'Content-Type': 'application/json' },
method: 'GET',
path: '/purchases?userid=1' } '{"key":9,"errorcode":0,"errormessage":"success","results"
:[{"id":1,"goodsid":1,"date":"2017-09-20T11:46:50.000Z"}]}'
done
모놀리식 아키텍처와 동일하게 동작하는 것을 확인할 수 있습니다.