swagger documentation for Api
This commit is contained in:
2104
package-lock.json
generated
Normal file
2104
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,18 +14,23 @@
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.4.5",
|
||||
"dotenv": "^16.4.7",
|
||||
"express": "^4.21.1",
|
||||
"http": "^0.0.1-security",
|
||||
"ip": "^2.0.1",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mongoose": "^8.8.1",
|
||||
"socket.io": "^4.8.1"
|
||||
"socket.io": "^4.8.1",
|
||||
"swagger-autogen": "^2.23.7",
|
||||
"swagger-ui-express": "^5.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/ip": "^1.1.3",
|
||||
"@types/jsonwebtoken": "^9.0.7",
|
||||
"@types/node": "^22.9.0",
|
||||
"@types/swagger-ui-express": "^4.1.7",
|
||||
"nodemon": "^3.1.7",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3"
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import app from './app';
|
||||
import http from 'http';
|
||||
import ip from 'ip';
|
||||
// import { startHealthCheck } from './controller/user-Controller';
|
||||
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
const server = http.createServer(app);
|
||||
|
||||
|
||||
|
||||
let swaggerDocument;
|
||||
try {
|
||||
swaggerDocument = require('../../swagger-output.json');
|
||||
} catch (error) {
|
||||
console.error('Error loading Swagger JSON:', error);
|
||||
swaggerDocument = {}; // Fallback: empty object or some default
|
||||
}
|
||||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic
|
||||
|
||||
if (!organization) {
|
||||
@@ -14,6 +21,8 @@ if (!organization) {
|
||||
|
||||
const PORT = process.env.API_PORT
|
||||
server.listen(PORT, () => {
|
||||
console.log(`API-Server running on port ${PORT}`);
|
||||
// startHealthCheck(server, organization);
|
||||
console.log(`API-Server running on http://localhost:${PORT}`);
|
||||
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
|
||||
// console.log(`Server is also accessible on IP address: ${ip.address()}`);
|
||||
|
||||
});
|
||||
|
||||
46
src/shared/swagger/swagger.ts
Normal file
46
src/shared/swagger/swagger.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
const swaggerAutogen = require('swagger-autogen')
|
||||
|
||||
const dotenv = require('dotenv')
|
||||
const path = require("path");
|
||||
|
||||
const envPath = path.resolve(__dirname, "../../../.env");
|
||||
|
||||
|
||||
dotenv.config({ path: envPath });
|
||||
const ip = require('ip')
|
||||
const PORT = process.env.API_PORT;
|
||||
|
||||
const doc = {
|
||||
info: {
|
||||
title: 'dwinzo documetion',
|
||||
description: 'Description'
|
||||
},
|
||||
host: '185.100.212.76:5000',
|
||||
basePath: '/api/v1',
|
||||
schemes: ['http'],
|
||||
|
||||
};
|
||||
|
||||
const outputFile = './../../../swagger-output.json';
|
||||
const routes = [
|
||||
'./../../api-server/Routes/user-Routes.ts',
|
||||
'./../../api-server/Routes/camera-Routes.ts',
|
||||
'./../../api-server/Routes/environments-Routes.ts',
|
||||
'./../../api-server/Routes/flooritem-Routes.ts',
|
||||
'./../../api-server/Routes/lines-Routes.ts',
|
||||
'./../../api-server/Routes/share-Routes.ts',
|
||||
'./../../api-server/Routes/wallItems-Routes.ts',
|
||||
];
|
||||
|
||||
/* NOTE: If you are using the express Router, you must pass in the 'routes' only the
|
||||
root file where the route starts, such as index.js, app.js, routes.js, etc ... */
|
||||
|
||||
swaggerAutogen()(outputFile, routes, doc).then(() => {
|
||||
console.log('Swagger documentation generated!');
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import express from "express"
|
||||
import { Response, Request } from "express";
|
||||
import http from "http";
|
||||
import ip from 'ip';
|
||||
import dotenv from "dotenv"; // Import dotenv
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -38,7 +38,7 @@ export const activeUsers = async (data: any) => {
|
||||
|
||||
}
|
||||
}else {
|
||||
console.error('Invalid data or missing email:', data);
|
||||
// console.error('Invalid data or missing email:', data);
|
||||
// Handle the error or return a default value
|
||||
// Example: Return an error response if the email is invalid
|
||||
|
||||
|
||||
728
swagger-output.json
Normal file
728
swagger-output.json
Normal file
@@ -0,0 +1,728 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "dwinzo documetion",
|
||||
"description": "Description",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"host": "185.100.212.76:5000",
|
||||
"basePath": "/api/v1",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
"/signup": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userName": {
|
||||
"example": "any"
|
||||
},
|
||||
"email": {
|
||||
"example": "any"
|
||||
},
|
||||
"password": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"profilePicture": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"example": "any"
|
||||
},
|
||||
"password": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setCamera": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
"example": "any"
|
||||
},
|
||||
"target": {
|
||||
"example": "any"
|
||||
},
|
||||
"rotation": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/getCamera/{organization}/{userId}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/activeCameras/{organization}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setEvironments": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"example": "any"
|
||||
},
|
||||
"roofVisibility": {
|
||||
"example": "any"
|
||||
},
|
||||
"wallVisibility": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findEnvironments/{organization}/{userId}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setfloorItems": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelfileID": {
|
||||
"example": "any"
|
||||
},
|
||||
"rotation": {
|
||||
"example": "any"
|
||||
},
|
||||
"isLocked": {
|
||||
"example": "any"
|
||||
},
|
||||
"isVisible": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findfloorItems/{organization}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deletefloorItem": {
|
||||
"delete": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setLine": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"layer": {
|
||||
"example": "any"
|
||||
},
|
||||
"line": {
|
||||
"example": "any"
|
||||
},
|
||||
"type": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/updatePoint": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"uuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findLines/{organization}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteLine": {
|
||||
"delete": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"layer": {
|
||||
"example": "any"
|
||||
},
|
||||
"line": {
|
||||
"example": "any"
|
||||
},
|
||||
"type": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deletePoint": {
|
||||
"delete": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"layer": {
|
||||
"example": "any"
|
||||
},
|
||||
"uuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"type": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteLayer": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"example": "any"
|
||||
},
|
||||
"layer": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/shareUser": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"example": "any"
|
||||
},
|
||||
"isShare": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findshareUsers": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "query",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setWallItems": {
|
||||
"post": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
"example": "any"
|
||||
},
|
||||
"type": {
|
||||
"example": "any"
|
||||
},
|
||||
"csgposition": {
|
||||
"example": "any"
|
||||
},
|
||||
"csgscale": {
|
||||
"example": "any"
|
||||
},
|
||||
"quaternion": {
|
||||
"example": "any"
|
||||
},
|
||||
"scale": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findWallItems/{organization}": {
|
||||
"get": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "organization",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteWallItem": {
|
||||
"delete": {
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
"example": "any"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user