| node_modules/ | node_modules/ | ||||
| loggerFiles/ | loggerFiles/ | ||||
| public/loggerFiles | |||||
| public/loggerFiles | |||||
| .idea |
| "bcryptjs": "^2.4.3", | "bcryptjs": "^2.4.3", | ||||
| "config": "^3.3.7", | "config": "^3.3.7", | ||||
| "cors": "^2.8.5", | "cors": "^2.8.5", | ||||
| "elmah.io.javascript": "^3.7.0", | |||||
| "express": "^4.18.1", | "express": "^4.18.1", | ||||
| "express-jwt": "^7.7.2", | "express-jwt": "^7.7.2", | ||||
| "helmet": "^5.1.0", | "helmet": "^5.1.0", | ||||
| "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | ||||
| "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" | ||||
| }, | }, | ||||
| "node_modules/elmah.io.javascript": { | |||||
| "version": "3.7.0", | |||||
| "resolved": "https://registry.npmjs.org/elmah.io.javascript/-/elmah.io.javascript-3.7.0.tgz", | |||||
| "integrity": "sha512-s7yyLo8tlZPURYxsT4tS977FfEXXaMzkbxZNLVRc90v949NgdfeJYLYyYe6c5fhcQkiIPsy3TgOCErSpaJWGvw==" | |||||
| }, | |||||
| "node_modules/emoji-regex": { | "node_modules/emoji-regex": { | ||||
| "version": "8.0.0", | "version": "8.0.0", | ||||
| "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", | ||||
| "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | ||||
| "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" | ||||
| }, | }, | ||||
| "elmah.io.javascript": { | |||||
| "version": "3.7.0", | |||||
| "resolved": "https://registry.npmjs.org/elmah.io.javascript/-/elmah.io.javascript-3.7.0.tgz", | |||||
| "integrity": "sha512-s7yyLo8tlZPURYxsT4tS977FfEXXaMzkbxZNLVRc90v949NgdfeJYLYyYe6c5fhcQkiIPsy3TgOCErSpaJWGvw==" | |||||
| }, | |||||
| "emoji-regex": { | "emoji-regex": { | ||||
| "version": "8.0.0", | "version": "8.0.0", | ||||
| "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", |
| "bcryptjs": "^2.4.3", | "bcryptjs": "^2.4.3", | ||||
| "config": "^3.3.7", | "config": "^3.3.7", | ||||
| "cors": "^2.8.5", | "cors": "^2.8.5", | ||||
| "elmah.io.javascript": "^3.7.0", | |||||
| "express": "^4.18.1", | "express": "^4.18.1", | ||||
| "express-jwt": "^7.7.2", | "express-jwt": "^7.7.2", | ||||
| "helmet": "^5.1.0", | "helmet": "^5.1.0", |
| module.exports = { | |||||
| openapi: "3.0.3", | |||||
| info: { | |||||
| title: "Trampa", | |||||
| description: "Trampa api" | |||||
| } | |||||
| } |
| module.exports = { | |||||
| components: { | |||||
| schemas: { | |||||
| id: { | |||||
| type: "string", | |||||
| description: "An id of a user" | |||||
| }, | |||||
| User: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| }, | |||||
| tokens: { | |||||
| type: "array", | |||||
| items: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| Token: { | |||||
| type: "object", | |||||
| properties: { | |||||
| token: { | |||||
| type: "string" | |||||
| }, | |||||
| userId: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| const basicInfo = require('./basicInfo'); | |||||
| const servers = require('./servers'); | |||||
| const components = require('./components'); | |||||
| const tags = require('./tags'); | |||||
| const routesDesc = require('./routesDesc'); | |||||
| module.exports = { | |||||
| ...basicInfo, | |||||
| ...servers, | |||||
| ...components, | |||||
| ...tags, | |||||
| ...routesDesc | |||||
| } |
| const getUser = require('./user/getUserDesc'); | |||||
| const getUsers = require('./user/getUsersDesc'); | |||||
| const createUser = require('./user/createUserDesc'); | |||||
| const updateUser = require('./user/updateUserDesc'); | |||||
| const updateUserContacts = require('./user/updateUserContactsDesc'); | |||||
| const deleteUserDesc = require('./user/deleteUserDesc'); | |||||
| const loginUserDesc = require('./token/loginUserDesc'); | |||||
| const logoutDesc = require('./token/logoutDesc'); | |||||
| const refreshTokenDesc = require('./token/refreshTokenDesc'); | |||||
| module.exports = { | |||||
| paths: { | |||||
| '/users': { | |||||
| ...getUsers, | |||||
| ...createUser | |||||
| }, | |||||
| '/users/{id}': { | |||||
| ...getUser, | |||||
| ...updateUser, | |||||
| ...updateUserContacts, | |||||
| ...deleteUserDesc | |||||
| }, | |||||
| '/auth/token': { | |||||
| ...loginUserDesc | |||||
| }, | |||||
| '/auth/logout': { | |||||
| ...logoutDesc | |||||
| }, | |||||
| '/auth/refresh': { | |||||
| ...refreshTokenDesc | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log in user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User logged in successfully!" | |||||
| }, | |||||
| 400: { | |||||
| description: "Wrong credentials!" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log out user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/Token" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User logged out successfully" | |||||
| }, | |||||
| 404: { | |||||
| description: "No user has the token provided!" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log out user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/Token" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User refreshed successfully" | |||||
| }, | |||||
| 404: { | |||||
| description: "Token not valid!" | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| post: { | |||||
| tags: ["User"], | |||||
| description: "Create user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User created successfully", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User" | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| 400: { | |||||
| description: "Object cant be empty", | |||||
| }, | |||||
| 401: { | |||||
| description: "Invalid input parameters", | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error", | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| delete: { | |||||
| tags: ["User"], | |||||
| description: "Delete user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", | |||||
| }, | |||||
| required: true, | |||||
| }, | |||||
| ], | |||||
| responses: { | |||||
| 204: { | |||||
| description: "User deleted successfully", | |||||
| }, | |||||
| 400: { | |||||
| description: "You need to provide valid Id'", | |||||
| }, | |||||
| 404: { | |||||
| description: "User not found", | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error", | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }; |
| module.exports = { | |||||
| get: { | |||||
| tags: ["User"], | |||||
| description: "Get user by id", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", | |||||
| }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| responses: { | |||||
| 200: { | |||||
| description: "Success", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User", | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| 400: { | |||||
| description: "Bad request" | |||||
| }, | |||||
| 404: { | |||||
| description: "User with specified id does not exist" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| get: { | |||||
| tags: ["User"], | |||||
| description: "Get all users", | |||||
| parameters: [], | |||||
| responses: { | |||||
| 200: { | |||||
| description: "Success", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User", | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| 200: { | |||||
| description: "Users returned successfully" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| patch: { | |||||
| tags: ["User"], | |||||
| description: "Update user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| // schema: { | |||||
| // $ref: "#/components/schemas/id", // data model of the param | |||||
| // }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| requestBody: { | |||||
| content: { | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| put: { | |||||
| tags: ["User"], | |||||
| description: "Update user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", // data model of the param | |||||
| }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 200: { | |||||
| description: "User updated successfully", | |||||
| }, | |||||
| 400: { | |||||
| description: "Invalid input parameters", | |||||
| }, | |||||
| 500: { | |||||
| description: "Server error", | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| module.exports = { | |||||
| servers: [ | |||||
| { | |||||
| url: "http://localhost:3000/", | |||||
| description: "Local server", | |||||
| }, | |||||
| ], | |||||
| } |
| module.exports = { | |||||
| tags: [ | |||||
| { | |||||
| name: "User" | |||||
| }, | |||||
| ], | |||||
| } |
| const winston = require('winston') | const winston = require('winston') | ||||
| const config = require('config') | const config = require('config') | ||||
| const loggerWinston = winston.createLogger({ | |||||
| const logger = winston.createLogger({ | |||||
| level: 'info', | level: 'info', | ||||
| format: winston.format.json(), | format: winston.format.json(), | ||||
| defaultMeta: { service: 'user-service' }, | defaultMeta: { service: 'user-service' }, | ||||
| transports: [ | transports: [ | ||||
| new winston.transports.File({ filename: '../public/loggerFiles/error.log', level: 'error' }), | new winston.transports.File({ filename: '../public/loggerFiles/error.log', level: 'error' }), | ||||
| new winston.transports.File({ filename: '../public/loggerFiles/all.log', level: 'silly' }), | new winston.transports.File({ filename: '../public/loggerFiles/all.log', level: 'silly' }), | ||||
| new winston.transports.Console({level: 'silly'}), | |||||
| ], | ], | ||||
| }); | }); | ||||
| if (config.util.getEnv('NODE_ENV') !== 'production') { | if (config.util.getEnv('NODE_ENV') !== 'production') { | ||||
| loggerWinston.add(new winston.transports.Console({ | |||||
| logger.add(new winston.transports.Console({ | |||||
| format: winston.format.simple(), | format: winston.format.simple(), | ||||
| })); | })); | ||||
| } | } | ||||
| module.exports = loggerWinston | |||||
| module.exports = logger |
| // const Elmahio = require("elmah.io.javascript") | |||||
| // | |||||
| // // TODO: da li ovo treba u configu (appsettings.json) da bude ili moze ovde hardkodirano | |||||
| // const loggerElmah = new Elmahio({ | |||||
| // apiKey: 'API_KEY', | |||||
| // logId: 'LOG_ID', | |||||
| // application: 'diligent-node-api' | |||||
| // }) | |||||
| // | |||||
| // module.exports = loggerElmah |
| //const loggerElmah = require('../logging/loggerElmah') | |||||
| const loggerWinston = require('../logging/loggerWinston') | |||||
| const logger = require('../logging/logger') | |||||
| const config = require('config') | const config = require('config') | ||||
| const errorLogger = (err, req, res, next) => { | const errorLogger = (err, req, res, next) => { | ||||
| console.error(err) | |||||
| //console.error(err) | |||||
| if (config.util.getEnv('NODE_ENV') === 'development') | if (config.util.getEnv('NODE_ENV') === 'development') | ||||
| loggerWinston.error(err) | |||||
| // else | |||||
| // loggerElmah.error('There has been an error', err) | |||||
| logger.error(err) | |||||
| next(err) | next(err) | ||||
| } | } |
| const logger = require("../logging/loggerWinston") | |||||
| const logger = require("../logging/logger") | |||||
| const requestLogging = async (req, res, next) => { | const requestLogging = async (req, res, next) => { | ||||
| res.header("Content-Type", 'application/json'); | res.header("Content-Type", 'application/json'); |
| const app = express() | const app = express() | ||||
| const port = process.env.NODE_ENV === 'production' ? 80 : 3001 | const port = process.env.NODE_ENV === 'production' ? 80 : 3001 | ||||
| require('./database/mongoose') | require('./database/mongoose') | ||||
| const docs = require('./documentation'); | |||||
| const swaggerUI = require("swagger-ui-express") | |||||
| const docs = require('./swagger.js'); | |||||
| const swaggerUI = require('swagger-ui-express') | |||||
| const { errorLogger, errorResponder } = require('./middleware/errorHandling.js') | const { errorLogger, errorResponder } = require('./middleware/errorHandling.js') | ||||
| const requestLogging = require('./middleware/requestLogging.js') | const requestLogging = require('./middleware/requestLogging.js') | ||||
| const cors = require('cors') //Cross-origin resource sharing | const cors = require('cors') //Cross-origin resource sharing |
| module.exports = { | |||||
| servers: [ | |||||
| { | |||||
| url: "http://localhost:3001/", | |||||
| description: "Local server", | |||||
| }, | |||||
| ], | |||||
| tags: [ | |||||
| { | |||||
| name: "User" | |||||
| }, | |||||
| ], | |||||
| openapi: "3.0.3", | |||||
| info: { | |||||
| title: "Trampa", | |||||
| description: "Trampa api" | |||||
| }, | |||||
| paths: { | |||||
| '/users': { | |||||
| get: { | |||||
| tags: ["User"], | |||||
| description: "Get all users", | |||||
| parameters: [], | |||||
| responses: { | |||||
| 200: { | |||||
| description: "Success", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User", | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| 200: { | |||||
| description: "Users returned successfully" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| }, | |||||
| post: { | |||||
| tags: ["User"], | |||||
| description: "Create user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User created successfully", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User" | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| 400: { | |||||
| description: "Object cant be empty", | |||||
| }, | |||||
| 401: { | |||||
| description: "Invalid input parameters", | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error", | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| '/users/{id}': { | |||||
| get: { | |||||
| tags: ["User"], | |||||
| description: "Get user by id", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", | |||||
| }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| responses: { | |||||
| 200: { | |||||
| description: "Success", | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/User", | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| 400: { | |||||
| description: "Bad request" | |||||
| }, | |||||
| 404: { | |||||
| description: "User with specified id does not exist" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| }, | |||||
| put: { | |||||
| tags: ["User"], | |||||
| description: "Update user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", // data model of the param | |||||
| }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 200: { | |||||
| description: "User updated successfully", | |||||
| }, | |||||
| 400: { | |||||
| description: "Invalid input parameters", | |||||
| }, | |||||
| 500: { | |||||
| description: "Server error", | |||||
| } | |||||
| } | |||||
| }, | |||||
| patch: { | |||||
| tags: ["User"], | |||||
| description: "Update user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| // schema: { | |||||
| // $ref: "#/components/schemas/id", // data model of the param | |||||
| // }, | |||||
| required: true, | |||||
| description: "A single user id", | |||||
| } | |||||
| ], | |||||
| requestBody: { | |||||
| content: { | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| } | |||||
| }, | |||||
| delete: { | |||||
| tags: ["User"], | |||||
| description: "Delete user", | |||||
| parameters: [ | |||||
| { | |||||
| name: "id", | |||||
| in: "path", | |||||
| schema: { | |||||
| $ref: "#/components/schemas/id", | |||||
| }, | |||||
| required: true, | |||||
| }, | |||||
| ], | |||||
| responses: { | |||||
| 204: { | |||||
| description: "User deleted successfully", | |||||
| }, | |||||
| 400: { | |||||
| description: "You need to provide valid Id'", | |||||
| }, | |||||
| 404: { | |||||
| description: "User not found", | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error", | |||||
| }, | |||||
| }, | |||||
| } | |||||
| }, | |||||
| '/auth/token': { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log in user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| type: "object", | |||||
| properties: { | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User logged in successfully!" | |||||
| }, | |||||
| 400: { | |||||
| description: "Wrong credentials!" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| '/auth/logout': { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log out user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/Token" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User logged out successfully" | |||||
| }, | |||||
| 404: { | |||||
| description: "No user has the token provided!" | |||||
| }, | |||||
| 500: { | |||||
| description: "Internal server error" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| '/auth/refresh': { | |||||
| post: { | |||||
| tags: ["Token"], | |||||
| description: "Log out user", | |||||
| parameters: [], | |||||
| requestBody: { | |||||
| content: { | |||||
| "application/json": { | |||||
| schema: { | |||||
| $ref: "#/components/schemas/Token" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| responses: { | |||||
| 201: { | |||||
| description: "User refreshed successfully" | |||||
| }, | |||||
| 404: { | |||||
| description: "Token not valid!" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| components: { | |||||
| schemas: { | |||||
| id: { | |||||
| type: "string", | |||||
| description: "An id of a user" | |||||
| }, | |||||
| User: { | |||||
| type: "object", | |||||
| properties: { | |||||
| name: { | |||||
| type: "string" | |||||
| }, | |||||
| email: { | |||||
| type: "string" | |||||
| }, | |||||
| password: { | |||||
| type: "string" | |||||
| }, | |||||
| tokens: { | |||||
| type: "array", | |||||
| items: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| }, | |||||
| Token: { | |||||
| type: "object", | |||||
| properties: { | |||||
| token: { | |||||
| type: "string" | |||||
| }, | |||||
| userId: { | |||||
| type: "string" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } |