diff --git a/README.md b/README.md index 973bdefd7..084b1d87b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Please make sure you have the right versions and download both packages. You can node --version # Check Mongo version -mongo --version +mongo --version OR db.version() after launching mongo.exe in prompt cmd ``` ### Instructions diff --git a/server/server.js b/server/server.js index 3d28f7e99..2528494ee 100644 --- a/server/server.js +++ b/server/server.js @@ -4,6 +4,7 @@ const cors = require('cors') const swaggerUi = require('swagger-ui-express') const yaml = require('yamljs') const swaggerDocs = yaml.load('./swagger.yaml') +const swaggerDocs2 = yaml.load('./swagger2.yaml') const dbConnection = require('./database/connection') dotEnv.config() @@ -27,6 +28,7 @@ app.use('/api/v1/user', require('./routes/userRoutes')) // API Documentation if (process.env.NODE_ENV !== 'production') { app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs)) + app.use('/api-docs2', swaggerUi.serve, swaggerUi.setup(swaggerDocs2)) } app.get('/', (req, res, next) => { diff --git a/swagger2.yaml b/swagger2.yaml new file mode 100644 index 000000000..061cf5f5b --- /dev/null +++ b/swagger2.yaml @@ -0,0 +1,421 @@ +swagger: "2.0" +info: + title: Bank Argent API documentation (phase 2) + description: Contains all available API endpoints in this codebase + version: '1.0.0' + termsOfService: 'http://swagger.io/terms/' +host: localhost:3001 +basePath: /api/v1 +schemes: + - http +paths: + /user/login: + post: + tags: + - User Module + summary: Login + description: API for Login + parameters: + - in: body + name: body + description: Login Payload + required: true + schema: + $ref: "#/definitions/Login" + produces: + - application/json + responses: + "200": + description: Login Successfully + schema: + $ref: "#/definitions/LoginResponse" + "400": + description: Invalid Fields + "500": + description: Internal Server Error + /user/signup: + post: + tags: + - User Module + summary: Signup + description: API for Signup + parameters: + - in: body + name: body + description: Signup Payload + required: true + schema: + $ref: "#/definitions/User" + produces: + - application/json + responses: + "200": + description: Signup Successfully + schema: + $ref: "#/definitions/ApiResponse" + "400": + description: Invalid Fields + "500": + description: Internal Server Error + /user/profile: + post: + security: + - Bearer: [] + tags: + - User Module + summary: User Profile API + description: API for fetching a user profile + parameters: + - in: header + type: string + name: Authorization + description: Attach Bearer JWT token + required: true + produces: + - application/json + responses: + "200": + description: User profile retrieved successully + schema: + $ref: "#/definitions/ApiResponse" + "400": + description: Invalid Fields + "500": + description: Internal Server Error + put: + security: + - Bearer: [] + tags: + - User Module + summary: User Profile API + description: API for updating a user profile + parameters: + - in: header + type: string + name: Authorization + description: Attach Bearer JWT token + required: true + - in: body + name: body + description: Update user profile attributes + required: true + schema: + $ref: "#/definitions/UserProfile" + produces: + - application/json + responses: + "200": + description: User profile retrieved successully + schema: + $ref: "#/definitions/ApiResponse" + "400": + description: Invalid Fields + "500": + description: Internal Server Error + /user/{userId}/transactions: + get: + security: + - Bearer: [] + tags: + - Transaction Module + summary: Get Transaction API + description: API for fetching transactions of the month + parameters: + - in: header + name: Authorization + description: Attach Bearer JWT token + required: true + - in: path + name: userId + type: string + description: Attach user ID to URL + required: true + - in: query + name: month + type: string + description: Name of the month when the transaction has been created + required: false + produces: + - application/json + responses: + '200': + description: Transactions fetched successully + schema: + $ref: '#/definitions/TransactionAllResponse' + '400': + description: Invalid Fields + '500': + description: Internal Server Error + post: + security: + - Bearer: [] + tags: + - Transaction Module + summary: Create Transaction API + description: API for creating specific transaction details + parameters: + - in: header + name: Authorization + type: string + description: Attach Bearer JWT token + required: true + - in: path + name: userId + type: string + description: Attach user ID to URL + required: true + - in: + name: body + description: Create transaction + required: true + schema: + $ref: "#/definitions/TransactionBody" + produces: + - application/json + responses: + '200': + description: Transactions created successully + schema: + $ref: '#/definitions/TransactionAllResponse' + '400': + description: Invalid Fields + '500': + description: Internal Server Error + /user/{userId}/transactions/{transactionId}: + put: + security: + - Bearer: [] + tags: + - Transaction Module + summary: Update Transaction API + description: API for updating a specific transaction detail + parameters: + - in: header + type: string + name: Authorization + description: Attach Bearer JWT token + required: true + - in: path + name: userId + type: string + description: Attach user ID to URL + required: true + - in: path + name: transactionId + type: string + description: Attach transaction ID to URL + required: true + - in: body + name: body + description: Update user profile attributes + required: true + schema: + $ref: '#/definitions/Transactions' + produces: + - application/json + responses: + '200': + description: Transactions details updated successully + schema: + $ref: '#/definitions/TransactionAllResponse' + '400': + description: Invalid Fields + '500': + description: Internal Server Error + delete: + security: + - Bearer: [] + tags: + - Transaction Module + summary: Delete Transaction API + description: API for deleting a specific transaction detail + parameters: + - in: header + type: string + name: Authorization + description: Attach Bearer JWT token + required: true + - in: path + name: userId + type: string + description: Attach user ID to URL + required: true + - in: path + name: transactionId + type: string + description: Attach transaction ID to URL + required: true + produces: + - application/json + responses: + '200': + description: Transactions details deleted successully + schema: + $ref: '#/definitions/TransactionAllResponse' + '400': + description: Invalid Fields + '500': + description: Internal Server Error +securityDefinitions: + Bearer: + type: apiKey + name: Authorization + in: header +definitions: + User: + properties: + email: + type: string + description: user email + password: + type: string + description: user password + firstName: + type: string + description: user first name + lastName: + type: string + description: user last name + Login: + properties: + email: + type: string + description: user email + password: + type: string + description: user password + ApiResponse: + type: object + properties: + status: + type: integer + message: + type: string + body: + type: object + properties: + id: + type: string + email: + type: string + LoginResponse: + type: object + properties: + token: + type: string + UserProfile: + type: object + properties: + firstName: + type: string + lastName: + type: string + Transaction: + properties: + type: + type: string + description: transaction's type + category: + type: string + description: transaction's category + notes: + type: string + description: transaction's notes + TransactionAllResponse: + type: object + properties: + status: + type: integer + message: + type: string + body: + type: array + items: + type: object + properties: + id: + type: string + description: unique id + date: + type: string + description: transaction's date + description: + type: string + description: transaction's description + amount: + type: number + description: transaction's amount + balance: + type: number + description: balance amount + TransactionResponse: + type: object + properties: + status: + type: integer + message: + type: string + body: + type: object + properties: + items: + type: string + category: + type: string + notes: + type: string + TransactionBody: + type: object + properties: + id: + type: string + date: + type: string + description: + type: string + amount: + type: number + balance: + type: number + type: + type: string + category: + type: string + notes: + type: string + TransactionUpdateResponse: + type: object + properties: + status: + type: integer + message: + type: string + body: + type: array + items: + type: object + properties: + id: + type: string + description: unique id + date: + type: string + description: transaction's date + description: + type: string + description: transaction's description + amount: + type: number + description: transaction's amount + balance: + type: number + description: balance amount + type: + type: string + description: Transaction's type + category: + type: string + description: Transaction's category + notes: + type: string + description: Transaction's notes \ No newline at end of file