From ce15108c9afd4344a224803e189c2a68b180bc9e Mon Sep 17 00:00:00 2001 From: Kevin Abrar Khansa Date: Sun, 5 May 2024 15:37:05 +0700 Subject: [PATCH] Add update address and test --- coverage/clover.xml | 349 ++++++++++ coverage/coverage-final.json | 35 + coverage/lcov-report/base.css | 224 ++++++ coverage/lcov-report/block-navigation.js | 87 +++ coverage/lcov-report/favicon.png | Bin 0 -> 445 bytes coverage/lcov-report/index.html | 266 ++++++++ coverage/lcov-report/prettify.css | 1 + coverage/lcov-report/prettify.js | 2 + coverage/lcov-report/sort-arrow-sprite.png | Bin 0 -> 138 bytes coverage/lcov-report/sorter.js | 196 ++++++ .../src/action/address/create-address.ts.html | 154 +++++ .../src/action/address/get-address.ts.html | 151 ++++ .../lcov-report/src/action/address/index.html | 146 ++++ .../src/action/address/update-address.ts.html | 172 +++++ .../src/action/contact/create-contact.ts.html | 163 +++++ .../src/action/contact/delete-contact.ts.html | 136 ++++ .../src/action/contact/get-contact.ts.html | 145 ++++ .../lcov-report/src/action/contact/index.html | 176 +++++ .../src/action/contact/search-contact.ts.html | 313 +++++++++ .../src/action/contact/update-contact.ts.html | 157 +++++ .../src/action/user/create-user.ts.html | 214 ++++++ .../src/action/user/get-user-by-token.ts.html | 157 +++++ .../lcov-report/src/action/user/index.html | 176 +++++ .../src/action/user/login-user.ts.html | 208 ++++++ .../src/action/user/logout-user.ts.html | 136 ++++ .../src/action/user/update-user.ts.html | 181 +++++ .../src/application/database.ts.html | 202 ++++++ .../lcov-report/src/application/index.html | 131 ++++ .../lcov-report/src/application/web.ts.html | 121 ++++ .../src/controller/address-controller.ts.html | 241 +++++++ .../src/controller/contact-controller.ts.html | 322 +++++++++ .../lcov-report/src/controller/index.html | 146 ++++ .../src/controller/user-controller.ts.html | 268 ++++++++ coverage/lcov-report/src/error/index.html | 116 ++++ .../src/error/response-error.ts.html | 109 +++ .../lcov-report/src/middleware/index.html | 131 ++++ .../lcov-report/src/middleware/user.ts.html | 148 ++++ .../src/middleware/validation.ts.html | 163 +++++ .../src/model/address-model.ts.html | 235 +++++++ .../src/model/contact-model.ts.html | 250 +++++++ coverage/lcov-report/src/model/index.html | 161 +++++ .../lcov-report/src/model/page-model.ts.html | 139 ++++ .../lcov-report/src/model/user-model.ts.html | 211 ++++++ coverage/lcov-report/src/route/api.ts.html | 151 ++++ coverage/lcov-report/src/route/index.html | 131 ++++ .../lcov-report/src/route/public-api.ts.html | 106 +++ .../src/validation/address-validation.ts.html | 142 ++++ .../src/validation/contact-validation.ts.html | 160 +++++ .../lcov-report/src/validation/index.html | 161 +++++ .../src/validation/user-validation.ts.html | 142 ++++ .../src/validation/validation.ts.html | 106 +++ .../tests/fixtures/address.ts.html | 154 +++++ .../tests/fixtures/contact.ts.html | 145 ++++ .../lcov-report/tests/fixtures/index.html | 146 ++++ .../lcov-report/tests/fixtures/user.ts.html | 148 ++++ coverage/lcov.info | 646 ++++++++++++++++++ package.json | 2 +- src/action/address/get-address.ts | 40 +- src/action/address/update-address.ts | 35 + src/controller/address-controller.ts | 21 +- src/model/address-model.ts | 4 + src/route/api.ts | 9 +- src/validation/address-validation.ts | 11 +- tests/address.test.ts | 91 ++- 64 files changed, 9560 insertions(+), 30 deletions(-) create mode 100644 coverage/clover.xml create mode 100644 coverage/coverage-final.json create mode 100644 coverage/lcov-report/base.css create mode 100644 coverage/lcov-report/block-navigation.js create mode 100644 coverage/lcov-report/favicon.png create mode 100644 coverage/lcov-report/index.html create mode 100644 coverage/lcov-report/prettify.css create mode 100644 coverage/lcov-report/prettify.js create mode 100644 coverage/lcov-report/sort-arrow-sprite.png create mode 100644 coverage/lcov-report/sorter.js create mode 100644 coverage/lcov-report/src/action/address/create-address.ts.html create mode 100644 coverage/lcov-report/src/action/address/get-address.ts.html create mode 100644 coverage/lcov-report/src/action/address/index.html create mode 100644 coverage/lcov-report/src/action/address/update-address.ts.html create mode 100644 coverage/lcov-report/src/action/contact/create-contact.ts.html create mode 100644 coverage/lcov-report/src/action/contact/delete-contact.ts.html create mode 100644 coverage/lcov-report/src/action/contact/get-contact.ts.html create mode 100644 coverage/lcov-report/src/action/contact/index.html create mode 100644 coverage/lcov-report/src/action/contact/search-contact.ts.html create mode 100644 coverage/lcov-report/src/action/contact/update-contact.ts.html create mode 100644 coverage/lcov-report/src/action/user/create-user.ts.html create mode 100644 coverage/lcov-report/src/action/user/get-user-by-token.ts.html create mode 100644 coverage/lcov-report/src/action/user/index.html create mode 100644 coverage/lcov-report/src/action/user/login-user.ts.html create mode 100644 coverage/lcov-report/src/action/user/logout-user.ts.html create mode 100644 coverage/lcov-report/src/action/user/update-user.ts.html create mode 100644 coverage/lcov-report/src/application/database.ts.html create mode 100644 coverage/lcov-report/src/application/index.html create mode 100644 coverage/lcov-report/src/application/web.ts.html create mode 100644 coverage/lcov-report/src/controller/address-controller.ts.html create mode 100644 coverage/lcov-report/src/controller/contact-controller.ts.html create mode 100644 coverage/lcov-report/src/controller/index.html create mode 100644 coverage/lcov-report/src/controller/user-controller.ts.html create mode 100644 coverage/lcov-report/src/error/index.html create mode 100644 coverage/lcov-report/src/error/response-error.ts.html create mode 100644 coverage/lcov-report/src/middleware/index.html create mode 100644 coverage/lcov-report/src/middleware/user.ts.html create mode 100644 coverage/lcov-report/src/middleware/validation.ts.html create mode 100644 coverage/lcov-report/src/model/address-model.ts.html create mode 100644 coverage/lcov-report/src/model/contact-model.ts.html create mode 100644 coverage/lcov-report/src/model/index.html create mode 100644 coverage/lcov-report/src/model/page-model.ts.html create mode 100644 coverage/lcov-report/src/model/user-model.ts.html create mode 100644 coverage/lcov-report/src/route/api.ts.html create mode 100644 coverage/lcov-report/src/route/index.html create mode 100644 coverage/lcov-report/src/route/public-api.ts.html create mode 100644 coverage/lcov-report/src/validation/address-validation.ts.html create mode 100644 coverage/lcov-report/src/validation/contact-validation.ts.html create mode 100644 coverage/lcov-report/src/validation/index.html create mode 100644 coverage/lcov-report/src/validation/user-validation.ts.html create mode 100644 coverage/lcov-report/src/validation/validation.ts.html create mode 100644 coverage/lcov-report/tests/fixtures/address.ts.html create mode 100644 coverage/lcov-report/tests/fixtures/contact.ts.html create mode 100644 coverage/lcov-report/tests/fixtures/index.html create mode 100644 coverage/lcov-report/tests/fixtures/user.ts.html create mode 100644 coverage/lcov.info create mode 100644 src/action/address/update-address.ts diff --git a/coverage/clover.xml b/coverage/clover.xml new file mode 100644 index 0000000..3968841 --- /dev/null +++ b/coverage/clover.xml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/coverage/coverage-final.json b/coverage/coverage-final.json new file mode 100644 index 0000000..541473e --- /dev/null +++ b/coverage/coverage-final.json @@ -0,0 +1,35 @@ +{"/app/src/action/address/create-address.ts": {"path":"/app/src/action/address/create-address.ts","statementMap":{"0":{"start":{"line":13,"column":22},"end":{"line":13,"column":76}},"1":{"start":{"line":15,"column":4},"end":{"line":15,"column":54}},"2":{"start":{"line":17,"column":27},"end":{"line":19,"column":6}},"3":{"start":{"line":21,"column":4},"end":{"line":21,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":12,"column":22},"end":{"line":22,"column":3}},"line":12}},"branchMap":{},"s":{"0":9,"1":8,"2":7,"3":7},"f":{"0":9},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"36e8c040457f541c5d4716ac8ed0c6063c01569d"} +,"/app/src/action/address/get-address.ts": {"path":"/app/src/action/address/get-address.ts","statementMap":{"0":{"start":{"line":8,"column":24},"end":{"line":8,"column":65}},"1":{"start":{"line":10,"column":24},"end":{"line":15,"column":10}},"2":{"start":{"line":17,"column":8},"end":{"line":19,"column":9}},"3":{"start":{"line":18,"column":12},"end":{"line":18,"column":81}},"4":{"start":{"line":21,"column":8},"end":{"line":21,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":7,"column":4},"end":{"line":7,"column":5}},"loc":{"start":{"line":7,"column":93},"end":{"line":22,"column":5}},"line":7}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":8},"end":{"line":19,"column":9}},"type":"if","locations":[{"start":{"line":17,"column":8},"end":{"line":19,"column":9}},{"start":{},"end":{}}],"line":17}},"s":{"0":5,"1":5,"2":5,"3":2,"4":3},"f":{"0":5},"b":{"0":[2,3]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"cf48e900e33d7013c0277a2a1e67010a3d563b29"} +,"/app/src/action/address/update-address.ts": {"path":"/app/src/action/address/update-address.ts","statementMap":{"0":{"start":{"line":11,"column":26},"end":{"line":11,"column":99}},"1":{"start":{"line":13,"column":24},"end":{"line":13,"column":80}},"2":{"start":{"line":15,"column":31},"end":{"line":26,"column":10}},"3":{"start":{"line":28,"column":8},"end":{"line":28,"column":29}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":10,"column":4},"end":{"line":10,"column":5}},"loc":{"start":{"line":10,"column":83},"end":{"line":29,"column":5}},"line":10}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":24},"end":{"line":17,"column":48}},"type":"binary-expr","locations":[{"start":{"line":17,"column":24},"end":{"line":17,"column":40}},{"start":{"line":17,"column":44},"end":{"line":17,"column":48}}],"line":17},"1":{"loc":{"start":{"line":18,"column":22},"end":{"line":18,"column":44}},"type":"binary-expr","locations":[{"start":{"line":18,"column":22},"end":{"line":18,"column":36}},{"start":{"line":18,"column":40},"end":{"line":18,"column":44}}],"line":18},"2":{"loc":{"start":{"line":19,"column":26},"end":{"line":19,"column":52}},"type":"binary-expr","locations":[{"start":{"line":19,"column":26},"end":{"line":19,"column":44}},{"start":{"line":19,"column":48},"end":{"line":19,"column":52}}],"line":19}},"s":{"0":3,"1":2,"2":2,"3":2},"f":{"0":3},"b":{"0":[2,1],"1":[2,1],"2":[2,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"513dff038f0661ca51e39c108573e660b1608555"} +,"/app/src/action/contact/create-contact.ts": {"path":"/app/src/action/contact/create-contact.ts","statementMap":{"0":{"start":{"line":12,"column":22},"end":{"line":12,"column":76}},"1":{"start":{"line":14,"column":27},"end":{"line":22,"column":6}},"2":{"start":{"line":24,"column":4},"end":{"line":24,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":2},"end":{"line":8,"column":3}},"loc":{"start":{"line":11,"column":22},"end":{"line":25,"column":3}},"line":11}},"branchMap":{},"s":{"0":58,"1":57,"2":57},"f":{"0":58},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"46121443dba187255c172359d509e8aa420a8ffe"} +,"/app/src/action/contact/delete-contact.ts": {"path":"/app/src/action/contact/delete-contact.ts","statementMap":{"0":{"start":{"line":7,"column":20},"end":{"line":7,"column":61}},"1":{"start":{"line":9,"column":27},"end":{"line":13,"column":6}},"2":{"start":{"line":15,"column":4},"end":{"line":15,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":2},"end":{"line":6,"column":3}},"loc":{"start":{"line":6,"column":54},"end":{"line":16,"column":3}},"line":6}},"branchMap":{},"s":{"0":2,"1":1,"2":1},"f":{"0":2},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"db83373a7f09ea76966e05fe85eb63334e461b82"} +,"/app/src/action/contact/get-contact.ts": {"path":"/app/src/action/contact/get-contact.ts","statementMap":{"0":{"start":{"line":7,"column":20},"end":{"line":12,"column":6}},"1":{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},"2":{"start":{"line":15,"column":6},"end":{"line":15,"column":73}},"3":{"start":{"line":18,"column":4},"end":{"line":18,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":2},"end":{"line":6,"column":3}},"loc":{"start":{"line":6,"column":54},"end":{"line":19,"column":3}},"line":6}},"branchMap":{"0":{"loc":{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},"type":"if","locations":[{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},{"start":{},"end":{}}],"line":14}},"s":{"0":18,"1":18,"2":3,"3":15},"f":{"0":18},"b":{"0":[3,15]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"13ec1ac608eea8355ef851ede24437a715643b69"} +,"/app/src/action/contact/search-contact.ts": {"path":"/app/src/action/contact/search-contact.ts","statementMap":{"0":{"start":{"line":13,"column":22},"end":{"line":13,"column":76}},"1":{"start":{"line":15,"column":26},"end":{"line":15,"column":28}},"2":{"start":{"line":17,"column":4},"end":{"line":32,"column":5}},"3":{"start":{"line":18,"column":6},"end":{"line":31,"column":8}},"4":{"start":{"line":34,"column":4},"end":{"line":40,"column":5}},"5":{"start":{"line":35,"column":6},"end":{"line":39,"column":8}},"6":{"start":{"line":42,"column":4},"end":{"line":48,"column":5}},"7":{"start":{"line":43,"column":6},"end":{"line":47,"column":8}},"8":{"start":{"line":50,"column":18},"end":{"line":55,"column":5}},"9":{"start":{"line":57,"column":21},"end":{"line":63,"column":6}},"10":{"start":{"line":65,"column":26},"end":{"line":65,"column":65}},"11":{"start":{"line":67,"column":4},"end":{"line":74,"column":5}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":12,"column":36},"end":{"line":75,"column":3}},"line":12}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":4},"end":{"line":32,"column":5}},"type":"if","locations":[{"start":{"line":17,"column":4},"end":{"line":32,"column":5}},{"start":{},"end":{}}],"line":17},"1":{"loc":{"start":{"line":34,"column":4},"end":{"line":40,"column":5}},"type":"if","locations":[{"start":{"line":34,"column":4},"end":{"line":40,"column":5}},{"start":{},"end":{}}],"line":34},"2":{"loc":{"start":{"line":42,"column":4},"end":{"line":48,"column":5}},"type":"if","locations":[{"start":{"line":42,"column":4},"end":{"line":48,"column":5}},{"start":{},"end":{}}],"line":42}},"s":{"0":9,"1":8,"2":8,"3":3,"4":8,"5":2,"6":8,"7":2,"8":8,"9":8,"10":8,"11":8},"f":{"0":9},"b":{"0":[3,5],"1":[2,6],"2":[2,6]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"854c23132acda9c6e7ef5ca0f7cc73d5956fc7dd"} +,"/app/src/action/contact/update-contact.ts": {"path":"/app/src/action/contact/update-contact.ts","statementMap":{"0":{"start":{"line":13,"column":22},"end":{"line":13,"column":76}},"1":{"start":{"line":15,"column":20},"end":{"line":15,"column":62}},"2":{"start":{"line":17,"column":4},"end":{"line":22,"column":6}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":12,"column":22},"end":{"line":23,"column":3}},"line":12}},"branchMap":{},"s":{"0":2,"1":1,"2":1},"f":{"0":2},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"1582de463ef0d9868d303ba48ab4274261402c61"} +,"/app/src/action/user/create-user.ts": {"path":"/app/src/action/user/create-user.ts","statementMap":{"0":{"start":{"line":15,"column":28},"end":{"line":18,"column":5}},"1":{"start":{"line":20,"column":19},"end":{"line":27,"column":6}},"2":{"start":{"line":29,"column":4},"end":{"line":31,"column":5}},"3":{"start":{"line":30,"column":6},"end":{"line":30,"column":61}},"4":{"start":{"line":33,"column":4},"end":{"line":35,"column":16}},"5":{"start":{"line":37,"column":17},"end":{"line":39,"column":6}},"6":{"start":{"line":41,"column":4},"end":{"line":41,"column":15}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":14,"column":2},"end":{"line":14,"column":3}},"loc":{"start":{"line":14,"column":66},"end":{"line":42,"column":3}},"line":14}},"branchMap":{"0":{"loc":{"start":{"line":29,"column":4},"end":{"line":31,"column":5}},"type":"if","locations":[{"start":{"line":29,"column":4},"end":{"line":31,"column":5}},{"start":{},"end":{}}],"line":29}},"s":{"0":39,"1":37,"2":37,"3":0,"4":37,"5":37,"6":37},"f":{"0":39},"b":{"0":[0,37]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"cfc4a1576a5669025b28d32e576818c3cb71b7bc"} +,"/app/src/action/user/get-user-by-token.ts": {"path":"/app/src/action/user/get-user-by-token.ts","statementMap":{"0":{"start":{"line":12,"column":17},"end":{"line":16,"column":6}},"1":{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},"2":{"start":{"line":19,"column":6},"end":{"line":19,"column":57}},"3":{"start":{"line":22,"column":4},"end":{"line":22,"column":15}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":11,"column":2},"end":{"line":11,"column":3}},"loc":{"start":{"line":11,"column":70},"end":{"line":23,"column":3}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},"type":"if","locations":[{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},{"start":{},"end":{}}],"line":18}},"s":{"0":37,"1":37,"2":2,"3":35},"f":{"0":37},"b":{"0":[2,35]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"81a50a561b8374310256f8c6623fc541fae6d821"} +,"/app/src/action/user/login-user.ts": {"path":"/app/src/action/user/login-user.ts","statementMap":{"0":{"start":{"line":12,"column":4},"end":{"line":12,"column":54}},"1":{"start":{"line":14,"column":17},"end":{"line":18,"column":6}},"2":{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},"3":{"start":{"line":21,"column":6},"end":{"line":21,"column":69}},"4":{"start":{"line":24,"column":27},"end":{"line":24,"column":80}},"5":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"6":{"start":{"line":27,"column":6},"end":{"line":27,"column":69}},"7":{"start":{"line":30,"column":24},"end":{"line":37,"column":6}},"8":{"start":{"line":39,"column":4},"end":{"line":39,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":11,"column":2},"end":{"line":11,"column":3}},"loc":{"start":{"line":11,"column":65},"end":{"line":40,"column":3}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},"type":"if","locations":[{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},{"start":{},"end":{}}],"line":20},"1":{"loc":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},{"start":{},"end":{}}],"line":26}},"s":{"0":37,"1":37,"2":37,"3":1,"4":36,"5":36,"6":1,"7":35,"8":35},"f":{"0":37},"b":{"0":[1,36],"1":[1,35]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"34c7934423c6a7968de71ab139b990ebba58b78d"} +,"/app/src/action/user/logout-user.ts": {"path":"/app/src/action/user/logout-user.ts","statementMap":{"0":{"start":{"line":6,"column":24},"end":{"line":13,"column":6}},"1":{"start":{"line":15,"column":4},"end":{"line":15,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":2},"end":{"line":5,"column":3}},"loc":{"start":{"line":5,"column":50},"end":{"line":16,"column":3}},"line":5}},"branchMap":{},"s":{"0":1,"1":1},"f":{"0":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"6a87273fbfee021d8258e0aceabeeca708104a27"} +,"/app/src/action/user/update-user.ts": {"path":"/app/src/action/user/update-user.ts","statementMap":{"0":{"start":{"line":10,"column":4},"end":{"line":10,"column":55}},"1":{"start":{"line":12,"column":34},"end":{"line":12,"column":36}},"2":{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},"3":{"start":{"line":15,"column":6},"end":{"line":15,"column":30}},"4":{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},"5":{"start":{"line":19,"column":6},"end":{"line":19,"column":74}},"6":{"start":{"line":22,"column":24},"end":{"line":28,"column":6}},"7":{"start":{"line":30,"column":4},"end":{"line":30,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":9,"column":78},"end":{"line":31,"column":3}},"line":9}},"branchMap":{"0":{"loc":{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},"type":"if","locations":[{"start":{"line":14,"column":4},"end":{"line":16,"column":5}},{"start":{},"end":{}}],"line":14},"1":{"loc":{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},"type":"if","locations":[{"start":{"line":18,"column":4},"end":{"line":20,"column":5}},{"start":{},"end":{}}],"line":18}},"s":{"0":4,"1":3,"2":3,"3":2,"4":3,"5":2,"6":3,"7":3},"f":{"0":4},"b":{"0":[2,1],"1":[2,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"e7de4abfaf1c8032507c48d0231ac7c6fabd1758"} +,"/app/src/application/database.ts": {"path":"/app/src/application/database.ts","statementMap":{"0":{"start":{"line":4,"column":28},"end":{"line":23,"column":2}},"1":{"start":{"line":25,"column":0},"end":{"line":27,"column":2}},"2":{"start":{"line":29,"column":0},"end":{"line":31,"column":2}},"3":{"start":{"line":33,"column":0},"end":{"line":35,"column":2}},"4":{"start":{"line":37,"column":0},"end":{"line":39,"column":2}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":25,"column":26},"end":{"line":25,"column":27}},"loc":{"start":{"line":25,"column":41},"end":{"line":27,"column":1}},"line":25},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":25},"end":{"line":29,"column":26}},"loc":{"start":{"line":29,"column":40},"end":{"line":31,"column":1}},"line":29},"2":{"name":"(anonymous_2)","decl":{"start":{"line":33,"column":25},"end":{"line":33,"column":26}},"loc":{"start":{"line":33,"column":40},"end":{"line":35,"column":1}},"line":33},"3":{"name":"(anonymous_3)","decl":{"start":{"line":37,"column":26},"end":{"line":37,"column":27}},"loc":{"start":{"line":37,"column":41},"end":{"line":39,"column":1}},"line":37}},"branchMap":{},"s":{"0":3,"1":3,"2":3,"3":3,"4":3},"f":{"0":0,"1":0,"2":3,"3":768},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"d942ccfcbfb8fd5b965441c4b6f2ceb8474c84fa"} +,"/app/src/application/web.ts": {"path":"/app/src/application/web.ts","statementMap":{"0":{"start":{"line":6,"column":19},"end":{"line":6,"column":28}},"1":{"start":{"line":8,"column":0},"end":{"line":10,"column":1}},"2":{"start":{"line":9,"column":2},"end":{"line":9,"column":24}},"3":{"start":{"line":12,"column":0},"end":{"line":12,"column":77}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":26},"end":{"line":8,"column":27}},"loc":{"start":{"line":8,"column":38},"end":{"line":10,"column":1}},"line":8}},"branchMap":{},"s":{"0":3,"1":3,"2":28,"3":3},"f":{"0":28},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"39f0ce69651094913ea82d82f2dcba3bd3007e94"} +,"/app/src/controller/address-controller.ts": {"path":"/app/src/controller/address-controller.ts","statementMap":{"0":{"start":{"line":10,"column":4},"end":{"line":20,"column":5}},"1":{"start":{"line":11,"column":19},"end":{"line":11,"column":51}},"2":{"start":{"line":13,"column":6},"end":{"line":13,"column":52}},"3":{"start":{"line":15,"column":23},"end":{"line":15,"column":67}},"4":{"start":{"line":17,"column":6},"end":{"line":17,"column":55}},"5":{"start":{"line":19,"column":6},"end":{"line":19,"column":13}},"6":{"start":{"line":24,"column":4},"end":{"line":34,"column":5}},"7":{"start":{"line":25,"column":24},"end":{"line":25,"column":52}},"8":{"start":{"line":27,"column":24},"end":{"line":27,"column":52}},"9":{"start":{"line":29,"column":23},"end":{"line":29,"column":81}},"10":{"start":{"line":31,"column":6},"end":{"line":31,"column":55}},"11":{"start":{"line":33,"column":6},"end":{"line":33,"column":13}},"12":{"start":{"line":38,"column":4},"end":{"line":50,"column":5}},"13":{"start":{"line":39,"column":17},"end":{"line":39,"column":25}},"14":{"start":{"line":41,"column":6},"end":{"line":41,"column":52}},"15":{"start":{"line":43,"column":6},"end":{"line":43,"column":44}},"16":{"start":{"line":45,"column":22},"end":{"line":45,"column":67}},"17":{"start":{"line":47,"column":6},"end":{"line":47,"column":54}},"18":{"start":{"line":49,"column":6},"end":{"line":49,"column":13}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":9,"column":75},"end":{"line":21,"column":3}},"line":9},"1":{"name":"(anonymous_1)","decl":{"start":{"line":23,"column":2},"end":{"line":23,"column":3}},"loc":{"start":{"line":23,"column":72},"end":{"line":35,"column":3}},"line":23},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":2},"end":{"line":37,"column":3}},"loc":{"start":{"line":37,"column":75},"end":{"line":51,"column":3}},"line":37}},"branchMap":{},"s":{"0":4,"1":4,"2":4,"3":4,"4":2,"5":2,"6":3,"7":3,"8":3,"9":3,"10":1,"11":2,"12":3,"13":3,"14":3,"15":3,"16":3,"17":2,"18":1},"f":{"0":4,"1":3,"2":3},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"ac26168e4a811a9d9f3c66ba361fd0552eb8f0c3"} +,"/app/src/controller/contact-controller.ts": {"path":"/app/src/controller/contact-controller.ts","statementMap":{"0":{"start":{"line":16,"column":4},"end":{"line":22,"column":5}},"1":{"start":{"line":17,"column":23},"end":{"line":17,"column":71}},"2":{"start":{"line":19,"column":6},"end":{"line":19,"column":55}},"3":{"start":{"line":21,"column":6},"end":{"line":21,"column":13}},"4":{"start":{"line":30,"column":4},"end":{"line":37,"column":5}},"5":{"start":{"line":31,"column":24},"end":{"line":31,"column":52}},"6":{"start":{"line":32,"column":23},"end":{"line":32,"column":69}},"7":{"start":{"line":34,"column":6},"end":{"line":34,"column":55}},"8":{"start":{"line":36,"column":6},"end":{"line":36,"column":13}},"9":{"start":{"line":45,"column":4},"end":{"line":55,"column":5}},"10":{"start":{"line":46,"column":19},"end":{"line":46,"column":51}},"11":{"start":{"line":48,"column":6},"end":{"line":48,"column":44}},"12":{"start":{"line":50,"column":23},"end":{"line":50,"column":67}},"13":{"start":{"line":52,"column":6},"end":{"line":52,"column":55}},"14":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"15":{"start":{"line":59,"column":4},"end":{"line":67,"column":5}},"16":{"start":{"line":60,"column":24},"end":{"line":60,"column":52}},"17":{"start":{"line":62,"column":23},"end":{"line":62,"column":72}},"18":{"start":{"line":64,"column":6},"end":{"line":64,"column":55}},"19":{"start":{"line":66,"column":6},"end":{"line":66,"column":13}},"20":{"start":{"line":71,"column":4},"end":{"line":77,"column":5}},"21":{"start":{"line":72,"column":23},"end":{"line":72,"column":71}},"22":{"start":{"line":74,"column":6},"end":{"line":74,"column":55}},"23":{"start":{"line":76,"column":6},"end":{"line":76,"column":13}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":11,"column":2},"end":{"line":11,"column":3}},"loc":{"start":{"line":15,"column":19},"end":{"line":23,"column":3}},"line":15},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":2},"end":{"line":25,"column":3}},"loc":{"start":{"line":29,"column":19},"end":{"line":38,"column":3}},"line":29},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":2},"end":{"line":40,"column":3}},"loc":{"start":{"line":44,"column":19},"end":{"line":56,"column":3}},"line":44},"3":{"name":"(anonymous_3)","decl":{"start":{"line":58,"column":2},"end":{"line":58,"column":3}},"loc":{"start":{"line":58,"column":75},"end":{"line":68,"column":3}},"line":58},"4":{"name":"(anonymous_4)","decl":{"start":{"line":70,"column":2},"end":{"line":70,"column":3}},"loc":{"start":{"line":70,"column":75},"end":{"line":78,"column":3}},"line":70}},"branchMap":{},"s":{"0":3,"1":3,"2":2,"3":1,"4":2,"5":2,"6":2,"7":1,"8":1,"9":2,"10":2,"11":2,"12":2,"13":1,"14":1,"15":2,"16":2,"17":2,"18":1,"19":1,"20":9,"21":9,"22":8,"23":1},"f":{"0":3,"1":2,"2":2,"3":2,"4":9},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"6b46d646d59f7ec9533f46f714c18a16bc29a3e5"} +,"/app/src/controller/user-controller.ts": {"path":"/app/src/controller/user-controller.ts","statementMap":{"0":{"start":{"line":11,"column":4},"end":{"line":17,"column":5}},"1":{"start":{"line":12,"column":23},"end":{"line":12,"column":57}},"2":{"start":{"line":14,"column":6},"end":{"line":14,"column":52}},"3":{"start":{"line":16,"column":6},"end":{"line":16,"column":13}},"4":{"start":{"line":21,"column":4},"end":{"line":27,"column":5}},"5":{"start":{"line":22,"column":23},"end":{"line":22,"column":56}},"6":{"start":{"line":24,"column":6},"end":{"line":24,"column":52}},"7":{"start":{"line":26,"column":6},"end":{"line":26,"column":13}},"8":{"start":{"line":35,"column":4},"end":{"line":39,"column":5}},"9":{"start":{"line":36,"column":6},"end":{"line":36,"column":53}},"10":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}},"11":{"start":{"line":43,"column":4},"end":{"line":49,"column":5}},"12":{"start":{"line":44,"column":19},"end":{"line":44,"column":64}},"13":{"start":{"line":46,"column":6},"end":{"line":46,"column":48}},"14":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"15":{"start":{"line":53,"column":4},"end":{"line":59,"column":5}},"16":{"start":{"line":54,"column":23},"end":{"line":54,"column":58}},"17":{"start":{"line":56,"column":6},"end":{"line":56,"column":52}},"18":{"start":{"line":58,"column":6},"end":{"line":58,"column":13}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":10,"column":2},"end":{"line":10,"column":3}},"loc":{"start":{"line":10,"column":73},"end":{"line":18,"column":3}},"line":10},"1":{"name":"(anonymous_1)","decl":{"start":{"line":20,"column":2},"end":{"line":20,"column":3}},"loc":{"start":{"line":20,"column":70},"end":{"line":28,"column":3}},"line":20},"2":{"name":"(anonymous_2)","decl":{"start":{"line":30,"column":2},"end":{"line":30,"column":3}},"loc":{"start":{"line":34,"column":4},"end":{"line":40,"column":3}},"line":34},"3":{"name":"(anonymous_3)","decl":{"start":{"line":42,"column":2},"end":{"line":42,"column":3}},"loc":{"start":{"line":42,"column":79},"end":{"line":50,"column":3}},"line":42},"4":{"name":"(anonymous_4)","decl":{"start":{"line":52,"column":2},"end":{"line":52,"column":3}},"loc":{"start":{"line":52,"column":79},"end":{"line":60,"column":3}},"line":52}},"branchMap":{},"s":{"0":3,"1":3,"2":1,"3":2,"4":3,"5":3,"6":1,"7":2,"8":1,"9":1,"10":0,"11":4,"12":4,"13":3,"14":1,"15":1,"16":1,"17":1,"18":0},"f":{"0":3,"1":3,"2":1,"3":4,"4":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"f2b38bc8ffc779ecebfce6dd4e873bcda45db985"} +,"/app/src/error/response-error.ts": {"path":"/app/src/error/response-error.ts","statementMap":{"0":{"start":{"line":6,"column":4},"end":{"line":6,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":2,"column":2},"end":{"line":2,"column":3}},"loc":{"start":{"line":5,"column":4},"end":{"line":7,"column":3}},"line":5}},"branchMap":{},"s":{"0":9},"f":{"0":9},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"53b5b1fc94006b5cd22d6a54d3c5ea9e388eb591"} +,"/app/src/middleware/user.ts": {"path":"/app/src/middleware/user.ts","statementMap":{"0":{"start":{"line":5,"column":20},"end":{"line":21,"column":1}},"1":{"start":{"line":10,"column":2},"end":{"line":20,"column":3}},"2":{"start":{"line":11,"column":17},"end":{"line":11,"column":74}},"3":{"start":{"line":13,"column":4},"end":{"line":13,"column":19}},"4":{"start":{"line":15,"column":4},"end":{"line":15,"column":10}},"5":{"start":{"line":17,"column":4},"end":{"line":19,"column":6}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":20},"end":{"line":5,"column":21}},"loc":{"start":{"line":9,"column":5},"end":{"line":21,"column":1}},"line":9}},"branchMap":{},"s":{"0":3,"1":36,"2":36,"3":34,"4":34,"5":2},"f":{"0":36},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"c3a3b2b64809cb966e59e0975e84e3475a4249e4"} +,"/app/src/middleware/validation.ts": {"path":"/app/src/middleware/validation.ts","statementMap":{"0":{"start":{"line":5,"column":31},"end":{"line":26,"column":1}},"1":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"2":{"start":{"line":12,"column":4},"end":{"line":14,"column":6}},"3":{"start":{"line":17,"column":2},"end":{"line":21,"column":3}},"4":{"start":{"line":18,"column":4},"end":{"line":20,"column":6}},"5":{"start":{"line":23,"column":2},"end":{"line":25,"column":4}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":31},"end":{"line":5,"column":32}},"loc":{"start":{"line":10,"column":5},"end":{"line":26,"column":1}},"line":10}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},{"start":{},"end":{}}],"line":11},"1":{"loc":{"start":{"line":17,"column":2},"end":{"line":21,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":21,"column":3}},{"start":{},"end":{}}],"line":17}},"s":{"0":3,"1":15,"2":8,"3":7,"4":7,"5":0},"f":{"0":15},"b":{"0":[8,7],"1":[7,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"8e19017e7d45832e2a8a8751f17c04065bbdbd20"} +,"/app/src/model/address-model.ts": {"path":"/app/src/model/address-model.ts","statementMap":{"0":{"start":{"line":30,"column":19},"end":{"line":38,"column":4}},"1":{"start":{"line":30,"column":42},"end":{"line":38,"column":3}},"2":{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},"3":{"start":{"line":41,"column":4},"end":{"line":44,"column":5}},"4":{"start":{"line":47,"column":2},"end":{"line":49,"column":3}}},"fnMap":{"0":{"name":"toAddressResponse","decl":{"start":{"line":27,"column":16},"end":{"line":27,"column":33}},"loc":{"start":{"line":29,"column":61},"end":{"line":50,"column":1}},"line":29},"1":{"name":"(anonymous_1)","decl":{"start":{"line":30,"column":19},"end":{"line":30,"column":20}},"loc":{"start":{"line":30,"column":42},"end":{"line":38,"column":3}},"line":30}},"branchMap":{"0":{"loc":{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},"type":"if","locations":[{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},{"start":{},"end":{}}],"line":40}},"s":{"0":5,"1":5,"2":5,"3":0,"4":5},"f":{"0":5,"1":5},"b":{"0":[0,5]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"866041c2b36c310d9f6ba6f2c9854abecb36b4a5"} +,"/app/src/model/contact-model.ts": {"path":"/app/src/model/contact-model.ts","statementMap":{"0":{"start":{"line":33,"column":17},"end":{"line":39,"column":4}},"1":{"start":{"line":33,"column":40},"end":{"line":39,"column":3}},"2":{"start":{"line":41,"column":2},"end":{"line":46,"column":3}},"3":{"start":{"line":42,"column":4},"end":{"line":45,"column":5}},"4":{"start":{"line":48,"column":2},"end":{"line":50,"column":3}},"5":{"start":{"line":53,"column":29},"end":{"line":55,"column":51}},"6":{"start":{"line":55,"column":28},"end":{"line":55,"column":51}}},"fnMap":{"0":{"name":"toContactResponse","decl":{"start":{"line":30,"column":16},"end":{"line":30,"column":33}},"loc":{"start":{"line":32,"column":61},"end":{"line":51,"column":1}},"line":32},"1":{"name":"(anonymous_1)","decl":{"start":{"line":33,"column":17},"end":{"line":33,"column":18}},"loc":{"start":{"line":33,"column":40},"end":{"line":39,"column":3}},"line":33},"2":{"name":"(anonymous_2)","decl":{"start":{"line":53,"column":29},"end":{"line":53,"column":30}},"loc":{"start":{"line":55,"column":28},"end":{"line":55,"column":51}},"line":55}},"branchMap":{"0":{"loc":{"start":{"line":41,"column":2},"end":{"line":46,"column":3}},"type":"if","locations":[{"start":{"line":41,"column":2},"end":{"line":46,"column":3}},{"start":{},"end":{}}],"line":41}},"s":{"0":13,"1":20,"2":13,"3":8,"4":5,"5":3,"6":0},"f":{"0":13,"1":20,"2":0},"b":{"0":[8,5]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"4f05a14fa9a3c130ca38fb8311a19b5ffabe6f3c"} +,"/app/src/model/page-model.ts": {"path":"/app/src/model/page-model.ts","statementMap":{"0":{"start":{"line":16,"column":28},"end":{"line":18,"column":70}},"1":{"start":{"line":18,"column":28},"end":{"line":18,"column":70}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":16,"column":28},"end":{"line":16,"column":29}},"loc":{"start":{"line":18,"column":28},"end":{"line":18,"column":70}},"line":18}},"branchMap":{},"s":{"0":3,"1":18},"f":{"0":18},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"362068944a66143c2885ef91379cae4bc32df75e"} +,"/app/src/model/user-model.ts": {"path":"/app/src/model/user-model.ts","statementMap":{"0":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}}},"fnMap":{"0":{"name":"toUserResponse","decl":{"start":{"line":30,"column":16},"end":{"line":30,"column":30}},"loc":{"start":{"line":34,"column":33},"end":{"line":42,"column":1}},"line":34}},"branchMap":{},"s":{"0":7},"f":{"0":7},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"eae68ce0b8e177690c4846e9f965085712f1ece9"} +,"/app/src/route/api.ts": {"path":"/app/src/route/api.ts","statementMap":{"0":{"start":{"line":7,"column":25},"end":{"line":7,"column":41}},"1":{"start":{"line":8,"column":0},"end":{"line":8,"column":19}},"2":{"start":{"line":10,"column":0},"end":{"line":10,"column":63}},"3":{"start":{"line":11,"column":0},"end":{"line":11,"column":64}},"4":{"start":{"line":12,"column":0},"end":{"line":12,"column":56}},"5":{"start":{"line":14,"column":0},"end":{"line":14,"column":57}},"6":{"start":{"line":15,"column":0},"end":{"line":15,"column":64}},"7":{"start":{"line":16,"column":0},"end":{"line":16,"column":67}},"8":{"start":{"line":17,"column":0},"end":{"line":17,"column":70}},"9":{"start":{"line":18,"column":0},"end":{"line":18,"column":64}},"10":{"start":{"line":20,"column":0},"end":{"line":20,"column":78}},"11":{"start":{"line":21,"column":0},"end":{"line":21,"column":85}},"12":{"start":{"line":22,"column":0},"end":{"line":22,"column":88}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3,"3":3,"4":3,"5":3,"6":3,"7":3,"8":3,"9":3,"10":3,"11":3,"12":3},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"923faa828f0316491b58c4bbeefa0afbb7c9c00c"} +,"/app/src/route/public-api.ts": {"path":"/app/src/route/public-api.ts","statementMap":{"0":{"start":{"line":4,"column":28},"end":{"line":4,"column":44}},"1":{"start":{"line":6,"column":0},"end":{"line":6,"column":53}},"2":{"start":{"line":7,"column":0},"end":{"line":7,"column":56}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"7b32b80a6b1317f6212c15ba92952d20969afc51"} +,"/app/src/validation/address-validation.ts": {"path":"/app/src/validation/address-validation.ts","statementMap":{"0":{"start":{"line":4,"column":29},"end":{"line":11,"column":3}},"1":{"start":{"line":13,"column":36},"end":{"line":13,"column":59}},"2":{"start":{"line":15,"column":36},"end":{"line":18,"column":4}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"2b680d23c2f0317d9ce0888c16d86914be888046"} +,"/app/src/validation/contact-validation.ts": {"path":"/app/src/validation/contact-validation.ts","statementMap":{"0":{"start":{"line":4,"column":29},"end":{"line":9,"column":3}},"1":{"start":{"line":11,"column":36},"end":{"line":11,"column":59}},"2":{"start":{"line":13,"column":36},"end":{"line":16,"column":4}},"3":{"start":{"line":18,"column":36},"end":{"line":24,"column":4}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3,"3":3},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"29e2a8f7d6107b4bc3bd4e482b36f884bb1d5c3b"} +,"/app/src/validation/user-validation.ts": {"path":"/app/src/validation/user-validation.ts","statementMap":{"0":{"start":{"line":4,"column":38},"end":{"line":8,"column":4}},"1":{"start":{"line":10,"column":35},"end":{"line":13,"column":4}},"2":{"start":{"line":15,"column":36},"end":{"line":18,"column":4}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"dddbafb89f43bc7feea4f74c3773ec14039f49c2"} +,"/app/src/validation/validation.ts": {"path":"/app/src/validation/validation.ts","statementMap":{"0":{"start":{"line":5,"column":4},"end":{"line":5,"column":29}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":2},"end":{"line":4,"column":3}},"loc":{"start":{"line":4,"column":53},"end":{"line":6,"column":3}},"line":4}},"branchMap":{},"s":{"0":161},"f":{"0":161},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"ac003f965488da031f44bb5cb24142086949ecd5"} +,"/app/tests/fixtures/address.ts": {"path":"/app/tests/fixtures/address.ts","statementMap":{"0":{"start":{"line":6,"column":36},"end":{"line":17,"column":2}},"1":{"start":{"line":9,"column":28},"end":{"line":17,"column":1}},"2":{"start":{"line":19,"column":29},"end":{"line":23,"column":1}},"3":{"start":{"line":20,"column":18},"end":{"line":20,"column":47}},"4":{"start":{"line":22,"column":2},"end":{"line":22,"column":51}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":36},"end":{"line":6,"column":37}},"loc":{"start":{"line":9,"column":28},"end":{"line":17,"column":1}},"line":9},"1":{"name":"(anonymous_1)","decl":{"start":{"line":19,"column":29},"end":{"line":19,"column":30}},"loc":{"start":{"line":19,"column":69},"end":{"line":23,"column":1}},"line":19}},"branchMap":{},"s":{"0":1,"1":10,"2":1,"3":5,"4":5},"f":{"0":10,"1":5},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"bc1d3f8dab03f3601add120e1ebe463ea7fda162"} +,"/app/tests/fixtures/contact.ts": {"path":"/app/tests/fixtures/contact.ts","statementMap":{"0":{"start":{"line":6,"column":36},"end":{"line":14,"column":2}},"1":{"start":{"line":8,"column":28},"end":{"line":14,"column":1}},"2":{"start":{"line":16,"column":29},"end":{"line":20,"column":1}},"3":{"start":{"line":17,"column":18},"end":{"line":17,"column":40}},"4":{"start":{"line":19,"column":2},"end":{"line":19,"column":51}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":36},"end":{"line":6,"column":37}},"loc":{"start":{"line":8,"column":28},"end":{"line":14,"column":1}},"line":8},"1":{"name":"(anonymous_1)","decl":{"start":{"line":16,"column":29},"end":{"line":16,"column":30}},"loc":{"start":{"line":16,"column":51},"end":{"line":20,"column":1}},"line":16}},"branchMap":{},"s":{"0":2,"1":57,"2":2,"3":15,"4":15},"f":{"0":57,"1":15},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"105015030d987a06dec7732eeefcf4313c2aa605"} +,"/app/tests/fixtures/user.ts": {"path":"/app/tests/fixtures/user.ts","statementMap":{"0":{"start":{"line":7,"column":33},"end":{"line":13,"column":1}},"1":{"start":{"line":8,"column":2},"end":{"line":12,"column":3}},"2":{"start":{"line":15,"column":26},"end":{"line":21,"column":1}},"3":{"start":{"line":16,"column":18},"end":{"line":16,"column":37}},"4":{"start":{"line":18,"column":2},"end":{"line":18,"column":35}},"5":{"start":{"line":20,"column":2},"end":{"line":20,"column":41}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":7,"column":33},"end":{"line":7,"column":34}},"loc":{"start":{"line":7,"column":58},"end":{"line":13,"column":1}},"line":7},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":26},"end":{"line":15,"column":27}},"loc":{"start":{"line":15,"column":53},"end":{"line":21,"column":1}},"line":15}},"branchMap":{},"s":{"0":3,"1":39,"2":3,"3":28,"4":28,"5":28},"f":{"0":39,"1":28},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"9bc52b90a91300d00857a9aad0b7637f514f9502"} +} diff --git a/coverage/lcov-report/base.css b/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/coverage/lcov-report/block-navigation.js b/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..cc12130 --- /dev/null +++ b/coverage/lcov-report/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/coverage/lcov-report/favicon.png b/coverage/lcov-report/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*> + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 97.14% + Statements + 204/210 +
+ + +
+ 91.66% + Branches + 33/36 +
+ + +
+ 93.75% + Functions + 45/48 +
+ + +
+ 97.11% + Lines + 202/208 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
src/action/address +
+
100%13/13100%8/8100%3/3100%13/13
src/action/contact +
+
100%25/25100%8/8100%5/5100%25/25
src/action/user +
+
96.66%29/3091.66%11/12100%5/596.66%29/30
src/application +
+
100%9/9100%0/060%3/5100%9/9
src/controller +
+
96.77%60/62100%0/0100%13/1396.77%60/62
src/error +
+
100%1/1100%0/0100%1/1100%1/1
src/middleware +
+
91.66%11/1275%3/4100%2/291.66%11/12
src/model +
+
86.66%13/1575%3/485.71%6/784.61%11/13
src/route +
+
100%16/16100%0/0100%0/0100%16/16
src/validation +
+
100%11/11100%0/0100%1/1100%11/11
tests/fixtures +
+
100%16/16100%0/0100%6/6100%16/16
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/prettify.css b/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/coverage/lcov-report/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/lcov-report/prettify.js b/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/lcov-report/sort-arrow-sprite.png b/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..6ed68316eb3f65dec9063332d2f69bf3093bbfab GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/coverage/lcov-report/sorter.js b/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..2bb296a --- /dev/null +++ b/coverage/lcov-report/sorter.js @@ -0,0 +1,196 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + if ( + row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()) + ) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/coverage/lcov-report/src/action/address/create-address.ts.html b/coverage/lcov-report/src/action/address/create-address.ts.html new file mode 100644 index 0000000..2a39346 --- /dev/null +++ b/coverage/lcov-report/src/action/address/create-address.ts.html @@ -0,0 +1,154 @@ + + + + + + Code coverage report for src/action/address/create-address.ts + + + + + + + + + +
+
+

All files / src/action/address create-address.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24  +  +  +  +  +  +  +  +  +  +  +  +9x +  +8x +  +7x +  +  +  +7x +  +  + 
import { Address, User } from '@prisma/client'
+import { CreateAddressRequest } from '../../model/address-model'
+import { Validation } from '../../validation/validation'
+import { AddressValidation } from '../../validation/address-validation'
+import { prismaClient } from '../../application/database'
+import GetContact from '../contact/get-contact'
+ 
+export default class CreateAddress {
+  static async execute(
+    user: User,
+    request: CreateAddressRequest
+  ): Promise<Address> {
+    const validated = Validation.validate(AddressValidation.CREATE, request)
+ 
+    await GetContact.execute(user, request.contact_id)
+ 
+    const createdAddress = await prismaClient.address.create({
+      data: validated
+    })
+ 
+    return createdAddress
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/address/get-address.ts.html b/coverage/lcov-report/src/action/address/get-address.ts.html new file mode 100644 index 0000000..eb4b4ab --- /dev/null +++ b/coverage/lcov-report/src/action/address/get-address.ts.html @@ -0,0 +1,151 @@ + + + + + + Code coverage report for src/action/address/get-address.ts + + + + + + + + + +
+
+

All files / src/action/address get-address.ts

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 2/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23  +  +  +  +  +  +  +5x +  +5x +  +  +  +  +  +  +5x +2x +  +  +3x +  + 
import { Address, User } from "@prisma/client";
+import { prismaClient } from "../../application/database";
+import GetContact from "../contact/get-contact";
+import { ResponseError } from "../../error/response-error";
+ 
+export default class GetAddress {
+    static async execute(user: User, addressId: bigint, contactId: bigint): Promise<Address> {
+        const contact = await GetContact.execute(user, contactId)
+ 
+        const address = await prismaClient.address.findFirst({
+            where: {
+                id: addressId,
+                contact_id: contact.id,
+            }
+        })
+ 
+        if (! address) {
+            throw new ResponseError(404, `Address by ID: ${addressId} not found`)
+        }
+ 
+        return address
+    }
+}
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/address/index.html b/coverage/lcov-report/src/action/address/index.html new file mode 100644 index 0000000..c599267 --- /dev/null +++ b/coverage/lcov-report/src/action/address/index.html @@ -0,0 +1,146 @@ + + + + + + Code coverage report for src/action/address + + + + + + + + + +
+
+

All files src/action/address

+
+ +
+ 100% + Statements + 13/13 +
+ + +
+ 100% + Branches + 8/8 +
+ + +
+ 100% + Functions + 3/3 +
+ + +
+ 100% + Lines + 13/13 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
create-address.ts +
+
100%4/4100%0/0100%1/1100%4/4
get-address.ts +
+
100%5/5100%2/2100%1/1100%5/5
update-address.ts +
+
100%4/4100%6/6100%1/1100%4/4
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/address/update-address.ts.html b/coverage/lcov-report/src/action/address/update-address.ts.html new file mode 100644 index 0000000..e4aaff1 --- /dev/null +++ b/coverage/lcov-report/src/action/address/update-address.ts.html @@ -0,0 +1,172 @@ + + + + + + Code coverage report for src/action/address/update-address.ts + + + + + + + + + +
+
+

All files / src/action/address update-address.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 6/6 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30  +  +  +  +  +  +  +  +  +  +3x +  +2x +  +2x +  +  +  +  +  +  +  +  +  +  +  +  +2x +  + 
import { Address, User } from "@prisma/client";
+import { UpdateAddressRequest } from "../../model/address-model";
+import GetContact from "../contact/get-contact";
+import GetAddress from "./get-address";
+import { prismaClient } from "../../application/database";
+import { Validation } from "../../validation/validation";
+import { AddressValidation } from "../../validation/address-validation";
+ 
+export default class UpdateAddress {
+    static async execute(user: User, data: UpdateAddressRequest): Promise<Address> {
+        const validated = Validation.validate<UpdateAddressRequest>(AddressValidation.UPDATE, data)
+ 
+        const address = await GetAddress.execute(user, data.id, data.contact_id)
+ 
+        const updatedAddress = await prismaClient.address.update({
+            data: {
+                street: validated.street || null,
+                city: validated.city || null,
+                province: validated.province || null,
+                country: validated.country,
+                postal_code: validated.postal_code,
+            },
+            where: {
+                id: address.id,
+            }
+        })
+ 
+        return updatedAddress
+    }
+}
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/create-contact.ts.html b/coverage/lcov-report/src/action/contact/create-contact.ts.html new file mode 100644 index 0000000..39d37f0 --- /dev/null +++ b/coverage/lcov-report/src/action/contact/create-contact.ts.html @@ -0,0 +1,163 @@ + + + + + + Code coverage report for src/action/contact/create-contact.ts + + + + + + + + + +
+
+

All files / src/action/contact create-contact.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27  +  +  +  +  +  +  +  +  +  +  +58x +  +57x +  +  +  +  +  +  +  +  +  +57x +  +  + 
import { Contact, User } from '@prisma/client'
+import { CreateContactRequest } from '../../model/contact-model'
+import { prismaClient } from '../../application/database'
+import { Validation } from '../../validation/validation'
+import { ContactValidation } from '../../validation/contact-validation'
+ 
+export default class CreateContact {
+  static async execute(
+    user: User,
+    request: CreateContactRequest
+  ): Promise<Contact> {
+    const validated = Validation.validate(ContactValidation.CREATE, request)
+ 
+    const createdContact = await prismaClient.contact.create({
+      data: {
+        username: user.username,
+        email: validated.email,
+        first_name: validated.first_name,
+        last_name: validated.last_name,
+        phone: validated.phone
+      }
+    })
+ 
+    return createdContact
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/delete-contact.ts.html b/coverage/lcov-report/src/action/contact/delete-contact.ts.html new file mode 100644 index 0000000..17891e6 --- /dev/null +++ b/coverage/lcov-report/src/action/contact/delete-contact.ts.html @@ -0,0 +1,136 @@ + + + + + + Code coverage report for src/action/contact/delete-contact.ts + + + + + + + + + +
+
+

All files / src/action/contact delete-contact.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18  +  +  +  +  +  +2x +  +1x +  +  +  +  +  +1x +  +  + 
import { User } from '@prisma/client'
+import GetContact from './get-contact'
+import { prismaClient } from '../../application/database'
+ 
+export default class DeleteContact {
+  static async execute(user: User, contactId: bigint) {
+    const contact = await GetContact.execute(user, contactId)
+ 
+    const deletedContact = await prismaClient.contact.delete({
+      where: {
+        id: contact.id
+      }
+    })
+ 
+    return deletedContact
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/get-contact.ts.html b/coverage/lcov-report/src/action/contact/get-contact.ts.html new file mode 100644 index 0000000..e65914a --- /dev/null +++ b/coverage/lcov-report/src/action/contact/get-contact.ts.html @@ -0,0 +1,145 @@ + + + + + + Code coverage report for src/action/contact/get-contact.ts + + + + + + + + + +
+
+

All files / src/action/contact get-contact.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 2/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21  +  +  +  +  +  +18x +  +  +  +  +  +  +18x +3x +  +  +15x +  +  + 
import { User } from '@prisma/client'
+import { prismaClient } from '../../application/database'
+import { ResponseError } from '../../error/response-error'
+ 
+export default class GetContact {
+  static async execute(user: User, contactId: bigint) {
+    const contact = await prismaClient.contact.findUnique({
+      where: {
+        id: contactId,
+        username: user.username
+      }
+    })
+ 
+    if (!contact) {
+      throw new ResponseError(404, `Contact ID: ${contactId} not found.`)
+    }
+ 
+    return contact
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/index.html b/coverage/lcov-report/src/action/contact/index.html new file mode 100644 index 0000000..27c055e --- /dev/null +++ b/coverage/lcov-report/src/action/contact/index.html @@ -0,0 +1,176 @@ + + + + + + Code coverage report for src/action/contact + + + + + + + + + +
+
+

All files src/action/contact

+
+ +
+ 100% + Statements + 25/25 +
+ + +
+ 100% + Branches + 8/8 +
+ + +
+ 100% + Functions + 5/5 +
+ + +
+ 100% + Lines + 25/25 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
create-contact.ts +
+
100%3/3100%0/0100%1/1100%3/3
delete-contact.ts +
+
100%3/3100%0/0100%1/1100%3/3
get-contact.ts +
+
100%4/4100%2/2100%1/1100%4/4
search-contact.ts +
+
100%12/12100%6/6100%1/1100%12/12
update-contact.ts +
+
100%3/3100%0/0100%1/1100%3/3
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/search-contact.ts.html b/coverage/lcov-report/src/action/contact/search-contact.ts.html new file mode 100644 index 0000000..b2b603b --- /dev/null +++ b/coverage/lcov-report/src/action/contact/search-contact.ts.html @@ -0,0 +1,313 @@ + + + + + + Code coverage report for src/action/contact/search-contact.ts + + + + + + + + + +
+
+

All files / src/action/contact search-contact.ts

+
+ +
+ 100% + Statements + 12/12 +
+ + +
+ 100% + Branches + 6/6 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 12/12 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77  +  +  +  +  +  +  +  +  +  +  +  +9x +  +8x +  +8x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +8x +2x +  +  +  +  +  +  +8x +2x +  +  +  +  +  +  +8x +  +  +  +  +  +  +8x +  +  +  +  +  +  +  +8x +  +8x +  +  +  +  +  +  +  +  +  + 
import { Contact, User } from '@prisma/client'
+import { SearchContactRequest } from '../../model/contact-model'
+import { prismaClient } from '../../application/database'
+import { Pagination } from '../../model/page-model'
+import { Validation } from '../../validation/validation'
+import { ContactValidation } from '../../validation/contact-validation'
+ 
+export default class SearchContact {
+  static async execute(
+    user: User,
+    request: SearchContactRequest
+  ): Promise<Pagination<Contact[]>> {
+    const validated = Validation.validate(ContactValidation.SEARCH, request)
+ 
+    const filters: {}[] = []
+ 
+    if (validated.name) {
+      filters.push({
+        OR: [
+          {
+            first_name: {
+              contains: validated.name
+            }
+          },
+          {
+            last_name: {
+              contains: validated.name
+            }
+          }
+        ]
+      })
+    }
+ 
+    if (validated.email) {
+      filters.push({
+        email: {
+          contains: validated.email
+        }
+      })
+    }
+ 
+    if (validated.phone) {
+      filters.push({
+        phone: {
+          contains: validated.phone
+        }
+      })
+    }
+ 
+    const query = {
+      where: {
+        username: user.username,
+        AND: filters
+      }
+    }
+ 
+    const contacts = await prismaClient.contact.findMany({
+      ...query,
+ 
+      skip: (validated.page - 1) * validated.size,
+ 
+      take: validated.size
+    })
+ 
+    const totalContacts = await prismaClient.contact.count(query)
+ 
+    return {
+      data: contacts,
+      page: {
+        current_page: validated.page,
+        size: validated.size,
+        total_page: Math.ceil(totalContacts / validated.size)
+      }
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/contact/update-contact.ts.html b/coverage/lcov-report/src/action/contact/update-contact.ts.html new file mode 100644 index 0000000..8025dde --- /dev/null +++ b/coverage/lcov-report/src/action/contact/update-contact.ts.html @@ -0,0 +1,157 @@ + + + + + + Code coverage report for src/action/contact/update-contact.ts + + + + + + + + + +
+
+

All files / src/action/contact update-contact.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25  +  +  +  +  +  +  +  +  +  +  +  +2x +  +1x +  +1x +  +  +  +  +  +  +  + 
import { Contact, User } from '@prisma/client'
+import { UpdateContactRequest } from '../../model/contact-model'
+import { prismaClient } from '../../application/database'
+import { Validation } from '../../validation/validation'
+import { ContactValidation } from '../../validation/contact-validation'
+import GetContact from './get-contact'
+ 
+export default class UpdateContact {
+  static async execute(
+    user: User,
+    request: UpdateContactRequest
+  ): Promise<Contact> {
+    const validated = Validation.validate(ContactValidation.UPDATE, request)
+ 
+    const contact = await GetContact.execute(user, request.id)
+ 
+    return await prismaClient.contact.update({
+      where: {
+        id: contact.id
+      },
+      data: validated
+    })
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/create-user.ts.html b/coverage/lcov-report/src/action/user/create-user.ts.html new file mode 100644 index 0000000..ef3b58c --- /dev/null +++ b/coverage/lcov-report/src/action/user/create-user.ts.html @@ -0,0 +1,214 @@ + + + + + + Code coverage report for src/action/user/create-user.ts + + + + + + + + + +
+
+

All files / src/action/user create-user.ts

+
+ +
+ 85.71% + Statements + 6/7 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 85.71% + Lines + 6/7 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44  +  +  +  +  +  +  +  +  +  +  +  +  +  +39x +  +  +  +  +37x +  +  +  +  +  +  +  +  +37x +  +  +  +37x +  +  +  +37x +  +  +  +37x +  +  + 
import {
+  CreateUserRequest,
+  toUserResponse,
+  UserResponse
+} from '../../model/user-model'
+import { Validation } from '../../validation/validation'
+import { UserValidation } from '../../validation/user-validation'
+import { prismaClient } from '../../application/database'
+import { ResponseError } from '../../error/response-error'
+import bcrypt from 'bcrypt'
+import { User } from '@prisma/client'
+ 
+export default class CreateUser {
+  static async execute(request: CreateUserRequest): Promise<User> {
+    const registerRequest = Validation.validate(
+      UserValidation.REGISTER,
+      request
+    )
+ 
+    const record = await prismaClient.user.findUnique({
+      where: {
+        username: registerRequest.username
+      },
+      select: {
+        username: true
+      }
+    })
+ 
+    Iif (record) {
+      throw new ResponseError(400, 'Username already exists')
+    }
+ 
+    registerRequest.password = (
+      await bcrypt.hash(registerRequest.password, 10)
+    ).toString()
+ 
+    const user = await prismaClient.user.create({
+      data: registerRequest
+    })
+ 
+    return user
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/get-user-by-token.ts.html b/coverage/lcov-report/src/action/user/get-user-by-token.ts.html new file mode 100644 index 0000000..1cf413c --- /dev/null +++ b/coverage/lcov-report/src/action/user/get-user-by-token.ts.html @@ -0,0 +1,157 @@ + + + + + + Code coverage report for src/action/user/get-user-by-token.ts + + + + + + + + + +
+
+

All files / src/action/user get-user-by-token.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 2/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25  +  +  +  +  +  +  +  +  +  +  +37x +  +  +  +  +  +37x +2x +  +  +35x +  +  + 
import { User } from '@prisma/client'
+import { prismaClient } from '../../application/database'
+import { ResponseError } from '../../error/response-error'
+import {
+  GetUserByTokenRequest,
+  UserResponse,
+  toUserResponse
+} from '../../model/user-model'
+ 
+export default class GetUserByToken {
+  static async execute(request: GetUserByTokenRequest): Promise<User> {
+    const user = await prismaClient.user.findFirst({
+      where: {
+        token: request.token
+      }
+    })
+ 
+    if (!user) {
+      throw new ResponseError(401, 'Invalid user token.')
+    }
+ 
+    return user
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/index.html b/coverage/lcov-report/src/action/user/index.html new file mode 100644 index 0000000..a4ee14a --- /dev/null +++ b/coverage/lcov-report/src/action/user/index.html @@ -0,0 +1,176 @@ + + + + + + Code coverage report for src/action/user + + + + + + + + + +
+
+

All files src/action/user

+
+ +
+ 96.66% + Statements + 29/30 +
+ + +
+ 91.66% + Branches + 11/12 +
+ + +
+ 100% + Functions + 5/5 +
+ + +
+ 96.66% + Lines + 29/30 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
create-user.ts +
+
85.71%6/750%1/2100%1/185.71%6/7
get-user-by-token.ts +
+
100%4/4100%2/2100%1/1100%4/4
login-user.ts +
+
100%9/9100%4/4100%1/1100%9/9
logout-user.ts +
+
100%2/2100%0/0100%1/1100%2/2
update-user.ts +
+
100%8/8100%4/4100%1/1100%8/8
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/login-user.ts.html b/coverage/lcov-report/src/action/user/login-user.ts.html new file mode 100644 index 0000000..b8afa35 --- /dev/null +++ b/coverage/lcov-report/src/action/user/login-user.ts.html @@ -0,0 +1,208 @@ + + + + + + Code coverage report for src/action/user/login-user.ts + + + + + + + + + +
+
+

All files / src/action/user login-user.ts

+
+ +
+ 100% + Statements + 9/9 +
+ + +
+ 100% + Branches + 4/4 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 9/9 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42  +  +  +  +  +  +  +  +  +  +  +37x +  +37x +  +  +  +  +  +37x +1x +  +  +36x +  +36x +1x +  +  +35x +  +  +  +  +  +  +  +  +35x +  +  + 
import { LoginUserRequest } from '../../model/user-model'
+import { UserValidation } from '../../validation/user-validation'
+import { Validation } from '../../validation/validation'
+import { prismaClient } from '../../application/database'
+import { ResponseError } from '../../error/response-error'
+import { v4 as uuidv4 } from 'uuid'
+import bcrypt from 'bcrypt'
+import { User } from '@prisma/client'
+ 
+export default class LoginUser {
+  static async execute(request: LoginUserRequest): Promise<User> {
+    Validation.validate(UserValidation.LOGIN, request)
+ 
+    const user = await prismaClient.user.findUnique({
+      where: {
+        username: request.username
+      }
+    })
+ 
+    if (!user) {
+      throw new ResponseError(401, 'Username or password incorrect.')
+    }
+ 
+    const passwordEquals = await bcrypt.compare(request.password, user.password)
+ 
+    if (!passwordEquals) {
+      throw new ResponseError(401, 'Username or password incorrect.')
+    }
+ 
+    const updatedUser = await prismaClient.user.update({
+      where: {
+        username: request.username
+      },
+      data: {
+        token: uuidv4()
+      }
+    })
+ 
+    return updatedUser
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/logout-user.ts.html b/coverage/lcov-report/src/action/user/logout-user.ts.html new file mode 100644 index 0000000..53fbc37 --- /dev/null +++ b/coverage/lcov-report/src/action/user/logout-user.ts.html @@ -0,0 +1,136 @@ + + + + + + Code coverage report for src/action/user/logout-user.ts + + + + + + + + + +
+
+

All files / src/action/user logout-user.ts

+
+ +
+ 100% + Statements + 2/2 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 2/2 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18  +  +  +  +  +1x +  +  +  +  +  +  +  +  +1x +  +  + 
import { User } from '@prisma/client'
+import { prismaClient } from '../../application/database'
+ 
+export default class LogoutUser {
+  static async execute(user: User): Promise<User> {
+    const updatedUser = await prismaClient.user.update({
+      where: {
+        username: user.username
+      },
+      data: {
+        token: null
+      }
+    })
+ 
+    return updatedUser
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/action/user/update-user.ts.html b/coverage/lcov-report/src/action/user/update-user.ts.html new file mode 100644 index 0000000..1d817ea --- /dev/null +++ b/coverage/lcov-report/src/action/user/update-user.ts.html @@ -0,0 +1,181 @@ + + + + + + Code coverage report for src/action/user/update-user.ts + + + + + + + + + +
+
+

All files / src/action/user update-user.ts

+
+ +
+ 100% + Statements + 8/8 +
+ + +
+ 100% + Branches + 4/4 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 8/8 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33  +  +  +  +  +  +  +  +  +4x +  +3x +  +3x +2x +  +  +3x +2x +  +  +3x +  +  +  +  +  +  +  +3x +  +  + 
import { User } from '@prisma/client'
+import { UpdateUserRequest } from '../../model/user-model'
+import { Validation } from '../../validation/validation'
+import { UserValidation } from '../../validation/user-validation'
+import bcrypt from 'bcrypt'
+import { prismaClient } from '../../application/database'
+ 
+export default class UpdateUser {
+  static async execute(user: User, request: UpdateUserRequest): Promise<User> {
+    Validation.validate(UserValidation.UPDATE, request)
+ 
+    let data: UpdateUserRequest = {}
+ 
+    if (request.name) {
+      data.name = request.name
+    }
+ 
+    if (request.password) {
+      data.password = (await bcrypt.hash(request.password, 10)).toString()
+    }
+ 
+    const updatedUser = await prismaClient.user.update({
+      where: {
+        username: user.username
+      },
+ 
+      data
+    })
+ 
+    return updatedUser
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/application/database.ts.html b/coverage/lcov-report/src/application/database.ts.html new file mode 100644 index 0000000..3265f1d --- /dev/null +++ b/coverage/lcov-report/src/application/database.ts.html @@ -0,0 +1,202 @@ + + + + + + Code coverage report for src/application/database.ts + + + + + + + + + +
+
+

All files / src/application database.ts

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 50% + Functions + 2/4 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40  +  +  +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +  +  +  +3x +  +  +  +3x +  +  +  +3x +  +  + 
import { PrismaClient } from '@prisma/client'
+import { logger } from './logger'
+ 
+export const prismaClient = new PrismaClient({
+  log: [
+    {
+      emit: 'event',
+      level: 'query'
+    },
+    {
+      emit: 'event',
+      level: 'error'
+    },
+    {
+      emit: 'event',
+      level: 'warn'
+    },
+    {
+      emit: 'event',
+      level: 'info'
+    }
+  ]
+})
+ 
+prismaClient.$on('error', (e: object) => {
+  // logger.debug(e)
+})
+ 
+prismaClient.$on('warn', (e: object) => {
+  // logger.warn(e)
+})
+ 
+prismaClient.$on('info', (e: object) => {
+  // logger.info(e)
+})
+ 
+prismaClient.$on('query', (e: object) => {
+  // logger.info(e)
+})
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/application/index.html b/coverage/lcov-report/src/application/index.html new file mode 100644 index 0000000..c84d91e --- /dev/null +++ b/coverage/lcov-report/src/application/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for src/application + + + + + + + + + +
+
+

All files src/application

+
+ +
+ 100% + Statements + 9/9 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 60% + Functions + 3/5 +
+ + +
+ 100% + Lines + 9/9 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
database.ts +
+
100%5/5100%0/050%2/4100%5/5
web.ts +
+
100%4/4100%0/0100%1/1100%4/4
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/application/web.ts.html b/coverage/lcov-report/src/application/web.ts.html new file mode 100644 index 0000000..77312f9 --- /dev/null +++ b/coverage/lcov-report/src/application/web.ts.html @@ -0,0 +1,121 @@ + + + + + + Code coverage report for src/application/web.ts + + + + + + + + + +
+
+

All files / src/application web.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13  +  +  +  +  +3x +  +3x +28x +  +  +3x + 
import express from 'express'
+import { publicRouter } from '../route/public-api'
+import { errorMiddleware } from '../middleware/validation'
+import { apiRouter } from '../route/api'
+ 
+export const web = express()
+ 
+BigInt.prototype.toJSON = function () {
+  return this.toString()
+}
+ 
+web.use(express.json()).use(publicRouter).use(apiRouter).use(errorMiddleware)
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/controller/address-controller.ts.html b/coverage/lcov-report/src/controller/address-controller.ts.html new file mode 100644 index 0000000..3b30050 --- /dev/null +++ b/coverage/lcov-report/src/controller/address-controller.ts.html @@ -0,0 +1,241 @@ + + + + + + Code coverage report for src/controller/address-controller.ts + + + + + + + + + +
+
+

All files / src/controller address-controller.ts

+
+ +
+ 100% + Statements + 19/19 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 3/3 +
+ + +
+ 100% + Lines + 19/19 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53  +  +  +  +  +  +  +  +  +4x +4x +  +4x +  +4x +  +2x +  +2x +  +  +  +  +3x +3x +  +3x +  +3x +  +1x +  +2x +  +  +  +  +3x +3x +  +3x +  +3x +  +3x +  +2x +  +1x +  +  +  + 
import { NextFunction, Response } from 'express'
+import CreateAddress from '../action/address/create-address'
+import UserRequest from '../request/user-request'
+import { CreateAddressRequest, toAddressResponse } from '../model/address-model'
+import GetAddress from '../action/address/get-address'
+import UpdateAddress from '../action/address/update-address'
+ 
+export default class AddressController {
+  static async create(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const data = req.body as CreateAddressRequest
+ 
+      data.contact_id = BigInt(req.params.contactId)
+ 
+      const response = await CreateAddress.execute(req.user!, data)
+ 
+      res.json(toAddressResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async get(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const addressId = BigInt(req.params.addressId)
+      
+      const contactId = BigInt(req.params.contactId)
+ 
+      const response = await GetAddress.execute(req.user !, addressId, contactId)
+ 
+      res.json(toAddressResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async update(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      let data = req.body
+ 
+      data.contact_id = BigInt(req.params.contactId)
+ 
+      data.id = BigInt(req.params.addressId)
+ 
+      const address = await UpdateAddress.execute(req.user !, data)
+ 
+      res.status(200).json(toAddressResponse(address))
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/controller/contact-controller.ts.html b/coverage/lcov-report/src/controller/contact-controller.ts.html new file mode 100644 index 0000000..e9dea65 --- /dev/null +++ b/coverage/lcov-report/src/controller/contact-controller.ts.html @@ -0,0 +1,322 @@ + + + + + + Code coverage report for src/controller/contact-controller.ts + + + + + + + + + +
+
+

All files / src/controller contact-controller.ts

+
+ +
+ 100% + Statements + 24/24 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 5/5 +
+ + +
+ 100% + Lines + 24/24 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +3x +  +2x +  +1x +  +  +  +  +  +  +  +  +2x +2x +2x +  +1x +  +1x +  +  +  +  +  +  +  +  +2x +2x +  +2x +  +2x +  +1x +  +1x +  +  +  +  +2x +2x +  +2x +  +1x +  +1x +  +  +  +  +9x +9x +  +8x +  +1x +  +  +  + 
import { NextFunction, Response } from 'express'
+import { UpdateContactRequest, toContactResponse } from '../model/contact-model'
+import CreateContact from '../action/contact/create-contact'
+import UserRequest from '../request/user-request'
+import GetContact from '../action/contact/get-contact'
+import UpdateContact from '../action/contact/update-contact'
+import DeleteContact from '../action/contact/delete-contact'
+import SearchContact from '../action/contact/search-contact'
+ 
+export default class ContactController {
+  static async create(
+    req: UserRequest,
+    res: Response,
+    next: NextFunction
+  ): Promise<void> {
+    try {
+      const response = await CreateContact.execute(req.user!, req.body)
+ 
+      res.json(toContactResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async get(
+    req: UserRequest,
+    res: Response,
+    next: NextFunction
+  ): Promise<void> {
+    try {
+      const contactId = BigInt(req.params.contactId)
+      const response = await GetContact.execute(req.user!, contactId)
+ 
+      res.json(toContactResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async update(
+    req: UserRequest,
+    res: Response,
+    next: NextFunction
+  ): Promise<void> {
+    try {
+      const data = req.body as UpdateContactRequest
+ 
+      data.id = BigInt(req.params.contactId)
+ 
+      const response = await UpdateContact.execute(req.user!, data)
+ 
+      res.json(toContactResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async delete(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const contactId = BigInt(req.params.contactId)
+ 
+      const response = await DeleteContact.execute(req.user!, contactId)
+ 
+      res.json(toContactResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async search(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const response = await SearchContact.execute(req.user!, req.body)
+ 
+      res.json(toContactResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/controller/index.html b/coverage/lcov-report/src/controller/index.html new file mode 100644 index 0000000..2aa25d5 --- /dev/null +++ b/coverage/lcov-report/src/controller/index.html @@ -0,0 +1,146 @@ + + + + + + Code coverage report for src/controller + + + + + + + + + +
+
+

All files src/controller

+
+ +
+ 96.77% + Statements + 60/62 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 13/13 +
+ + +
+ 96.77% + Lines + 60/62 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
address-controller.ts +
+
100%19/19100%0/0100%3/3100%19/19
contact-controller.ts +
+
100%24/24100%0/0100%5/5100%24/24
user-controller.ts +
+
89.47%17/19100%0/0100%5/589.47%17/19
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/controller/user-controller.ts.html b/coverage/lcov-report/src/controller/user-controller.ts.html new file mode 100644 index 0000000..24effb3 --- /dev/null +++ b/coverage/lcov-report/src/controller/user-controller.ts.html @@ -0,0 +1,268 @@ + + + + + + Code coverage report for src/controller/user-controller.ts + + + + + + + + + +
+
+

All files / src/controller user-controller.ts

+
+ +
+ 89.47% + Statements + 17/19 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 5/5 +
+ + +
+ 89.47% + Lines + 17/19 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62  +  +  +  +  +  +  +  +  +  +3x +3x +  +1x +  +2x +  +  +  +  +3x +3x +  +1x +  +2x +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +4x +4x +  +3x +  +1x +  +  +  +  +1x +1x +  +1x +  +  +  +  +  + 
import { NextFunction, Request, Response } from 'express'
+import CreateUser from '../action/user/create-user'
+import LoginUser from '../action/user/login-user'
+import { toUserResponse } from '../model/user-model'
+import UserRequest from '../request/user-request'
+import UpdateUser from '../action/user/update-user'
+import LogoutUser from '../action/user/logout-user'
+ 
+export class UserController {
+  static async register(req: Request, res: Response, next: NextFunction) {
+    try {
+      const response = await CreateUser.execute(req.body)
+ 
+      res.status(201).json(toUserResponse(response))
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async login(req: Request, res: Response, next: NextFunction) {
+    try {
+      const response = await LoginUser.execute(req.body)
+ 
+      res.status(200).json(toUserResponse(response))
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async currentUser(
+    req: UserRequest,
+    res: Response,
+    next: NextFunction
+  ) {
+    try {
+      res.status(200).json(toUserResponse(req.user!))
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async updateUser(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const user = await UpdateUser.execute(req.user!, req.body)
+ 
+      res.status(200).json(toUserResponse(user))
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+ 
+  static async logoutUser(req: UserRequest, res: Response, next: NextFunction) {
+    try {
+      const response = await LogoutUser.execute(req.user!)
+ 
+      res.json(toUserResponse(response)).status(200)
+    } catch (e: unknown) {
+      next(e)
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/error/index.html b/coverage/lcov-report/src/error/index.html new file mode 100644 index 0000000..43dcb3d --- /dev/null +++ b/coverage/lcov-report/src/error/index.html @@ -0,0 +1,116 @@ + + + + + + Code coverage report for src/error + + + + + + + + + +
+
+

All files src/error

+
+ +
+ 100% + Statements + 1/1 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 1/1 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
response-error.ts +
+
100%1/1100%0/0100%1/1100%1/1
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/error/response-error.ts.html b/coverage/lcov-report/src/error/response-error.ts.html new file mode 100644 index 0000000..ce3a999 --- /dev/null +++ b/coverage/lcov-report/src/error/response-error.ts.html @@ -0,0 +1,109 @@ + + + + + + Code coverage report for src/error/response-error.ts + + + + + + + + + +
+
+

All files / src/error response-error.ts

+
+ +
+ 100% + Statements + 1/1 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 1/1 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9  +  +  +  +  +9x +  +  + 
export class ResponseError extends Error {
+  constructor(
+    public status: number,
+    message: string
+  ) {
+    super(message)
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/middleware/index.html b/coverage/lcov-report/src/middleware/index.html new file mode 100644 index 0000000..28fe385 --- /dev/null +++ b/coverage/lcov-report/src/middleware/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for src/middleware + + + + + + + + + +
+
+

All files src/middleware

+
+ +
+ 91.66% + Statements + 11/12 +
+ + +
+ 75% + Branches + 3/4 +
+ + +
+ 100% + Functions + 2/2 +
+ + +
+ 91.66% + Lines + 11/12 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
user.ts +
+
100%6/6100%0/0100%1/1100%6/6
validation.ts +
+
83.33%5/675%3/4100%1/183.33%5/6
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/middleware/user.ts.html b/coverage/lcov-report/src/middleware/user.ts.html new file mode 100644 index 0000000..5847b06 --- /dev/null +++ b/coverage/lcov-report/src/middleware/user.ts.html @@ -0,0 +1,148 @@ + + + + + + Code coverage report for src/middleware/user.ts + + + + + + + + + +
+
+

All files / src/middleware user.ts

+
+ +
+ 100% + Statements + 6/6 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 6/6 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22  +  +  +  +3x +  +  +  +  +36x +36x +  +34x +  +34x +  +2x +  +  +  +  + 
import { NextFunction, Response } from 'express'
+import UserRequest from '../request/user-request'
+import GetUser from '../action/user/get-user-by-token'
+ 
+export const user = async (
+  req: UserRequest,
+  res: Response,
+  next: NextFunction
+) => {
+  try {
+    const user = await GetUser.execute({ token: req.get('X-API-TOKEN')! })
+ 
+    req.user = user
+ 
+    next()
+  } catch (e: unknown) {
+    res.status(401).json({
+      errors: 'Unauthorized user.'
+    })
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/middleware/validation.ts.html b/coverage/lcov-report/src/middleware/validation.ts.html new file mode 100644 index 0000000..94288aa --- /dev/null +++ b/coverage/lcov-report/src/middleware/validation.ts.html @@ -0,0 +1,163 @@ + + + + + + Code coverage report for src/middleware/validation.ts + + + + + + + + + +
+
+

All files / src/middleware validation.ts

+
+ +
+ 83.33% + Statements + 5/6 +
+ + +
+ 75% + Branches + 3/4 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 83.33% + Lines + 5/6 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27  +  +  +  +3x +  +  +  +  +  +15x +8x +  +  +  +  +7x +7x +  +  +  +  +  +  +  +  + 
import { NextFunction, Request, Response } from 'express'
+import { ZodError } from 'zod'
+import { ResponseError } from '../error/response-error'
+ 
+export const errorMiddleware = (
+  err: Error,
+  req: Request,
+  res: Response,
+  next: NextFunction
+) => {
+  if (err instanceof ZodError) {
+    return res.status(422).json({
+      errors: `Validation Error: ${JSON.stringify(err)}`
+    })
+  }
+ 
+  Eif (err instanceof ResponseError) {
+    return res.status(err.status).json({
+      errors: err.message
+    })
+  }
+ 
+  return res.status(500).json({
+    errors: err.message
+  })
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/model/address-model.ts.html b/coverage/lcov-report/src/model/address-model.ts.html new file mode 100644 index 0000000..bbd1e04 --- /dev/null +++ b/coverage/lcov-report/src/model/address-model.ts.html @@ -0,0 +1,235 @@ + + + + + + Code coverage report for src/model/address-model.ts + + + + + + + + + +
+
+

All files / src/model address-model.ts

+
+ +
+ 80% + Statements + 4/5 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 2/2 +
+ + +
+ 75% + Lines + 3/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +5x +  +  +  +  +  +  +  +  +  +5x +  +  +  +  +  +  +5x +  +  +  + 
import { Address } from '@prisma/client'
+import { Response } from './model'
+import { Pagination, isPagination } from './page-model'
+ 
+export type CreateAddressRequest = {
+  contact_id: bigint
+  street?: string | null
+  city?: string | null
+  province?: string | null
+  country: string
+  postal_code: string
+}
+ 
+export type UpdateAddressRequest = CreateAddressRequest & {
+  id: bigint
+}
+ 
+export type AddressResponse = {
+  id: bigint
+  street: string | null
+  city: string | null
+  province: string | null
+  country: string
+  postal_code: string
+}
+ 
+export function toAddressResponse(
+  address: Address | Pagination<Address[]>
+): Response<AddressResponse> | Pagination<AddressResponse[]> {
+  const callback = (address: Address) => ({
+    id: address.id,
+ 
+    street: address.street,
+    city: address.city,
+    province: address.province,
+    country: address.country,
+    postal_code: address.postal_code
+  })
+ 
+  Iif (isPagination<Address | Address[]>(address)) {
+    return {
+      data: address.data.map(callback),
+      page: address.page
+    }
+  }
+ 
+  return {
+    data: callback(address)
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/model/contact-model.ts.html b/coverage/lcov-report/src/model/contact-model.ts.html new file mode 100644 index 0000000..f3ed0a9 --- /dev/null +++ b/coverage/lcov-report/src/model/contact-model.ts.html @@ -0,0 +1,250 @@ + + + + + + Code coverage report for src/model/contact-model.ts + + + + + + + + + +
+
+

All files / src/model contact-model.ts

+
+ +
+ 85.71% + Statements + 6/7 +
+ + +
+ 100% + Branches + 2/2 +
+ + +
+ 66.66% + Functions + 2/3 +
+ + +
+ 83.33% + Lines + 5/6 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +20x +  +  +  +  +  +  +  +13x +8x +  +  +  +  +  +5x +  +  +  +  +3x +  +  + 
import { Contact } from '@prisma/client'
+import { Response } from './model'
+import { PageRequest, Pagination, isPagination } from './page-model'
+ 
+export type CreateContactRequest = {
+  first_name: string
+  last_name: string | null
+  email: string | null
+  phone: string | null
+}
+ 
+export type UpdateContactRequest = CreateContactRequest & {
+  id: bigint
+}
+ 
+export type ContactResponse = {
+  id: bigint
+  first_name: string
+  last_name: string | null
+  email: string | null
+  phone: string | null
+}
+ 
+export type SearchContactRequest = PageRequest & {
+  name?: string | null
+  email?: string | null
+  phone?: string | null
+}
+ 
+export function toContactResponse(
+  contacts: Contact | Pagination<Contact[]>
+): Response<ContactResponse> | Pagination<ContactResponse[]> {
+  const mapper = (contact: Contact) => ({
+    id: contact.id,
+    first_name: contact.first_name,
+    last_name: contact.last_name,
+    email: contact.email,
+    phone: contact.phone
+  })
+ 
+  if (isPagination<Contact | Contact[]>(contacts)) {
+    return {
+      ...contacts,
+      data: contacts.data.map(mapper)
+    }
+  }
+ 
+  return {
+    data: mapper(contacts)
+  }
+}
+ 
+export const isContactList = (
+  contacts: Contact | Contact[]
+): contacts is Contact[] => Array.isArray(contacts)
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/model/index.html b/coverage/lcov-report/src/model/index.html new file mode 100644 index 0000000..66c416a --- /dev/null +++ b/coverage/lcov-report/src/model/index.html @@ -0,0 +1,161 @@ + + + + + + Code coverage report for src/model + + + + + + + + + +
+
+

All files src/model

+
+ +
+ 86.66% + Statements + 13/15 +
+ + +
+ 75% + Branches + 3/4 +
+ + +
+ 85.71% + Functions + 6/7 +
+ + +
+ 84.61% + Lines + 11/13 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
address-model.ts +
+
80%4/550%1/2100%2/275%3/4
contact-model.ts +
+
85.71%6/7100%2/266.66%2/383.33%5/6
page-model.ts +
+
100%2/2100%0/0100%1/1100%2/2
user-model.ts +
+
100%1/1100%0/0100%1/1100%1/1
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/model/page-model.ts.html b/coverage/lcov-report/src/model/page-model.ts.html new file mode 100644 index 0000000..9948383 --- /dev/null +++ b/coverage/lcov-report/src/model/page-model.ts.html @@ -0,0 +1,139 @@ + + + + + + Code coverage report for src/model/page-model.ts + + + + + + + + + +
+
+

All files / src/model page-model.ts

+
+ +
+ 100% + Statements + 2/2 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 2/2 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +  +18x + 
import { Response } from './model'
+ 
+export type Pagination<T> = Response<T> & {
+  page: {
+    current_page: number
+    total_page: number
+    size: number
+  }
+}
+ 
+export type PageRequest = {
+  page: number
+  size: number
+}
+ 
+export const isPagination = <T>(
+  data: T | Pagination<T>
+): data is Pagination<T> => (data as Pagination<T>).page !== undefined
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/model/user-model.ts.html b/coverage/lcov-report/src/model/user-model.ts.html new file mode 100644 index 0000000..51063aa --- /dev/null +++ b/coverage/lcov-report/src/model/user-model.ts.html @@ -0,0 +1,211 @@ + + + + + + Code coverage report for src/model/user-model.ts + + + + + + + + + +
+
+

All files / src/model user-model.ts

+
+ +
+ 100% + Statements + 1/1 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 1/1 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +7x +  +  +  +  +  +  +  + 
import { User } from '@prisma/client'
+import { Response } from './model'
+ 
+export type UserResponse = {
+  username: string
+  name: string
+  token?: string | null
+}
+ 
+export type CreateUserRequest = {
+  username: string
+  name: string
+  password: string
+}
+ 
+export type LoginUserRequest = {
+  username: string
+  password: string
+}
+ 
+export type GetUserByTokenRequest = {
+  token: string
+}
+ 
+export type UpdateUserRequest = {
+  name?: string
+  password?: string
+}
+ 
+export function toUserResponse({
+  username,
+  name,
+  token
+}: User): Response<UserResponse> {
+  return {
+    data: {
+      name,
+      username,
+      token
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/route/api.ts.html b/coverage/lcov-report/src/route/api.ts.html new file mode 100644 index 0000000..9a35d25 --- /dev/null +++ b/coverage/lcov-report/src/route/api.ts.html @@ -0,0 +1,151 @@ + + + + + + Code coverage report for src/route/api.ts + + + + + + + + + +
+
+

All files / src/route api.ts

+
+ +
+ 100% + Statements + 13/13 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 13/13 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23  +  +  +  +  +  +3x +3x +  +3x +3x +3x +  +3x +3x +3x +3x +3x +  +3x +3x +3x + 
import express from 'express'
+import { UserController } from '../controller/user-controller'
+import { user } from '../middleware/user'
+import ContactController from '../controller/contact-controller'
+import AddressController from '../controller/address-controller'
+ 
+export const apiRouter = express.Router()
+apiRouter.use(user)
+ 
+apiRouter.get('/api/users/current', UserController.currentUser)
+apiRouter.patch('/api/users/current', UserController.updateUser)
+apiRouter.post('/api/logout', UserController.logoutUser)
+ 
+apiRouter.post('/api/contacts', ContactController.create)
+apiRouter.get('/api/contacts/:contactId', ContactController.get)
+apiRouter.put('/api/contacts/:contactId', ContactController.update)
+apiRouter.delete('/api/contacts/:contactId', ContactController.delete)
+apiRouter.post('/api/contacts/search', ContactController.search)
+ 
+apiRouter.post('/api/contacts/:contactId/addresses', AddressController.create)
+apiRouter.get('/api/contacts/:contactId/addresses/:addressId', AddressController.get)
+apiRouter.put('/api/contacts/:contactId/addresses/:addressId', AddressController.update)
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/route/index.html b/coverage/lcov-report/src/route/index.html new file mode 100644 index 0000000..87729d2 --- /dev/null +++ b/coverage/lcov-report/src/route/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for src/route + + + + + + + + + +
+
+

All files src/route

+
+ +
+ 100% + Statements + 16/16 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 16/16 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
api.ts +
+
100%13/13100%0/0100%0/0100%13/13
public-api.ts +
+
100%3/3100%0/0100%0/0100%3/3
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/route/public-api.ts.html b/coverage/lcov-report/src/route/public-api.ts.html new file mode 100644 index 0000000..5c1aead --- /dev/null +++ b/coverage/lcov-report/src/route/public-api.ts.html @@ -0,0 +1,106 @@ + + + + + + Code coverage report for src/route/public-api.ts + + + + + + + + + +
+
+

All files / src/route public-api.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8  +  +  +3x +  +3x +3x + 
import express from 'express'
+import { UserController } from '../controller/user-controller'
+ 
+export const publicRouter = express.Router()
+ 
+publicRouter.post('/api/login', UserController.login)
+publicRouter.post('/api/users', UserController.register)
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/validation/address-validation.ts.html b/coverage/lcov-report/src/validation/address-validation.ts.html new file mode 100644 index 0000000..46f7d9a --- /dev/null +++ b/coverage/lcov-report/src/validation/address-validation.ts.html @@ -0,0 +1,142 @@ + + + + + + Code coverage report for src/validation/address-validation.ts + + + + + + + + + +
+
+

All files / src/validation address-validation.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20  +  +  +3x +  +  +  +  +  +  +  +  +3x +  +3x +  +  +  +  + 
import { ZodType, bigint, z } from 'zod'
+ 
+export class AddressValidation {
+  static readonly #default = {
+    contact_id: z.bigint(),
+    street: z.string().min(0).max(255).optional(),
+    city: z.string().min(0).max(255).optional(),
+    province: z.string().min(0).max(255).optional(),
+    country: z.string().min(0).max(255),
+    postal_code: z.string().min(0).max(255)
+  }
+ 
+  static readonly CREATE: ZodType = z.object(this.#default)
+ 
+  static readonly UPDATE: ZodType = z.object({
+    ...this.#default,
+    id: z.bigint()
+  })
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/validation/contact-validation.ts.html b/coverage/lcov-report/src/validation/contact-validation.ts.html new file mode 100644 index 0000000..d119745 --- /dev/null +++ b/coverage/lcov-report/src/validation/contact-validation.ts.html @@ -0,0 +1,160 @@ + + + + + + Code coverage report for src/validation/contact-validation.ts + + + + + + + + + +
+
+

All files / src/validation contact-validation.ts

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26  +  +  +3x +  +  +  +  +  +  +3x +  +3x +  +  +  +  +3x +  +  +  +  +  +  +  + 
import { ZodType, z } from 'zod'
+ 
+export class ContactValidation {
+  static readonly #default = {
+    first_name: z.string().min(1).max(100),
+    last_name: z.string().min(1).max(100).optional(),
+    phone: z.string().min(1).max(100).optional(),
+    email: z.string().min(1).max(100).email().optional()
+  }
+ 
+  static readonly CREATE: ZodType = z.object(this.#default)
+ 
+  static readonly UPDATE: ZodType = z.object({
+    ...this.#default,
+    id: z.bigint()
+  })
+ 
+  static readonly SEARCH: ZodType = z.object({
+    name: z.string().optional(),
+    email: z.string().optional(),
+    phone: z.string().optional(),
+    size: z.number().positive(),
+    page: z.number().positive()
+  })
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/validation/index.html b/coverage/lcov-report/src/validation/index.html new file mode 100644 index 0000000..e161f24 --- /dev/null +++ b/coverage/lcov-report/src/validation/index.html @@ -0,0 +1,161 @@ + + + + + + Code coverage report for src/validation + + + + + + + + + +
+
+

All files src/validation

+
+ +
+ 100% + Statements + 11/11 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 11/11 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
address-validation.ts +
+
100%3/3100%0/0100%0/0100%3/3
contact-validation.ts +
+
100%4/4100%0/0100%0/0100%4/4
user-validation.ts +
+
100%3/3100%0/0100%0/0100%3/3
validation.ts +
+
100%1/1100%0/0100%1/1100%1/1
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/validation/user-validation.ts.html b/coverage/lcov-report/src/validation/user-validation.ts.html new file mode 100644 index 0000000..f142b4f --- /dev/null +++ b/coverage/lcov-report/src/validation/user-validation.ts.html @@ -0,0 +1,142 @@ + + + + + + Code coverage report for src/validation/user-validation.ts + + + + + + + + + +
+
+

All files / src/validation user-validation.ts

+
+ +
+ 100% + Statements + 3/3 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20  +  +  +3x +  +  +  +  +  +3x +  +  +  +  +3x +  +  +  +  + 
import { z, ZodType } from 'zod'
+ 
+export class UserValidation {
+  static readonly REGISTER: ZodType = z.object({
+    username: z.string().min(1).max(100),
+    password: z.string().min(1).max(100),
+    name: z.string().min(1).max(100)
+  })
+ 
+  static readonly LOGIN: ZodType = z.object({
+    username: z.string(),
+    password: z.string()
+  })
+ 
+  static readonly UPDATE: ZodType = z.object({
+    name: z.string().min(1).max(100).optional(),
+    password: z.string().min(1).max(100).optional()
+  })
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/src/validation/validation.ts.html b/coverage/lcov-report/src/validation/validation.ts.html new file mode 100644 index 0000000..4c4a6cc --- /dev/null +++ b/coverage/lcov-report/src/validation/validation.ts.html @@ -0,0 +1,106 @@ + + + + + + Code coverage report for src/validation/validation.ts + + + + + + + + + +
+
+

All files / src/validation validation.ts

+
+ +
+ 100% + Statements + 1/1 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 1/1 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8  +  +  +  +161x +  +  + 
import { ZodType } from 'zod'
+ 
+export class Validation {
+  static validate<T>(schema: ZodType<T>, data: T): T {
+    return schema.parse(data)
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/tests/fixtures/address.ts.html b/coverage/lcov-report/tests/fixtures/address.ts.html new file mode 100644 index 0000000..c157a6d --- /dev/null +++ b/coverage/lcov-report/tests/fixtures/address.ts.html @@ -0,0 +1,154 @@ + + + + + + Code coverage report for tests/fixtures/address.ts + + + + + + + + + +
+
+

All files / tests/fixtures address.ts

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 2/2 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24  +  +  +  +  +1x +  +  +10x +  +  +  +  +  +  +  +  +  +1x +5x +  +5x +  + 
import { faker } from '@faker-js/faker'
+import { CreateAddressRequest } from '../../src/model/address-model'
+import { Contact, User } from '@prisma/client'
+import CreateAddress from '../../src/action/address/create-address'
+ 
+export const createAddressRequest = (
+  contact: Contact,
+  state?: Partial<CreateAddressRequest>
+): CreateAddressRequest => ({
+  contact_id: contact.id,
+  street: faker.location.streetAddress(),
+  city: faker.location.city(),
+  province: faker.location.state(),
+  country: faker.location.country(),
+  postal_code: faker.location.zipCode(),
+  ...state
+})
+ 
+export const createAddress = async (user: User, contact: Contact) => {
+  const request = createAddressRequest(contact)
+ 
+  return await CreateAddress.execute(user, request)
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/tests/fixtures/contact.ts.html b/coverage/lcov-report/tests/fixtures/contact.ts.html new file mode 100644 index 0000000..25da4aa --- /dev/null +++ b/coverage/lcov-report/tests/fixtures/contact.ts.html @@ -0,0 +1,145 @@ + + + + + + Code coverage report for tests/fixtures/contact.ts + + + + + + + + + +
+
+

All files / tests/fixtures contact.ts

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 2/2 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21  +  +  +  +  +2x +  +57x +  +  +  +  +  +  +  +2x +15x +  +15x +  + 
import { faker } from '@faker-js/faker'
+import { CreateContactRequest } from '../../src/model/contact-model'
+import { User } from '@prisma/client'
+import CreateContact from '../../src/action/contact/create-contact'
+ 
+export const createContactRequest = (
+  state?: Partial<CreateContactRequest>
+): CreateContactRequest => ({
+  first_name: faker.person.firstName(),
+  last_name: faker.person.lastName(),
+  email: faker.internet.email(),
+  phone: faker.phone.number(),
+  ...state
+})
+ 
+export const createContact = async (user: User) => {
+  const request = createContactRequest()
+ 
+  return await CreateContact.execute(user, request)
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/tests/fixtures/index.html b/coverage/lcov-report/tests/fixtures/index.html new file mode 100644 index 0000000..e7df9d0 --- /dev/null +++ b/coverage/lcov-report/tests/fixtures/index.html @@ -0,0 +1,146 @@ + + + + + + Code coverage report for tests/fixtures + + + + + + + + + +
+
+

All files tests/fixtures

+
+ +
+ 100% + Statements + 16/16 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 6/6 +
+ + +
+ 100% + Lines + 16/16 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
address.ts +
+
100%5/5100%0/0100%2/2100%5/5
contact.ts +
+
100%5/5100%0/0100%2/2100%5/5
user.ts +
+
100%6/6100%0/0100%2/2100%6/6
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/tests/fixtures/user.ts.html b/coverage/lcov-report/tests/fixtures/user.ts.html new file mode 100644 index 0000000..97f84ab --- /dev/null +++ b/coverage/lcov-report/tests/fixtures/user.ts.html @@ -0,0 +1,148 @@ + + + + + + Code coverage report for tests/fixtures/user.ts + + + + + + + + + +
+
+

All files / tests/fixtures user.ts

+
+ +
+ 100% + Statements + 6/6 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 2/2 +
+ + +
+ 100% + Lines + 6/6 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22  +  +  +  +  +  +3x +39x +  +  +  +  +  +  +3x +28x +  +28x +  +28x +  + 
import { faker } from '@faker-js/faker'
+import { CreateUserRequest } from '../../src/model/user-model'
+import { User } from '@prisma/client'
+import CreateUser from '../../src/action/user/create-user'
+import LoginUser from '../../src/action/user/login-user'
+ 
+export const createUserRequest = (): CreateUserRequest => {
+  return {
+    username: faker.internet.userName(),
+    name: faker.person.fullName(),
+    password: faker.internet.password()
+  }
+}
+ 
+export const createUser = async (): Promise<User> => {
+  const request = createUserRequest()
+ 
+  await CreateUser.execute(request)
+ 
+  return await LoginUser.execute(request)
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov.info b/coverage/lcov.info new file mode 100644 index 0000000..bb6c54b --- /dev/null +++ b/coverage/lcov.info @@ -0,0 +1,646 @@ +TN: +SF:src/action/address/create-address.ts +FN:9,(anonymous_0) +FNF:1 +FNH:1 +FNDA:9,(anonymous_0) +DA:13,9 +DA:15,8 +DA:17,7 +DA:21,7 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/action/address/get-address.ts +FN:7,(anonymous_0) +FNF:1 +FNH:1 +FNDA:5,(anonymous_0) +DA:8,5 +DA:10,5 +DA:17,5 +DA:18,2 +DA:21,3 +LF:5 +LH:5 +BRDA:17,0,0,2 +BRDA:17,0,1,3 +BRF:2 +BRH:2 +end_of_record +TN: +SF:src/action/address/update-address.ts +FN:10,(anonymous_0) +FNF:1 +FNH:1 +FNDA:3,(anonymous_0) +DA:11,3 +DA:13,2 +DA:15,2 +DA:28,2 +LF:4 +LH:4 +BRDA:17,0,0,2 +BRDA:17,0,1,1 +BRDA:18,1,0,2 +BRDA:18,1,1,1 +BRDA:19,2,0,2 +BRDA:19,2,1,1 +BRF:6 +BRH:6 +end_of_record +TN: +SF:src/action/contact/create-contact.ts +FN:8,(anonymous_0) +FNF:1 +FNH:1 +FNDA:58,(anonymous_0) +DA:12,58 +DA:14,57 +DA:24,57 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/action/contact/delete-contact.ts +FN:6,(anonymous_0) +FNF:1 +FNH:1 +FNDA:2,(anonymous_0) +DA:7,2 +DA:9,1 +DA:15,1 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/action/contact/get-contact.ts +FN:6,(anonymous_0) +FNF:1 +FNH:1 +FNDA:18,(anonymous_0) +DA:7,18 +DA:14,18 +DA:15,3 +DA:18,15 +LF:4 +LH:4 +BRDA:14,0,0,3 +BRDA:14,0,1,15 +BRF:2 +BRH:2 +end_of_record +TN: +SF:src/action/contact/search-contact.ts +FN:9,(anonymous_0) +FNF:1 +FNH:1 +FNDA:9,(anonymous_0) +DA:13,9 +DA:15,8 +DA:17,8 +DA:18,3 +DA:34,8 +DA:35,2 +DA:42,8 +DA:43,2 +DA:50,8 +DA:57,8 +DA:65,8 +DA:67,8 +LF:12 +LH:12 +BRDA:17,0,0,3 +BRDA:17,0,1,5 +BRDA:34,1,0,2 +BRDA:34,1,1,6 +BRDA:42,2,0,2 +BRDA:42,2,1,6 +BRF:6 +BRH:6 +end_of_record +TN: +SF:src/action/contact/update-contact.ts +FN:9,(anonymous_0) +FNF:1 +FNH:1 +FNDA:2,(anonymous_0) +DA:13,2 +DA:15,1 +DA:17,1 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/action/user/create-user.ts +FN:14,(anonymous_0) +FNF:1 +FNH:1 +FNDA:39,(anonymous_0) +DA:15,39 +DA:20,37 +DA:29,37 +DA:30,0 +DA:33,37 +DA:37,37 +DA:41,37 +LF:7 +LH:6 +BRDA:29,0,0,0 +BRDA:29,0,1,37 +BRF:2 +BRH:1 +end_of_record +TN: +SF:src/action/user/get-user-by-token.ts +FN:11,(anonymous_0) +FNF:1 +FNH:1 +FNDA:37,(anonymous_0) +DA:12,37 +DA:18,37 +DA:19,2 +DA:22,35 +LF:4 +LH:4 +BRDA:18,0,0,2 +BRDA:18,0,1,35 +BRF:2 +BRH:2 +end_of_record +TN: +SF:src/action/user/login-user.ts +FN:11,(anonymous_0) +FNF:1 +FNH:1 +FNDA:37,(anonymous_0) +DA:12,37 +DA:14,37 +DA:20,37 +DA:21,1 +DA:24,36 +DA:26,36 +DA:27,1 +DA:30,35 +DA:39,35 +LF:9 +LH:9 +BRDA:20,0,0,1 +BRDA:20,0,1,36 +BRDA:26,1,0,1 +BRDA:26,1,1,35 +BRF:4 +BRH:4 +end_of_record +TN: +SF:src/action/user/logout-user.ts +FN:5,(anonymous_0) +FNF:1 +FNH:1 +FNDA:1,(anonymous_0) +DA:6,1 +DA:15,1 +LF:2 +LH:2 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/action/user/update-user.ts +FN:9,(anonymous_0) +FNF:1 +FNH:1 +FNDA:4,(anonymous_0) +DA:10,4 +DA:12,3 +DA:14,3 +DA:15,2 +DA:18,3 +DA:19,2 +DA:22,3 +DA:30,3 +LF:8 +LH:8 +BRDA:14,0,0,2 +BRDA:14,0,1,1 +BRDA:18,1,0,2 +BRDA:18,1,1,1 +BRF:4 +BRH:4 +end_of_record +TN: +SF:src/application/database.ts +FN:25,(anonymous_0) +FN:29,(anonymous_1) +FN:33,(anonymous_2) +FN:37,(anonymous_3) +FNF:4 +FNH:2 +FNDA:0,(anonymous_0) +FNDA:0,(anonymous_1) +FNDA:3,(anonymous_2) +FNDA:768,(anonymous_3) +DA:4,3 +DA:25,3 +DA:29,3 +DA:33,3 +DA:37,3 +LF:5 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/application/web.ts +FN:8,(anonymous_0) +FNF:1 +FNH:1 +FNDA:28,(anonymous_0) +DA:6,3 +DA:8,3 +DA:9,28 +DA:12,3 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/controller/address-controller.ts +FN:9,(anonymous_0) +FN:23,(anonymous_1) +FN:37,(anonymous_2) +FNF:3 +FNH:3 +FNDA:4,(anonymous_0) +FNDA:3,(anonymous_1) +FNDA:3,(anonymous_2) +DA:10,4 +DA:11,4 +DA:13,4 +DA:15,4 +DA:17,2 +DA:19,2 +DA:24,3 +DA:25,3 +DA:27,3 +DA:29,3 +DA:31,1 +DA:33,2 +DA:38,3 +DA:39,3 +DA:41,3 +DA:43,3 +DA:45,3 +DA:47,2 +DA:49,1 +LF:19 +LH:19 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/controller/contact-controller.ts +FN:11,(anonymous_0) +FN:25,(anonymous_1) +FN:40,(anonymous_2) +FN:58,(anonymous_3) +FN:70,(anonymous_4) +FNF:5 +FNH:5 +FNDA:3,(anonymous_0) +FNDA:2,(anonymous_1) +FNDA:2,(anonymous_2) +FNDA:2,(anonymous_3) +FNDA:9,(anonymous_4) +DA:16,3 +DA:17,3 +DA:19,2 +DA:21,1 +DA:30,2 +DA:31,2 +DA:32,2 +DA:34,1 +DA:36,1 +DA:45,2 +DA:46,2 +DA:48,2 +DA:50,2 +DA:52,1 +DA:54,1 +DA:59,2 +DA:60,2 +DA:62,2 +DA:64,1 +DA:66,1 +DA:71,9 +DA:72,9 +DA:74,8 +DA:76,1 +LF:24 +LH:24 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/controller/user-controller.ts +FN:10,(anonymous_0) +FN:20,(anonymous_1) +FN:30,(anonymous_2) +FN:42,(anonymous_3) +FN:52,(anonymous_4) +FNF:5 +FNH:5 +FNDA:3,(anonymous_0) +FNDA:3,(anonymous_1) +FNDA:1,(anonymous_2) +FNDA:4,(anonymous_3) +FNDA:1,(anonymous_4) +DA:11,3 +DA:12,3 +DA:14,1 +DA:16,2 +DA:21,3 +DA:22,3 +DA:24,1 +DA:26,2 +DA:35,1 +DA:36,1 +DA:38,0 +DA:43,4 +DA:44,4 +DA:46,3 +DA:48,1 +DA:53,1 +DA:54,1 +DA:56,1 +DA:58,0 +LF:19 +LH:17 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/error/response-error.ts +FN:2,(anonymous_0) +FNF:1 +FNH:1 +FNDA:9,(anonymous_0) +DA:6,9 +LF:1 +LH:1 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/middleware/user.ts +FN:5,(anonymous_0) +FNF:1 +FNH:1 +FNDA:36,(anonymous_0) +DA:5,3 +DA:10,36 +DA:11,36 +DA:13,34 +DA:15,34 +DA:17,2 +LF:6 +LH:6 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/middleware/validation.ts +FN:5,(anonymous_0) +FNF:1 +FNH:1 +FNDA:15,(anonymous_0) +DA:5,3 +DA:11,15 +DA:12,8 +DA:17,7 +DA:18,7 +DA:23,0 +LF:6 +LH:5 +BRDA:11,0,0,8 +BRDA:11,0,1,7 +BRDA:17,1,0,7 +BRDA:17,1,1,0 +BRF:4 +BRH:3 +end_of_record +TN: +SF:src/model/address-model.ts +FN:27,toAddressResponse +FN:30,(anonymous_1) +FNF:2 +FNH:2 +FNDA:5,toAddressResponse +FNDA:5,(anonymous_1) +DA:30,5 +DA:40,5 +DA:41,0 +DA:47,5 +LF:4 +LH:3 +BRDA:40,0,0,0 +BRDA:40,0,1,5 +BRF:2 +BRH:1 +end_of_record +TN: +SF:src/model/contact-model.ts +FN:30,toContactResponse +FN:33,(anonymous_1) +FN:53,(anonymous_2) +FNF:3 +FNH:2 +FNDA:13,toContactResponse +FNDA:20,(anonymous_1) +FNDA:0,(anonymous_2) +DA:33,20 +DA:41,13 +DA:42,8 +DA:48,5 +DA:53,3 +DA:55,0 +LF:6 +LH:5 +BRDA:41,0,0,8 +BRDA:41,0,1,5 +BRF:2 +BRH:2 +end_of_record +TN: +SF:src/model/page-model.ts +FN:16,(anonymous_0) +FNF:1 +FNH:1 +FNDA:18,(anonymous_0) +DA:16,3 +DA:18,18 +LF:2 +LH:2 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/model/user-model.ts +FN:30,toUserResponse +FNF:1 +FNH:1 +FNDA:7,toUserResponse +DA:35,7 +LF:1 +LH:1 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/route/api.ts +FNF:0 +FNH:0 +DA:7,3 +DA:8,3 +DA:10,3 +DA:11,3 +DA:12,3 +DA:14,3 +DA:15,3 +DA:16,3 +DA:17,3 +DA:18,3 +DA:20,3 +DA:21,3 +DA:22,3 +LF:13 +LH:13 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/route/public-api.ts +FNF:0 +FNH:0 +DA:4,3 +DA:6,3 +DA:7,3 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/validation/address-validation.ts +FNF:0 +FNH:0 +DA:4,3 +DA:13,3 +DA:15,3 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/validation/contact-validation.ts +FNF:0 +FNH:0 +DA:4,3 +DA:11,3 +DA:13,3 +DA:18,3 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/validation/user-validation.ts +FNF:0 +FNH:0 +DA:4,3 +DA:10,3 +DA:15,3 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/validation/validation.ts +FN:4,(anonymous_0) +FNF:1 +FNH:1 +FNDA:161,(anonymous_0) +DA:5,161 +LF:1 +LH:1 +BRF:0 +BRH:0 +end_of_record +TN: +SF:tests/fixtures/address.ts +FN:6,(anonymous_0) +FN:19,(anonymous_1) +FNF:2 +FNH:2 +FNDA:10,(anonymous_0) +FNDA:5,(anonymous_1) +DA:6,1 +DA:9,10 +DA:19,1 +DA:20,5 +DA:22,5 +LF:5 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:tests/fixtures/contact.ts +FN:6,(anonymous_0) +FN:16,(anonymous_1) +FNF:2 +FNH:2 +FNDA:57,(anonymous_0) +FNDA:15,(anonymous_1) +DA:6,2 +DA:8,57 +DA:16,2 +DA:17,15 +DA:19,15 +LF:5 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:tests/fixtures/user.ts +FN:7,(anonymous_0) +FN:15,(anonymous_1) +FNF:2 +FNH:2 +FNDA:39,(anonymous_0) +FNDA:28,(anonymous_1) +DA:7,3 +DA:8,39 +DA:15,3 +DA:16,28 +DA:18,28 +DA:20,28 +LF:6 +LH:6 +BRF:0 +BRH:0 +end_of_record diff --git a/package.json b/package.json index e2b5105..83ae1bf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "jest", + "test": "jest --coverage", "start": "node dist/index.js", "dev": "nodemon src/application/web.ts", "format": "prettier ./src ./tests --write" diff --git a/src/action/address/get-address.ts b/src/action/address/get-address.ts index a884568..e1dedda 100644 --- a/src/action/address/get-address.ts +++ b/src/action/address/get-address.ts @@ -1,23 +1,27 @@ -import { Address, User } from "@prisma/client"; -import { prismaClient } from "../../application/database"; -import GetContact from "../contact/get-contact"; -import { ResponseError } from "../../error/response-error"; +import { Address, User } from '@prisma/client' +import { prismaClient } from '../../application/database' +import GetContact from '../contact/get-contact' +import { ResponseError } from '../../error/response-error' export default class GetAddress { - static async execute(user: User, addressId: bigint, contactId: bigint): Promise
{ - const contact = await GetContact.execute(user, contactId) + static async execute( + user: User, + addressId: bigint, + contactId: bigint + ): Promise
{ + const contact = await GetContact.execute(user, contactId) - const address = await prismaClient.address.findFirst({ - where: { - id: addressId, - contact_id: contact.id, - } - }) + const address = await prismaClient.address.findFirst({ + where: { + id: addressId, + contact_id: contact.id + } + }) - if (! address) { - throw new ResponseError(404, `Address by ID: ${addressId} not found`) - } - - return address + if (!address) { + throw new ResponseError(404, `Address by ID: ${addressId} not found`) } -} \ No newline at end of file + + return address + } +} diff --git a/src/action/address/update-address.ts b/src/action/address/update-address.ts new file mode 100644 index 0000000..fa452a0 --- /dev/null +++ b/src/action/address/update-address.ts @@ -0,0 +1,35 @@ +import { Address, User } from '@prisma/client' +import { UpdateAddressRequest } from '../../model/address-model' +import GetAddress from './get-address' +import { prismaClient } from '../../application/database' +import { Validation } from '../../validation/validation' +import { AddressValidation } from '../../validation/address-validation' + +export default class UpdateAddress { + static async execute( + user: User, + data: UpdateAddressRequest + ): Promise
{ + const validated = Validation.validate( + AddressValidation.UPDATE, + data + ) + + const address = await GetAddress.execute(user, data.id, data.contact_id) + + const updatedAddress = await prismaClient.address.update({ + data: { + street: validated.street || null, + city: validated.city || null, + province: validated.province || null, + country: validated.country, + postal_code: validated.postal_code + }, + where: { + id: address.id + } + }) + + return updatedAddress + } +} diff --git a/src/controller/address-controller.ts b/src/controller/address-controller.ts index edcc8ba..ccba560 100644 --- a/src/controller/address-controller.ts +++ b/src/controller/address-controller.ts @@ -3,6 +3,7 @@ import CreateAddress from '../action/address/create-address' import UserRequest from '../request/user-request' import { CreateAddressRequest, toAddressResponse } from '../model/address-model' import GetAddress from '../action/address/get-address' +import UpdateAddress from '../action/address/update-address' export default class AddressController { static async create(req: UserRequest, res: Response, next: NextFunction) { @@ -22,14 +23,30 @@ export default class AddressController { static async get(req: UserRequest, res: Response, next: NextFunction) { try { const addressId = BigInt(req.params.addressId) - + const contactId = BigInt(req.params.contactId) - const response = await GetAddress.execute(req.user !, addressId, contactId) + const response = await GetAddress.execute(req.user!, addressId, contactId) res.json(toAddressResponse(response)).status(200) } catch (e: unknown) { next(e) } } + + static async update(req: UserRequest, res: Response, next: NextFunction) { + try { + let data = req.body + + data.contact_id = BigInt(req.params.contactId) + + data.id = BigInt(req.params.addressId) + + const address = await UpdateAddress.execute(req.user!, data) + + res.status(200).json(toAddressResponse(address)) + } catch (e: unknown) { + next(e) + } + } } diff --git a/src/model/address-model.ts b/src/model/address-model.ts index 8f426c5..9e455d3 100644 --- a/src/model/address-model.ts +++ b/src/model/address-model.ts @@ -11,6 +11,10 @@ export type CreateAddressRequest = { postal_code: string } +export type UpdateAddressRequest = CreateAddressRequest & { + id: bigint +} + export type AddressResponse = { id: bigint street: string | null diff --git a/src/route/api.ts b/src/route/api.ts index 1c82a3f..e7b4459 100644 --- a/src/route/api.ts +++ b/src/route/api.ts @@ -18,4 +18,11 @@ apiRouter.delete('/api/contacts/:contactId', ContactController.delete) apiRouter.post('/api/contacts/search', ContactController.search) apiRouter.post('/api/contacts/:contactId/addresses', AddressController.create) -apiRouter.get('/api/contacts/:contactId/addresses/:addressId', AddressController.get) +apiRouter.get( + '/api/contacts/:contactId/addresses/:addressId', + AddressController.get +) +apiRouter.put( + '/api/contacts/:contactId/addresses/:addressId', + AddressController.update +) diff --git a/src/validation/address-validation.ts b/src/validation/address-validation.ts index 0534673..972a55d 100644 --- a/src/validation/address-validation.ts +++ b/src/validation/address-validation.ts @@ -1,12 +1,19 @@ -import { ZodType, z } from 'zod' +import { ZodType, bigint, z } from 'zod' export class AddressValidation { - static readonly CREATE: ZodType = z.object({ + static readonly #default = { contact_id: z.bigint(), street: z.string().min(0).max(255).optional(), city: z.string().min(0).max(255).optional(), province: z.string().min(0).max(255).optional(), country: z.string().min(0).max(255), postal_code: z.string().min(0).max(255) + } + + static readonly CREATE: ZodType = z.object(this.#default) + + static readonly UPDATE: ZodType = z.object({ + ...this.#default, + id: z.bigint() }) } diff --git a/tests/address.test.ts b/tests/address.test.ts index 8dddcea..0ec9ac3 100644 --- a/tests/address.test.ts +++ b/tests/address.test.ts @@ -7,6 +7,7 @@ import { AddressResponse } from '../src/model/address-model' import { Response } from '../src/model/model' import { faker } from '@faker-js/faker' import { add } from 'winston' +import { ResponseError } from '../src/error/response-error' describe('POST /api/contacts/{:contactId}/addresses', () => { it('can create address by contact', async () => { @@ -95,7 +96,7 @@ describe('POST /api/contacts/{:contactId}/addresses', () => { }) describe('GET /api/contacts/:contactId/addresses/:addresId', () => { - it ('can get address', async () => { + it('can get address', async () => { const user = await createUser() const contact = await createContact(user) @@ -104,7 +105,7 @@ describe('GET /api/contacts/:contactId/addresses/:addresId', () => { const response = await supertest(web) .get(`/api/contacts/${contact.id}/addresses/${address.id}`) - .set('X-API-TOKEN', user.token !) + .set('X-API-TOKEN', user.token!) .send() expect(response.status).toBe(200) @@ -119,7 +120,7 @@ describe('GET /api/contacts/:contactId/addresses/:addresId', () => { expect(body.data.postal_code).toBe(address.postal_code) }) - it ('cant get address by wrong contact', async () => { + it('cant get address by wrong contact', async () => { const user = await createUser() const contact = await createContact(user) @@ -130,22 +131,100 @@ describe('GET /api/contacts/:contactId/addresses/:addresId', () => { const response = await supertest(web) .get(`/api/contacts/${contact2nd.id}/addresses/${address.id}`) - .set('X-API-TOKEN', user.token !) + .set('X-API-TOKEN', user.token!) .send() expect(response.status).toBe(404) }) - it ('cant get address by unknown address', async () => { + it('cant get address by unknown address', async () => { const user = await createUser() const contact = await createContact(user) const response = await supertest(web) .get(`/api/contacts/${contact.id}/addresses/0`) - .set('X-API-TOKEN', user.token !) + .set('X-API-TOKEN', user.token!) .send() expect(response.status).toBe(404) }) }) + +describe('PUT /api/contacts/:contactId/addresses/:addressId', () => { + it('can update address if payload desirable', async () => { + const user = await createUser() + + const contact = await createContact(user) + + const address = await createAddress(user, contact) + + const request = createAddressRequest(contact) + + const response = await supertest(web) + .put(`/api/contacts/${contact.id}/addresses/${address.id}`) + .set('X-API-TOKEN', user.token!) + .send(request) + + expect(response.status).toBe(200) + + const body: Response = response.body + + expect(BigInt(body.data.id)).toBe(address.id) + expect(body.data.city).toBe(request.city) + expect(body.data.province).toBe(request.province) + expect(body.data.street).toBe(request.street) + expect(body.data.country).toBe(request.country) + expect(body.data.postal_code).toBe(request.postal_code) + }) + + it('can update address if payload desirable', async () => { + const user = await createUser() + + const contact = await createContact(user) + + const address = await createAddress(user, contact) + + const response = await supertest(web) + .put(`/api/contacts/${contact.id}/addresses/${address.id}`) + .set('X-API-TOKEN', user.token!) + .send({ + street: faker.word.words(50), + country: faker.word.words(50), + postal_code: faker.word.words(50), + province: faker.word.words(50), + city: faker.word.words(50) + }) + + expect(response.status).toBe(422) + }) + + it('can update address only required fields', async () => { + const user = await createUser() + + const contact = await createContact(user) + + const address = await createAddress(user, contact) + + const request = createAddressRequest(contact) + + const response = await supertest(web) + .put(`/api/contacts/${contact.id}/addresses/${address.id}`) + .set('X-API-TOKEN', user.token!) + .send({ + country: request.country, + postal_code: request.postal_code + }) + + expect(response.status).toBe(200) + + const body: Response = response.body + + expect(BigInt(body.data.id)).toBe(address.id) + expect(body.data.city).toBeNull() + expect(body.data.province).toBeNull() + expect(body.data.street).toBeNull() + expect(body.data.country).toBe(request.country) + expect(body.data.postal_code).toBe(request.postal_code) + }) +})