diff --git a/services/audit-dependencies.sh b/services/audit-dependencies.sh index e42ab23..6d32b39 100755 --- a/services/audit-dependencies.sh +++ b/services/audit-dependencies.sh @@ -5,4 +5,8 @@ yarn audit cd "$root"/cart yarn audit cd "$root"/documentation +yarn audit +cd "$root"/auth +yarn audit +cd "$root"/user yarn audit \ No newline at end of file diff --git a/services/documentation/index.js b/services/documentation/index.js index d42b486..7fba839 100644 --- a/services/documentation/index.js +++ b/services/documentation/index.js @@ -55,6 +55,10 @@ const options = { url: `${externalHost}:${externalPort}/auth-swagger.json`, name: 'Auth', }, + { + url: `${externalHost}:${externalPort}/user-swagger.json`, + name: 'User', + }, ], }, customCss: '.swagger-ui .topbar .link { display: none }', diff --git a/services/documentation/postman/user-postman.json b/services/documentation/postman/user-postman.json new file mode 100644 index 0000000..a05cd3a --- /dev/null +++ b/services/documentation/postman/user-postman.json @@ -0,0 +1,564 @@ +{ + "info" : { + "name" : "user", + "schema" : "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "description" : { + "content" : "Service to manage users" + }, + "version" : "1.0.0" + }, + "item" : [ { + "name" : "users", + "item" : [ { + "request" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ { + "key" : "email", + "disabled" : true, + "description" : { + "content" : "Type: string | Required: false" + } + } ], + "variable" : [ ] + }, + "method" : "GET", + "description" : { + "content" : "Get users; methodName: getUsers" + }, + "header" : [ ] + }, + "name" : "GET /users", + "description" : { + "content" : "Get users; methodName: getUsers" + }, + "event" : [ { + "listen" : "test", + "script" : { + "exec" : [ "pm.test(\"GET requests should return 2xx\", function () {", " pm.response.to.be.success;", "});" ], + "type" : "text/javascript" + } + } ], + "response" : [ { + "name" : "Example 200 - [user]", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ { + "key" : "email", + "disabled" : true, + "description" : { + "content" : "Type: string | Required: false" + } + } ], + "variable" : [ ] + }, + "method" : "GET", + "description" : { + "content" : "Get users; methodName: getUsers" + }, + "header" : [ ] + }, + "body" : "[ {\n \"updatedAt\" : \"2020-11-07T11:53:39.125Z\",\n \"email\" : \"20f3fe7e92c1\",\n \"lastName\" : \"bfd3faf79685\",\n \"createdAt\" : \"2020-11-07T11:53:39.125Z\",\n \"firstName\" : \"9850bebb76c8\",\n \"id\" : \"f41470bf-4bc3-43b7-90ed-cad1f5da1a1d\"\n} ]", + "code" : 200 + }, { + "name" : "Example 400 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ { + "key" : "email", + "disabled" : true, + "description" : { + "content" : "Type: string | Required: false" + } + } ], + "variable" : [ ] + }, + "method" : "GET", + "description" : { + "content" : "Get users; methodName: getUsers" + }, + "header" : [ ] + }, + "code" : 400 + } ], + "type" : "item" + }, { + "request" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "GET", + "description" : { + "content" : "Get a user by id; methodName: getUserById" + }, + "header" : [ ] + }, + "name" : "GET /users/:id", + "description" : { + "content" : "Get a user by id; methodName: getUserById" + }, + "event" : [ { + "listen" : "test", + "script" : { + "exec" : [ "pm.test(\"GET requests should return 2xx\", function () {", " pm.response.to.be.success;", "});" ], + "type" : "text/javascript" + } + } ], + "response" : [ { + "name" : "Example 200 - user", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "GET", + "description" : { + "content" : "Get a user by id; methodName: getUserById" + }, + "header" : [ ] + }, + "body" : "{\n \"updatedAt\" : \"2020-11-07T11:53:39.125Z\",\n \"email\" : \"da0d87f85268\",\n \"lastName\" : \"3e4bf8e6b14a\",\n \"createdAt\" : \"2020-11-07T11:53:39.125Z\",\n \"firstName\" : \"d333e90195c0\",\n \"id\" : \"ae391b41-b357-4e64-b5a3-9a60792af2d5\"\n}", + "code" : 200 + }, { + "name" : "Example 404 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "GET", + "description" : { + "content" : "Get a user by id; methodName: getUserById" + }, + "header" : [ ] + }, + "code" : 404 + } ], + "type" : "item" + }, { + "request" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ ], + "variable" : [ ] + }, + "method" : "PUT", + "description" : { + "content" : "Create a user; methodName: createUser" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"2728feff8290\",\n \"lastName\" : \"4c6d4433f956\",\n \"email\" : \"336b4b563f3c\",\n \"password\" : \"b6575c2e4032\"\n}", + "mode" : "raw" + } + }, + "name" : "PUT /users", + "description" : { + "content" : "Create a user; methodName: createUser" + }, + "event" : [ { + "listen" : "test", + "script" : { + "exec" : [ "pm.test(\"PUT requests should return 2xx\", function () {", " pm.response.to.be.success;", "});" ], + "type" : "text/javascript" + } + } ], + "response" : [ { + "name" : "Example 201 - user", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ ], + "variable" : [ ] + }, + "method" : "PUT", + "description" : { + "content" : "Create a user; methodName: createUser" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"2728feff8290\",\n \"lastName\" : \"4c6d4433f956\",\n \"email\" : \"336b4b563f3c\",\n \"password\" : \"b6575c2e4032\"\n}", + "mode" : "raw" + } + }, + "body" : "{\n \"updatedAt\" : \"2020-11-07T11:53:39.125Z\",\n \"email\" : \"2b172eff76da\",\n \"lastName\" : \"e8d49e227692\",\n \"createdAt\" : \"2020-11-07T11:53:39.125Z\",\n \"firstName\" : \"8344b2bc535a\",\n \"id\" : \"13f035b4-ca1f-4947-b1a8-2e582b178798\"\n}", + "code" : 201 + }, { + "name" : "Example 400 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ ], + "variable" : [ ] + }, + "method" : "PUT", + "description" : { + "content" : "Create a user; methodName: createUser" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"2728feff8290\",\n \"lastName\" : \"4c6d4433f956\",\n \"email\" : \"336b4b563f3c\",\n \"password\" : \"b6575c2e4032\"\n}", + "mode" : "raw" + } + }, + "code" : 400 + }, { + "name" : "Example 422 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users" ], + "query" : [ ], + "variable" : [ ] + }, + "method" : "PUT", + "description" : { + "content" : "Create a user; methodName: createUser" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"2728feff8290\",\n \"lastName\" : \"4c6d4433f956\",\n \"email\" : \"336b4b563f3c\",\n \"password\" : \"b6575c2e4032\"\n}", + "mode" : "raw" + } + }, + "code" : 422 + } ], + "type" : "item" + }, { + "request" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "PUT", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"cc37e0e8f87d\",\n \"lastName\" : \"a9d8ad9429c1\",\n \"email\" : \"8a7be82447a0\",\n \"password\" : \"264af3ce0eb6\"\n}", + "mode" : "raw" + } + }, + "name" : "PUT /users/:id", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "event" : [ { + "listen" : "test", + "script" : { + "exec" : [ "pm.test(\"PUT requests should return 2xx\", function () {", " pm.response.to.be.success;", "});" ], + "type" : "text/javascript" + } + } ], + "response" : [ { + "name" : "Example 200 - user", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "PUT", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"cc37e0e8f87d\",\n \"lastName\" : \"a9d8ad9429c1\",\n \"email\" : \"8a7be82447a0\",\n \"password\" : \"264af3ce0eb6\"\n}", + "mode" : "raw" + } + }, + "body" : "{\n \"updatedAt\" : \"2020-11-07T11:53:39.126Z\",\n \"email\" : \"7d7af19a3e39\",\n \"lastName\" : \"f59051a5847b\",\n \"createdAt\" : \"2020-11-07T11:53:39.126Z\",\n \"firstName\" : \"7d61b18143f9\",\n \"id\" : \"bdd895ae-1ec0-470a-901a-e53bb68fcba0\"\n}", + "code" : 200 + }, { + "name" : "Example 404 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "PUT", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"cc37e0e8f87d\",\n \"lastName\" : \"a9d8ad9429c1\",\n \"email\" : \"8a7be82447a0\",\n \"password\" : \"264af3ce0eb6\"\n}", + "mode" : "raw" + } + }, + "code" : 404 + }, { + "name" : "Example 400 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "PUT", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"cc37e0e8f87d\",\n \"lastName\" : \"a9d8ad9429c1\",\n \"email\" : \"8a7be82447a0\",\n \"password\" : \"264af3ce0eb6\"\n}", + "mode" : "raw" + } + }, + "code" : 400 + }, { + "name" : "Example 412 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "PUT", + "description" : { + "content" : "Update a user by id; methodName: updateUserById" + }, + "header" : [ { + "key" : "Content-Type", + "value" : "application/json", + "description" : { + "content" : "Required to send JSON body" + } + } ], + "body" : { + "raw" : "{\n \"firstName\" : \"cc37e0e8f87d\",\n \"lastName\" : \"a9d8ad9429c1\",\n \"email\" : \"8a7be82447a0\",\n \"password\" : \"264af3ce0eb6\"\n}", + "mode" : "raw" + } + }, + "code" : 412 + } ], + "type" : "item" + }, { + "request" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "DELETE", + "description" : { + "content" : "Delete a user; methodName: deleteUser" + }, + "header" : [ ] + }, + "name" : "DELETE /users/:id", + "description" : { + "content" : "Delete a user; methodName: deleteUser" + }, + "response" : [ { + "name" : "Example 204 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "DELETE", + "description" : { + "content" : "Delete a user; methodName: deleteUser" + }, + "header" : [ ] + }, + "code" : 204 + }, { + "name" : "Example 404 - unit", + "originalRequest" : { + "url" : { + "raw" : "{{BASE_URL}}/users/:id", + "host" : [ "{{BASE_URL}}" ], + "path" : [ "users", ":id" ], + "query" : [ ], + "variable" : [ { + "key" : "id", + "value" : "{{id}}", + "description" : { + "content" : "Type: uuid | Required: true" + }, + "disabled" : false + } ] + }, + "method" : "DELETE", + "description" : { + "content" : "Delete a user; methodName: deleteUser" + }, + "header" : [ ] + }, + "code" : 404 + } ], + "type" : "item" + } ], + "type" : "folder" + } ], + "event" : [ ], + "variable" : [ { + "key" : "BASE_URL", + "value" : "", + "type" : "string" + } ] +} diff --git a/services/documentation/swagger/user-swagger.json b/services/documentation/swagger/user-swagger.json new file mode 100644 index 0000000..8a754dc --- /dev/null +++ b/services/documentation/swagger/user-swagger.json @@ -0,0 +1,213 @@ +{ + "swagger": "2.0", + "info": { + "title": "user", + "description": "Service to manage users", + "version": "1.0.0" + }, + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/users": { + "get": { + "description": "Get users; methodName: getUsers", + "parameters": [ + { + "name": "email", + "in": "query", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "200 response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/user" + } + } + }, + "400": { + "description": "400 response" + } + } + }, + "put": { + "description": "Create a user; methodName: createUser", + "parameters": [ + { + "name": "user_form", + "in": "body", + "schema": { + "$ref": "#/definitions/user_form" + } + } + ], + "responses": { + "201": { + "description": "201 response", + "schema": { + "$ref": "#/definitions/user" + } + }, + "400": { + "description": "400 response" + }, + "422": { + "description": "422 response" + } + } + } + }, + "/users/{id}": { + "get": { + "description": "Get a user by id; methodName: getUserById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string", + "format": "uuid" + } + ], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/user" + } + }, + "404": { + "description": "404 response" + } + } + }, + "put": { + "description": "Update a user by id; methodName: updateUserById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "name": "user_form", + "in": "body", + "schema": { + "$ref": "#/definitions/user_form" + } + } + ], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/user" + } + }, + "400": { + "description": "400 response" + }, + "404": { + "description": "404 response" + }, + "412": { + "description": "412 response" + } + } + }, + "delete": { + "description": "Delete a user; methodName: deleteUser", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string", + "format": "uuid" + } + ], + "responses": { + "204": { + "description": "204 response" + }, + "404": { + "description": "404 response" + } + } + } + } + }, + "definitions": { + "user": { + "type": "object", + "description": "The model of a user in a get request", + "title": "user", + "required": [ + "id", + "firstName", + "lastName", + "email", + "createdAt", + "updatedAt" + ], + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "format": "date-time" + } + } + }, + "user_form": { + "type": "object", + "description": "The model used to create/update instances of users", + "title": "user_form", + "required": [ + "firstName", + "lastName", + "email", + "password" + ], + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/services/launcher.sh b/services/launcher.sh index 001247d..c2fa5bd 100755 --- a/services/launcher.sh +++ b/services/launcher.sh @@ -23,7 +23,8 @@ done if test ${#scriptArguments[@]} -lt 1 then echo "Launch all" - scriptArguments=(article cart documentation auth) + # The Auth service must be launch after user. + scriptArguments=(article cart documentation user auth) fi cd "$root"/api-gateway ENV=$env docker-compose up -d --build --quiet-pull --remove-orphans diff --git a/services/stop-all.sh b/services/stop-all.sh index 1397223..484ee8b 100755 --- a/services/stop-all.sh +++ b/services/stop-all.sh @@ -12,5 +12,7 @@ cd "$root"/cart docker-compose -f docker-compose.yaml -f docker-compose.local.yaml -f docker-compose.hot-reload.yaml down cd "$root"/documentation docker-compose -f docker-compose.yaml -f docker-compose.local.yaml -f docker-compose.hot-reload.yaml down +cd "$root"/user +docker-compose -f docker-compose.yaml -f docker-compose.local.yaml -f docker-compose.hot-reload.yaml down cd "$root"/kafka docker-compose down \ No newline at end of file diff --git a/services/upgrade-dependencies copy.sh b/services/upgrade-dependencies copy.sh index eebd3bc..4666379 100755 --- a/services/upgrade-dependencies copy.sh +++ b/services/upgrade-dependencies copy.sh @@ -5,4 +5,8 @@ yarn upgrade cd "$root"/cart yarn upgrade cd "$root"/documentation +yarn upgrade +cd "$root"/auth +yarn upgrade +cd "$root"/user yarn upgrade \ No newline at end of file