From d737ee0233c8a9a7c0c725b1303e0dcb0b2085c2 Mon Sep 17 00:00:00 2001 From: ALGLAVE Ivan <ivan.alglave8@etu.univ-lorraine.fr> Date: Thu, 2 Feb 2023 15:44:08 +0100 Subject: [PATCH] added doc to all but the login controller --- package-lock.json | 440 ++++++++++++++++++ package.json | 2 + src/groups/dto/create-group.dto.ts | 4 + src/groups/dto/update-group.dto.ts | 4 + src/groups/entities/group.entity.ts | 8 + src/groups/groups.controller.ts | 32 ++ src/internships/dto/create-internship.dto.ts | 3 + src/internships/dto/internship.dto.ts | 4 + .../dto/nested-create/address.dto.ts | 5 + .../dto/nested-create/affectation.dto.ts | 9 + .../dto/nested-create/company.dto.ts | 6 + .../dto/nested-create/compensation.dto.ts | 4 + .../dto/nested-create/information.dto.ts | 6 + .../dto/nested-create/student.dto.ts | 8 + .../dto/nested-create/tracking.dto.ts | 9 + src/internships/entities/internship.entity.ts | 4 + .../nested-entities/address.entity.ts | 6 + .../nested-entities/affectation.entity.ts | 9 + .../nested-entities/company.entity.ts | 6 + .../nested-entities/compensation.entity.ts | 5 + .../nested-entities/information.entity.ts | 6 + .../nested-entities/student.entity.ts | 8 + .../nested-entities/tracking.entity.ts | 10 + src/internships/internships.controller.ts | 40 ++ src/login/login.controller.ts | 6 +- src/main.ts | 50 ++ src/people/dto/create-people.dto.ts | 14 +- src/people/dto/update-people.dto.ts | 13 +- src/people/entities/people.entity.ts | 9 +- src/people/people.controller.ts | 46 +- 30 files changed, 750 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c2e07f..2247b9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,10 +16,12 @@ "@nestjs/mongoose": "^9.2.1", "@nestjs/passport": "^9.0.0", "@nestjs/platform-express": "^9.0.0", + "@nestjs/swagger": "^6.1.4", "class-transformer": "^0.5.1", "class-validator": "^0.13.2", "eslint-import-resolver-typescript": "^3.5.2", "fastify": "^4.9.2", + "fastify-swagger": "^5.2.0", "mailgun-js": "^0.22.0", "mongoose": "^6.7.2", "multer": "^1.4.5-lts.1", @@ -2725,6 +2727,25 @@ "@nestjs/common": "^8.0.0 || ^9.0.0" } }, + "node_modules/@nestjs/mapped-types": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.2.0.tgz", + "integrity": "sha512-NTFwPZkQWsArQH8QSyFWGZvJ08gR+R4TofglqZoihn/vU+ktHEJjMqsIsADwb7XD97DhiD+TVv5ac+jG33BHrg==", + "peerDependencies": { + "@nestjs/common": "^7.0.8 || ^8.0.0 || ^9.0.0", + "class-transformer": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0", + "class-validator": "^0.11.1 || ^0.12.0 || ^0.13.0", + "reflect-metadata": "^0.1.12" + }, + "peerDependenciesMeta": { + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, "node_modules/@nestjs/mongoose": { "version": "9.2.1", "resolved": "https://registry.npmjs.org/@nestjs/mongoose/-/mongoose-9.2.1.tgz", @@ -2879,6 +2900,37 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "node_modules/@nestjs/swagger": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-6.1.4.tgz", + "integrity": "sha512-kE8VjR+NaoKqxg8XqM/YYfALScPh4AcoR8Wywga8/OxHsTHY+MKxqvTpWp7IhCUWSA6xT8nQUpcC9Rt7C+r7Hw==", + "dependencies": { + "@nestjs/mapped-types": "1.2.0", + "js-yaml": "4.1.0", + "lodash": "4.17.21", + "path-to-regexp": "3.2.0", + "swagger-ui-dist": "4.15.5" + }, + "peerDependencies": { + "@fastify/static": "^6.0.0", + "@nestjs/common": "^9.0.0", + "@nestjs/core": "^9.0.0", + "class-transformer": "*", + "class-validator": "*", + "reflect-metadata": "^0.1.12" + }, + "peerDependenciesMeta": { + "@fastify/static": { + "optional": true + }, + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, "node_modules/@nestjs/testing": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-9.2.0.tgz", @@ -5308,6 +5360,14 @@ "node": ">=8.10.0" } }, + "node_modules/encoding-negotiator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/encoding-negotiator/-/encoding-negotiator-2.0.1.tgz", + "integrity": "sha512-GSK7qphNR4iPcejfAlZxKDoz3xMhnspwImK+Af5WhePS9jUpK/Oh7rUdyENWu+9rgDflOCTmAojBsgsvM8neAQ==", + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -6290,6 +6350,169 @@ "tiny-lru": "^9.0.2" } }, + "node_modules/fastify-plugin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz", + "integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA==" + }, + "node_modules/fastify-static": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/fastify-static/-/fastify-static-4.7.0.tgz", + "integrity": "sha512-zZhCfJv/hkmud2qhWqpU3K9XVAuy3+IV8Tp9BC5J5U+GyA2XwoB6h8lh9GqpEIqdXOw01WyWQllV7dOWVyAlXg==", + "dependencies": { + "fastify-static-deprecated": "npm:fastify-static@4.6.1", + "process-warning": "^1.0.0" + } + }, + "node_modules/fastify-static-deprecated": { + "name": "fastify-static", + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/fastify-static/-/fastify-static-4.6.1.tgz", + "integrity": "sha512-vy7N28U4AMhuOim12ZZWHulEE6OQKtzZbHgiB8Zj4llUuUQXPka0WHAQI3njm1jTCx4W6fixUHfpITxweMtAIA==", + "dependencies": { + "content-disposition": "^0.5.3", + "encoding-negotiator": "^2.0.1", + "fastify-plugin": "^3.0.0", + "glob": "^7.1.4", + "p-limit": "^3.1.0", + "readable-stream": "^3.4.0", + "send": "^0.17.1" + } + }, + "node_modules/fastify-static-deprecated/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/fastify-static-deprecated/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/fastify-static-deprecated/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fastify-static-deprecated/node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==" + }, + "node_modules/fastify-static-deprecated/node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fastify-static-deprecated/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/fastify-static-deprecated/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fastify-static-deprecated/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fastify-static-deprecated/node_modules/send": { + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "1.8.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/fastify-static-deprecated/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fastify-static/node_modules/process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + }, + "node_modules/fastify-swagger": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/fastify-swagger/-/fastify-swagger-5.2.0.tgz", + "integrity": "sha512-yKct50Mev9YIrhd2FRO4AChcJM9JwTBCziIjA4C+AI+hV2ystaIklgHVEwHoyqlaeQ+B4gZ1Z5rgOE87i4llLg==", + "dependencies": { + "fastify-swagger-deprecated": "npm:fastify-swagger@5.1.1", + "process-warning": "^1.0.0" + } + }, + "node_modules/fastify-swagger-deprecated": { + "name": "fastify-swagger", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/fastify-swagger/-/fastify-swagger-5.1.1.tgz", + "integrity": "sha512-7DA0zS8CCV5r+gbLgWdeeKEwLrVbbOxLMJVUfOl1H9+wSildSLD8hok2TLX7s3c28wOjF8+iZRxsz/hBDzfdIw==", + "dependencies": { + "fastify-plugin": "^3.0.0", + "fastify-static": "^4.0.0", + "js-yaml": "^4.0.0", + "json-schema-resolver": "^1.3.0", + "openapi-types": "^10.0.0", + "rfdc": "^1.3.0" + } + }, + "node_modules/fastify-swagger/node_modules/process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + }, "node_modules/fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -8683,6 +8906,19 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, + "node_modules/json-schema-resolver": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-schema-resolver/-/json-schema-resolver-1.3.0.tgz", + "integrity": "sha512-EX7W1r8aZ/T3j8GbbBxPXi60bnsELfT90OiA1QrbGMvwzVSbyMNOAzvMFcFb8m7gKCXZLJpGe+cJOvWgoFl29A==", + "dependencies": { + "debug": "^4.1.1", + "rfdc": "^1.1.4", + "uri-js": "^4.2.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -10753,6 +10989,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/openapi-types": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-10.0.0.tgz", + "integrity": "sha512-Y8xOCT2eiKGYDzMW9R4x5cmfc3vGaaI4EL2pwhDmodWw1HlK18YcZ4uJxc7Rdp7/gGzAygzH9SXr6GKYIXbRcQ==" + }, "node_modules/optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -12675,6 +12916,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/swagger-ui-dist": { + "version": "4.15.5", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.15.5.tgz", + "integrity": "sha512-V3eIa28lwB6gg7/wfNvAbjwJYmDXy1Jo1POjyTzlB6wPcHiGlRxq39TSjYGVjQrUSAzpv+a7nzp7mDxgNy57xA==" + }, "node_modules/symbol-observable": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", @@ -15961,6 +16207,12 @@ "jsonwebtoken": "8.5.1" } }, + "@nestjs/mapped-types": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.2.0.tgz", + "integrity": "sha512-NTFwPZkQWsArQH8QSyFWGZvJ08gR+R4TofglqZoihn/vU+ktHEJjMqsIsADwb7XD97DhiD+TVv5ac+jG33BHrg==", + "requires": {} + }, "@nestjs/mongoose": { "version": "9.2.1", "resolved": "https://registry.npmjs.org/@nestjs/mongoose/-/mongoose-9.2.1.tgz", @@ -16079,6 +16331,18 @@ } } }, + "@nestjs/swagger": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-6.1.4.tgz", + "integrity": "sha512-kE8VjR+NaoKqxg8XqM/YYfALScPh4AcoR8Wywga8/OxHsTHY+MKxqvTpWp7IhCUWSA6xT8nQUpcC9Rt7C+r7Hw==", + "requires": { + "@nestjs/mapped-types": "1.2.0", + "js-yaml": "4.1.0", + "lodash": "4.17.21", + "path-to-regexp": "3.2.0", + "swagger-ui-dist": "4.15.5" + } + }, "@nestjs/testing": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-9.2.0.tgz", @@ -17972,6 +18236,11 @@ "resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.0.0.tgz", "integrity": "sha512-++P0RhebUC8MJAwJOsT93dT+5oc5oPImp1HubZpAuCZ5kTLnhuuBhKHj2jJeO/Gj93idPBWmIuQ9QWMe5rX3pQ==" }, + "encoding-negotiator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/encoding-negotiator/-/encoding-negotiator-2.0.1.tgz", + "integrity": "sha512-GSK7qphNR4iPcejfAlZxKDoz3xMhnspwImK+Af5WhePS9jUpK/Oh7rUdyENWu+9rgDflOCTmAojBsgsvM8neAQ==" + }, "end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -18735,6 +19004,157 @@ "tiny-lru": "^9.0.2" } }, + "fastify-plugin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz", + "integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA==" + }, + "fastify-static": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/fastify-static/-/fastify-static-4.7.0.tgz", + "integrity": "sha512-zZhCfJv/hkmud2qhWqpU3K9XVAuy3+IV8Tp9BC5J5U+GyA2XwoB6h8lh9GqpEIqdXOw01WyWQllV7dOWVyAlXg==", + "requires": { + "fastify-static-deprecated": "npm:fastify-static@4.6.1", + "process-warning": "^1.0.0" + }, + "dependencies": { + "process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + } + } + }, + "fastify-static-deprecated": { + "version": "npm:fastify-static@4.6.1", + "resolved": "https://registry.npmjs.org/fastify-static/-/fastify-static-4.6.1.tgz", + "integrity": "sha512-vy7N28U4AMhuOim12ZZWHulEE6OQKtzZbHgiB8Zj4llUuUQXPka0WHAQI3njm1jTCx4W6fixUHfpITxweMtAIA==", + "requires": { + "content-disposition": "^0.5.3", + "encoding-negotiator": "^2.0.1", + "fastify-plugin": "^3.0.0", + "glob": "^7.1.4", + "p-limit": "^3.1.0", + "readable-stream": "^3.4.0", + "send": "^0.17.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + } + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==" + }, + "http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "requires": { + "ee-first": "1.1.1" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "send": { + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "1.8.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==" + } + } + }, + "fastify-swagger": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/fastify-swagger/-/fastify-swagger-5.2.0.tgz", + "integrity": "sha512-yKct50Mev9YIrhd2FRO4AChcJM9JwTBCziIjA4C+AI+hV2ystaIklgHVEwHoyqlaeQ+B4gZ1Z5rgOE87i4llLg==", + "requires": { + "fastify-swagger-deprecated": "npm:fastify-swagger@5.1.1", + "process-warning": "^1.0.0" + }, + "dependencies": { + "process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + } + } + }, + "fastify-swagger-deprecated": { + "version": "npm:fastify-swagger@5.1.1", + "resolved": "https://registry.npmjs.org/fastify-swagger/-/fastify-swagger-5.1.1.tgz", + "integrity": "sha512-7DA0zS8CCV5r+gbLgWdeeKEwLrVbbOxLMJVUfOl1H9+wSildSLD8hok2TLX7s3c28wOjF8+iZRxsz/hBDzfdIw==", + "requires": { + "fastify-plugin": "^3.0.0", + "fastify-static": "^4.0.0", + "js-yaml": "^4.0.0", + "json-schema-resolver": "^1.3.0", + "openapi-types": "^10.0.0", + "rfdc": "^1.3.0" + } + }, "fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -20506,6 +20926,16 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, + "json-schema-resolver": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-schema-resolver/-/json-schema-resolver-1.3.0.tgz", + "integrity": "sha512-EX7W1r8aZ/T3j8GbbBxPXi60bnsELfT90OiA1QrbGMvwzVSbyMNOAzvMFcFb8m7gKCXZLJpGe+cJOvWgoFl29A==", + "requires": { + "debug": "^4.1.1", + "rfdc": "^1.1.4", + "uri-js": "^4.2.2" + } + }, "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -22230,6 +22660,11 @@ "is-wsl": "^2.2.0" } }, + "openapi-types": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-10.0.0.tgz", + "integrity": "sha512-Y8xOCT2eiKGYDzMW9R4x5cmfc3vGaaI4EL2pwhDmodWw1HlK18YcZ4uJxc7Rdp7/gGzAygzH9SXr6GKYIXbRcQ==" + }, "optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -23703,6 +24138,11 @@ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, + "swagger-ui-dist": { + "version": "4.15.5", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.15.5.tgz", + "integrity": "sha512-V3eIa28lwB6gg7/wfNvAbjwJYmDXy1Jo1POjyTzlB6wPcHiGlRxq39TSjYGVjQrUSAzpv+a7nzp7mDxgNy57xA==" + }, "symbol-observable": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", diff --git a/package.json b/package.json index cb95605..ec1b454 100644 --- a/package.json +++ b/package.json @@ -32,10 +32,12 @@ "@nestjs/mongoose": "^9.2.1", "@nestjs/passport": "^9.0.0", "@nestjs/platform-express": "^9.0.0", + "@nestjs/swagger": "^6.1.4", "class-transformer": "^0.5.1", "class-validator": "^0.13.2", "eslint-import-resolver-typescript": "^3.5.2", "fastify": "^4.9.2", + "fastify-swagger": "^5.2.0", "mailgun-js": "^0.22.0", "mongoose": "^6.7.2", "multer": "^1.4.5-lts.1", diff --git a/src/groups/dto/create-group.dto.ts b/src/groups/dto/create-group.dto.ts index b1156ab..008f757 100644 --- a/src/groups/dto/create-group.dto.ts +++ b/src/groups/dto/create-group.dto.ts @@ -1,13 +1,17 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IsBoolean, IsString, IsNotEmpty } from 'class-validator'; export class CreateGroupDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() name: string; + @ApiProperty({ required: true, type: Boolean }) @IsBoolean() final: boolean; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() parent: any; diff --git a/src/groups/dto/update-group.dto.ts b/src/groups/dto/update-group.dto.ts index 6b7f725..dcd9e36 100644 --- a/src/groups/dto/update-group.dto.ts +++ b/src/groups/dto/update-group.dto.ts @@ -1,14 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IsArray, IsOptional } from 'class-validator'; export class UpdateGroupDto { + @ApiProperty({ required: false, type: [String] }) @IsArray() @IsOptional() responsibles: string[]; + @ApiProperty({ required: false, type: [String] }) @IsArray() @IsOptional() secretaries: string[]; + @ApiProperty({ required: false, type: [String] }) @IsArray() @IsOptional() students: string[]; diff --git a/src/groups/entities/group.entity.ts b/src/groups/entities/group.entity.ts index 6bfc55a..347336f 100644 --- a/src/groups/entities/group.entity.ts +++ b/src/groups/entities/group.entity.ts @@ -1,12 +1,20 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Group } from '../schemas/group.schema'; export class GroupEntity { + @ApiProperty() _id: string; + @ApiProperty() name: string; + @ApiProperty() final: boolean; + @ApiProperty() responsibles: string[]; + @ApiProperty() secretaries: string[]; + @ApiProperty() students: string[]; + @ApiProperty() parent: string; constructor(partial: Partial<Group>) { diff --git a/src/groups/groups.controller.ts b/src/groups/groups.controller.ts index 662eb3e..7418038 100644 --- a/src/groups/groups.controller.ts +++ b/src/groups/groups.controller.ts @@ -8,6 +8,12 @@ import { Body, UseInterceptors, } from '@nestjs/common'; +import { + ApiBody, + ApiCreatedResponse, + ApiParam, + ApiResponse, +} from '@nestjs/swagger'; import { HttpInterceptor } from '../interceptors/http.interceptor'; import { CreateGroupDto } from './dto/create-group.dto'; import { UpdateGroupDto } from './dto/update-group.dto'; @@ -19,21 +25,41 @@ import { GroupsService } from './groups.service'; export class GroupsController { constructor(private readonly _groupsService: GroupsService) {} + @ApiResponse({ + isArray: true, + type: GroupEntity, + description: 'Groups as a JSON objects list', + }) @Get() findAll(): Promise<GroupEntity[] | void> { return this._groupsService.findAll(); } + @ApiResponse({ + status: 200, + type: GroupEntity, + description: 'Group as a JSON object', + }) + @ApiParam({ name: 'id', type: String, description: 'Id of the group to get' }) @Get(':id') findOne(@Param() params: { id: string }): Promise<GroupEntity | void> { return this._groupsService.findOne(params.id); } + @ApiCreatedResponse({ description: 'Group was created successfully' }) + @ApiBody({ type: CreateGroupDto }) @Post() create(@Body() createGroupDto: CreateGroupDto): Promise<GroupEntity> { return this._groupsService.create(createGroupDto); } + @ApiResponse({ status: 200, description: 'Group was updated successfully' }) + @ApiParam({ + name: 'id', + type: String, + description: 'Id of the group to update', + }) + @ApiBody({ type: UpdateGroupDto }) @Put(':id') update( @Param() params: { id: string }, @@ -42,6 +68,12 @@ export class GroupsController { return this._groupsService.update(params.id, updateGroupDto); } + @ApiResponse({ status: 200, description: 'Group was deleted' }) + @ApiParam({ + name: 'id', + type: String, + description: 'Id of the group to delete', + }) @Delete(':id') delete(@Param() params: { id: string }): Promise<GroupEntity | void> { return this._groupsService.delete(params.id); diff --git a/src/internships/dto/create-internship.dto.ts b/src/internships/dto/create-internship.dto.ts index 6dfd532..4d2b659 100644 --- a/src/internships/dto/create-internship.dto.ts +++ b/src/internships/dto/create-internship.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -9,10 +10,12 @@ import { import { InformationDto } from './nested-create/information.dto'; export class CreateInternshipDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() studentId: string; + @ApiProperty({ required: true, type: InformationDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() diff --git a/src/internships/dto/internship.dto.ts b/src/internships/dto/internship.dto.ts index 331dab3..8a26881 100644 --- a/src/internships/dto/internship.dto.ts +++ b/src/internships/dto/internship.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -10,16 +11,19 @@ import { InformationDto } from './nested-create/information.dto'; import { TrackingDto } from './nested-create/tracking.dto'; export class InternshipDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() studentId: string; + @ApiProperty({ required: true, type: InformationDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => InformationDto) information: InformationDto; + @ApiProperty({ required: true, type: TrackingDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() diff --git a/src/internships/dto/nested-create/address.dto.ts b/src/internships/dto/nested-create/address.dto.ts index 2003cff..af017aa 100644 --- a/src/internships/dto/nested-create/address.dto.ts +++ b/src/internships/dto/nested-create/address.dto.ts @@ -1,18 +1,23 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IsString, IsNotEmpty } from 'class-validator'; export class AddressDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() street: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() city: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() postalCode: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() country: string; diff --git a/src/internships/dto/nested-create/affectation.dto.ts b/src/internships/dto/nested-create/affectation.dto.ts index 12cfca0..3174999 100644 --- a/src/internships/dto/nested-create/affectation.dto.ts +++ b/src/internships/dto/nested-create/affectation.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -10,34 +11,42 @@ import { import { AddressDto } from './address.dto'; export class AffectationDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() service: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() responsibleName: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() responsibleEmail: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() responsiblePhone: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() responsibleFunction: string; + @ApiProperty({ required: true, type: String }) @IsDateString() @IsNotEmpty() dateStart: Date; + @ApiProperty({ required: true, type: String }) @IsDateString() @IsNotEmpty() dateEnd: Date; + @ApiProperty({ required: true, type: AddressDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() diff --git a/src/internships/dto/nested-create/company.dto.ts b/src/internships/dto/nested-create/company.dto.ts index fee0c59..da74e23 100644 --- a/src/internships/dto/nested-create/company.dto.ts +++ b/src/internships/dto/nested-create/company.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -9,22 +10,27 @@ import { import { AddressDto } from './address.dto'; export class CompanyDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() ceoName: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() companyName: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() hrContactName: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() hrContactEmail: string; + @ApiProperty({ required: true, type: AddressDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() diff --git a/src/internships/dto/nested-create/compensation.dto.ts b/src/internships/dto/nested-create/compensation.dto.ts index 5e403bc..924fe49 100644 --- a/src/internships/dto/nested-create/compensation.dto.ts +++ b/src/internships/dto/nested-create/compensation.dto.ts @@ -1,14 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IsString, IsNotEmpty } from 'class-validator'; export class CompensationDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() gratificationAmount: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() modalities: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() othersAdvantages: string; diff --git a/src/internships/dto/nested-create/information.dto.ts b/src/internships/dto/nested-create/information.dto.ts index 7a28140..e604cbb 100644 --- a/src/internships/dto/nested-create/information.dto.ts +++ b/src/internships/dto/nested-create/information.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -12,30 +13,35 @@ import { CompensationDto } from './compensation.dto'; import { StudentDto } from './student.dto'; export class InformationDto { + @ApiProperty({ required: true, type: StudentDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => StudentDto) student: StudentDto; + @ApiProperty({ required: true, type: CompanyDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => CompanyDto) company: CompanyDto; + @ApiProperty({ required: true, type: AffectationDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => AffectationDto) affectation: AffectationDto; + @ApiProperty({ required: true, type: CompensationDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => CompensationDto) compensation: CompensationDto; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() internshipDescription: string; diff --git a/src/internships/dto/nested-create/student.dto.ts b/src/internships/dto/nested-create/student.dto.ts index 0d8d8cd..3af8399 100644 --- a/src/internships/dto/nested-create/student.dto.ts +++ b/src/internships/dto/nested-create/student.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsString, @@ -13,34 +14,41 @@ import { import { AddressDto } from './address.dto'; export class StudentDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() completeName: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsPhoneNumber() @IsNotEmpty() phone: string; + @ApiProperty({ required: true, type: Date }) @IsDateString() @IsNotEmpty() birthDate: Date; + @ApiProperty({ required: true, type: AddressDto }) @IsDefined() @IsNotEmptyObject() @ValidateNested() @Type(() => AddressDto) address: AddressDto; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() FormationAndSpecialty: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsEmail() @IsNotEmpty() email: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsAlphanumeric() @IsNotEmpty() diff --git a/src/internships/dto/nested-create/tracking.dto.ts b/src/internships/dto/nested-create/tracking.dto.ts index 868c9b0..ad76c5b 100644 --- a/src/internships/dto/nested-create/tracking.dto.ts +++ b/src/internships/dto/nested-create/tracking.dto.ts @@ -1,34 +1,43 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IsString, IsNotEmpty, IsBoolean, IsOptional } from 'class-validator'; export class TrackingDto { + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() state: string; + @ApiProperty({ required: false, type: String }) @IsBoolean() @IsOptional() studentEntersInternshipInformation?: boolean; + @ApiProperty({ required: false, type: String }) @IsBoolean() @IsOptional() responsibleAcceptsInternshipInformation?: boolean; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() secretaryEstablishesInternshipAgreement?: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() studentSignsInternshipAgreement?: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() responsibleSignsInternshipAgreement?: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() companySignsInternshipAgreement?: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() deanSignsInternshipAgreement?: string; diff --git a/src/internships/entities/internship.entity.ts b/src/internships/entities/internship.entity.ts index b886cc4..cd3bbc7 100644 --- a/src/internships/entities/internship.entity.ts +++ b/src/internships/entities/internship.entity.ts @@ -1,9 +1,13 @@ +import { ApiProperty } from '@nestjs/swagger'; import { InformationEntity } from './nested-entities/information.entity'; import { TrackingEntity } from './nested-entities/tracking.entity'; export class InternshipEntity { + @ApiProperty({ type: String }) studentId: string; + @ApiProperty({ type: InformationEntity }) information: InformationEntity; + @ApiProperty({ type: TrackingEntity }) tracking: TrackingEntity; constructor(partial: Partial<InternshipEntity>) { diff --git a/src/internships/entities/nested-entities/address.entity.ts b/src/internships/entities/nested-entities/address.entity.ts index db6ba95..8e3c48a 100644 --- a/src/internships/entities/nested-entities/address.entity.ts +++ b/src/internships/entities/nested-entities/address.entity.ts @@ -1,7 +1,13 @@ +import { ApiProperty } from '@nestjs/swagger'; + export class AddressEntity { + @ApiProperty() street: string; + @ApiProperty() postalCode: string; + @ApiProperty() city: string; + @ApiProperty() country: string; constructor(partial: Partial<AddressEntity>) { diff --git a/src/internships/entities/nested-entities/affectation.entity.ts b/src/internships/entities/nested-entities/affectation.entity.ts index d1bf619..d793fae 100644 --- a/src/internships/entities/nested-entities/affectation.entity.ts +++ b/src/internships/entities/nested-entities/affectation.entity.ts @@ -1,13 +1,22 @@ +import { ApiProperty } from '@nestjs/swagger'; import { AddressEntity } from './address.entity'; export class AffectationEntity { + @ApiProperty() service: string; + @ApiProperty() responsibleName: string; + @ApiProperty() responsibleEmail: string; + @ApiProperty() responsiblePhone: string; + @ApiProperty() responsibleFunction: string; + @ApiProperty() dateStart: Date; + @ApiProperty() dateEnd: Date; + @ApiProperty() address: AddressEntity; constructor(partial: Partial<AffectationEntity>) { diff --git a/src/internships/entities/nested-entities/company.entity.ts b/src/internships/entities/nested-entities/company.entity.ts index 25c3561..71d3130 100644 --- a/src/internships/entities/nested-entities/company.entity.ts +++ b/src/internships/entities/nested-entities/company.entity.ts @@ -1,10 +1,16 @@ +import { ApiProperty } from '@nestjs/swagger'; import { AddressEntity } from './address.entity'; export class CompanyEntity { + @ApiProperty() ceoName: string; + @ApiProperty() companyName: string; + @ApiProperty() hrContactName: string; + @ApiProperty() hrContactEmail: string; + @ApiProperty() address: AddressEntity; constructor(partial: Partial<CompanyEntity>) { diff --git a/src/internships/entities/nested-entities/compensation.entity.ts b/src/internships/entities/nested-entities/compensation.entity.ts index d097a14..f3da038 100644 --- a/src/internships/entities/nested-entities/compensation.entity.ts +++ b/src/internships/entities/nested-entities/compensation.entity.ts @@ -1,6 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; + export class CompensationEntity { + @ApiProperty() gratificationAmount: string; + @ApiProperty() modalities: string; + @ApiProperty() othersAdvantages: string; constructor(partial: Partial<CompensationEntity>) { diff --git a/src/internships/entities/nested-entities/information.entity.ts b/src/internships/entities/nested-entities/information.entity.ts index 4ecba28..f7d941f 100644 --- a/src/internships/entities/nested-entities/information.entity.ts +++ b/src/internships/entities/nested-entities/information.entity.ts @@ -1,13 +1,19 @@ +import { ApiProperty } from '@nestjs/swagger'; import { AffectationEntity } from './affectation.entity'; import { CompanyEntity } from './company.entity'; import { CompensationEntity } from './compensation.entity'; import { StudentEntity } from './student.entity'; export class InformationEntity { + @ApiProperty() student: StudentEntity; + @ApiProperty() company: CompanyEntity; + @ApiProperty() affectation: AffectationEntity; + @ApiProperty() compensation: CompensationEntity; + @ApiProperty() internshipDescription: string; constructor(partial: Partial<InformationEntity>) { diff --git a/src/internships/entities/nested-entities/student.entity.ts b/src/internships/entities/nested-entities/student.entity.ts index 780f7e9..dedd7f3 100644 --- a/src/internships/entities/nested-entities/student.entity.ts +++ b/src/internships/entities/nested-entities/student.entity.ts @@ -1,12 +1,20 @@ +import { ApiProperty } from '@nestjs/swagger'; import { AddressEntity } from './address.entity'; export class StudentEntity { + @ApiProperty() completeName: string; + @ApiProperty() phone: string; + @ApiProperty() birthDate: Date; + @ApiProperty() address: AddressEntity; + @ApiProperty() FormationAndSpecialty: string; + @ApiProperty() email: string; + @ApiProperty() socialSecurityNumber: string; constructor(partial: Partial<StudentEntity>) { diff --git a/src/internships/entities/nested-entities/tracking.entity.ts b/src/internships/entities/nested-entities/tracking.entity.ts index a13fd5b..5cd83f3 100644 --- a/src/internships/entities/nested-entities/tracking.entity.ts +++ b/src/internships/entities/nested-entities/tracking.entity.ts @@ -1,11 +1,21 @@ +import { ApiProperty } from '@nestjs/swagger'; + export class TrackingEntity { + @ApiProperty() state: string; + @ApiProperty() studentEntersInternshipInformation?: boolean; + @ApiProperty() responsibleAcceptsInternshipInformation?: boolean; + @ApiProperty() secretaryEstablishesInternshipAgreement?: string; + @ApiProperty() studentSignsInternshipAgreement?: string; + @ApiProperty() responsibleSignsInternshipAgreement?: string; + @ApiProperty() companySignsInternshipAgreement?: string; + @ApiProperty() deanSignsInternshipAgreement?: string; constructor(partial: Partial<TrackingEntity>) { diff --git a/src/internships/internships.controller.ts b/src/internships/internships.controller.ts index 3db74f0..35da874 100644 --- a/src/internships/internships.controller.ts +++ b/src/internships/internships.controller.ts @@ -24,17 +24,33 @@ import config from 'src/config'; import { Optional } from '@nestjs/common/decorators'; import { v4 } from 'uuid'; import { diskStorage } from 'multer'; +import { ApiBody, ApiParam, ApiResponse } from '@nestjs/swagger'; @Controller('internships') @UseInterceptors(HttpInterceptor) export class InternshipsController { constructor(private readonly _internshipsService: InternshipService) {} + @ApiResponse({ + status: 200, + type: [InternshipEntity], + description: 'Students as a JSON objects list', + }) @Get() findAll(): Promise<InternshipEntity[] | void> { return this._internshipsService.findAll(); } + @ApiResponse({ + status: 200, + type: InternshipEntity, + description: 'Student as a JSON object', + }) + @ApiParam({ + name: 'studentId', + type: String, + description: 'Id of the student whose internship to get', + }) @Get(':studentId') findOne( @Param() params: { studentId: string }, @@ -42,6 +58,11 @@ export class InternshipsController { return this._internshipsService.findOne(params.studentId); } + @ApiResponse({ status: 201, description: 'Student was created successfully' }) + @ApiBody({ + type: CreateInternshipDto, + description: 'Internship as a JSON object', + }) @Post() create( @Body() internshipDto: CreateInternshipDto, @@ -49,6 +70,12 @@ export class InternshipsController { return this._internshipsService.create(internshipDto); } + @ApiResponse({ status: 200, description: 'Student was updated successfully' }) + @ApiParam({ + name: 'studentId', + type: String, + description: 'Id of the student whose internship to update', + }) @Put(':studentId') update( @Param() params: { studentId: string }, @@ -58,6 +85,13 @@ export class InternshipsController { } // uploads even if invalid state... + @ApiParam({ + name: 'studentId', + type: String, + description: 'Id of the student whose internship to update', + }) + @ApiParam({ name: 'state', type: String, description: 'State to update' }) + @ApiResponse({ status: 200, description: 'State was updated successfully' }) @Put(':studentId/:state') @UseInterceptors( FileInterceptor('pdf', { @@ -97,6 +131,12 @@ export class InternshipsController { ); } + @ApiParam({ + name: 'studentId', + type: String, + description: 'Id of the student to delete', + }) + @ApiResponse({ status: 200, description: 'Student was deleted' }) @Delete(':studentId') delete( @Param() params: { studentId: string }, diff --git a/src/login/login.controller.ts b/src/login/login.controller.ts index 3722154..de2c8d4 100644 --- a/src/login/login.controller.ts +++ b/src/login/login.controller.ts @@ -1,6 +1,5 @@ -import { Controller, Post, Request, UseGuards } from '@nestjs/common'; +import { Controller, Post } from '@nestjs/common'; import { Body } from '@nestjs/common/decorators/http/route-params.decorator'; -import { AuthGuard } from '@nestjs/passport'; import { Login } from 'src/types/login'; import { LoginService } from './login.service'; @@ -8,9 +7,8 @@ import { LoginService } from './login.service'; export class LoginController { constructor(private loginService: LoginService) {} -// @UseGuards(AuthGuard('local')) @Post() - async login(@Body() req: Login) { + async login(@Body() req: Login) { console.log('controller ' + req.email + req.passwordHash); return this.loginService.login(req); } diff --git a/src/main.ts b/src/main.ts index bffb6ea..f73b104 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,61 @@ import config from './config'; +import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import { GroupsModule } from './groups/groups.module'; +import { InternshipsModule } from './internships/internships.module'; +import { PeopleModule } from './people/people.module'; +import { LoginModule } from './login/login.module'; async function bootstrap() { const env = process.env.NODE_ENV; const app = await NestFactory.create(AppModule); + + // Swaggers doc for groups + const groupsOptions = new DocumentBuilder() + .setTitle('Groups documentation') + .setDescription('API documentation for the Internship Manager application') + .setVersion('1.0') + .build(); + const groupsDocument = SwaggerModule.createDocument(app, groupsOptions, { + include: [GroupsModule], + }); + SwaggerModule.setup('api/groups', app, groupsDocument); + + // Swaggers doc for internships + const internshipsOptions = new DocumentBuilder() + .setTitle('Internship documentation') + .setDescription('API documentation for the Internship Manager application') + .setVersion('1.0') + .build(); + const internshipsDocument = SwaggerModule.createDocument( + app, + internshipsOptions, + { include: [InternshipsModule] }, + ); + SwaggerModule.setup('api/internships', app, internshipsDocument); + + // Swaggers doc for people + const peopleOptions = new DocumentBuilder() + .setTitle('People documentation') + .setDescription('API documentation for the Internship Manager application') + .setVersion('1.0') + .build(); + const peopleDocument = SwaggerModule.createDocument(app, peopleOptions, { + include: [PeopleModule], + }); + SwaggerModule.setup('api/people', app, peopleDocument); + + // API welcome page + const options = new DocumentBuilder() + .setTitle('Internship manager API documentation') + .setDescription('Documentation for the Internship manager API application') + .setVersion('1.0') + .build(); + const document = SwaggerModule.createDocument(app, options, { include: [] }); + SwaggerModule.setup('api', app, document); + if (env === 'dev') { app.enableCors(); } else if (env === 'prod') { diff --git a/src/people/dto/create-people.dto.ts b/src/people/dto/create-people.dto.ts index c26bd35..b5db281 100644 --- a/src/people/dto/create-people.dto.ts +++ b/src/people/dto/create-people.dto.ts @@ -1,23 +1,27 @@ -import { IsBoolean, IsString, IsNotEmpty, IsOptional } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; +import { IsString, IsNotEmpty, IsOptional } from 'class-validator'; export class CreatePeopleDto { - + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() firstname: string; + @ApiProperty({ required: true, type: String }) @IsString() @IsNotEmpty() lastname: string; + @ApiProperty({ required: false, type: String }) @IsOptional() passwordHash: string; + @ApiProperty({ required: true, type: String, pattern: 'email@gmail.com' }) @IsString() @IsNotEmpty() email: string; - + + @ApiProperty({ required: true, type: Number }) @IsNotEmpty() role: number; - -} \ No newline at end of file +} diff --git a/src/people/dto/update-people.dto.ts b/src/people/dto/update-people.dto.ts index 4097f1e..f939bd2 100644 --- a/src/people/dto/update-people.dto.ts +++ b/src/people/dto/update-people.dto.ts @@ -1,23 +1,28 @@ -import { IsOptional, IsString, IsNotEmpty } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; +import { IsOptional, IsString } from 'class-validator'; export class UpdatePeopleDto { + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() firstname: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() lastname: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() email: string; + @ApiProperty({ required: false, type: String }) @IsString() @IsOptional() passwordHash: string; - + + @ApiProperty({ required: false, type: Number }) @IsOptional() role: number; - -} \ No newline at end of file +} diff --git a/src/people/entities/people.entity.ts b/src/people/entities/people.entity.ts index 7f8bf24..00d87ad 100644 --- a/src/people/entities/people.entity.ts +++ b/src/people/entities/people.entity.ts @@ -1,14 +1,21 @@ +import { ApiProperty } from '@nestjs/swagger'; import { People } from '../schemas/people.schema'; export class PeopleEntity { + @ApiProperty() _id: string; + @ApiProperty() firstname: string; + @ApiProperty() lastname: string; + @ApiProperty() email: string; + @ApiProperty() passwordHash: string; + @ApiProperty() role: number; constructor(partial: Partial<People>) { Object.assign(this, partial); } -} \ No newline at end of file +} diff --git a/src/people/people.controller.ts b/src/people/people.controller.ts index 0837bc2..0a0c743 100644 --- a/src/people/people.controller.ts +++ b/src/people/people.controller.ts @@ -7,53 +7,75 @@ import { Param, Body, UseInterceptors, - UseGuards + UseGuards, } from '@nestjs/common'; import { CreatePeopleDto } from './dto/create-people.dto'; import { UpdatePeopleDto } from './dto/update-people.dto'; import { HttpInterceptor } from '../interceptors/http.interceptor'; -// import { CreatePeopleDto } from './dto/create-people.dto'; -// import { UpdatePeopleDto } from './dto/update-people.dto'; import { PeopleEntity } from './entities/people.entity'; import { PeopleService } from './people.service'; import { AuthGuard } from '@nestjs/passport'; - - interface Login { - email: string; - password: string; -} +import { ApiBody, ApiParam, ApiResponse } from '@nestjs/swagger'; @Controller('people') @UseInterceptors(HttpInterceptor) export class PeopleController { constructor(private readonly _peopleService: PeopleService) {} - @UseGuards(AuthGuard('jwt')) + @ApiResponse({ + status: 200, + type: [PeopleEntity], + description: 'People as a JSON objects list', + }) @Get() findAll(): Promise<PeopleEntity[] | void> { return this._peopleService.findAll(); } - + @UseGuards(AuthGuard('jwt')) + @ApiParam({ + name: 'id', + type: String, + description: 'Id of the person to get', + }) + @ApiResponse({ + status: 200, + type: PeopleEntity, + description: 'Person as a JSON object', + }) @Get(':id') findOne(@Param() params: { id: string }): Promise<PeopleEntity | void> { return this._peopleService.findOne(params.id); } @Post() + @ApiResponse({ status: 201, description: 'Person was created successfully' }) + @ApiBody({ type: CreatePeopleDto, description: 'Person as a JSON object' }) create(@Body() createPeopleDto: CreatePeopleDto): Promise<PeopleEntity> { return this._peopleService.create(createPeopleDto); } + @ApiParam({ + name: 'id', + type: String, + description: 'Id of the person to update', + }) @Put(':id') + @ApiResponse({ status: 200, description: 'Person was updated successfully' }) + @ApiBody({ type: UpdatePeopleDto, description: 'Person as a JSON object' }) update( @Param() params: { id: string }, - @Body() updateGroupDto: UpdatePeopleDto, + @Body() updatePeopleDto: UpdatePeopleDto, ): Promise<PeopleEntity | void> { - return this._peopleService.update(params.id, updateGroupDto); + return this._peopleService.update(params.id, updatePeopleDto); } + @ApiParam({ + name: 'id', + type: String, + description: 'Id of the person to delete', + }) @Delete(':id') delete(@Param() params: { id: string }): Promise<PeopleEntity | void> { return this._peopleService.delete(params.id); -- GitLab