swagger documentation for Api

This commit is contained in:
2025-01-30 12:44:04 +05:30
parent 5984f445f7
commit 465f713624
45 changed files with 5201 additions and 2308 deletions

6
.env
View File

@@ -1,4 +1,4 @@
# MONGO_URI=mongodb://127.0.0.1:27017/ # MONGO_URI=mongodb://127.0.0.1:27017/
MONGO_URI=mongodb://mongo/ MONGO_URI=mongodb://mongo/
API_PORT=5000 API_PORT=5000
SOCKET_PORT=8000 SOCKET_PORT=8000

26
.vscode/settings.json vendored
View File

@@ -1,14 +1,14 @@
{ {
"files.exclude": { "files.exclude": {
"**/.git": true, "**/.git": true,
"**/.svn": true, "**/.svn": true,
"**/.hg": true, "**/.hg": true,
"**/CVS": true, "**/CVS": true,
"**/.DS_Store": true, "**/.DS_Store": true,
"**/Thumbs.db": true, "**/Thumbs.db": true,
"**/.retool_types/**": true, "**/.retool_types/**": true,
"**/*tsconfig.json": true, "**/*tsconfig.json": true,
".cache": true, ".cache": true,
"retool.config.json": true "retool.config.json": true
} }
} }

View File

@@ -1,50 +1,50 @@
services: services:
api-server: api-server:
build: # Assuming Dockerfile for API is in the root directory build: # Assuming Dockerfile for API is in the root directory
context: ./ # Root directory context context: ./ # Root directory context
dockerfile: src/api-server/Dockerfile dockerfile: src/api-server/Dockerfile
container_name: DwinzoApi_end container_name: DwinzoApi_end
environment: environment:
NODE_ENV: development NODE_ENV: development
ports: ports:
- "5000:5000" # Host port 5000 mapped to container's port 5000 - "5000:5000" # Host port 5000 mapped to container's port 5000
expose: expose:
- 5000 - 5000
depends_on: depends_on:
- mongo - mongo
networks: networks:
- DwinzoMajor - DwinzoMajor
socket-server: socket-server:
build: # Assuming Dockerfile for Socket server is in the root directory build: # Assuming Dockerfile for Socket server is in the root directory
context: ./ # Root directory context context: ./ # Root directory context
dockerfile: src/socket-server/Dockerfile dockerfile: src/socket-server/Dockerfile
container_name: DwinzoSocket_end container_name: DwinzoSocket_end
environment: environment:
NODE_ENV: development NODE_ENV: development
ports: ports:
- "8000:8000" # Changed host port to avoid conflict with API server - "8000:8000" # Changed host port to avoid conflict with API server
expose: expose:
- 8000 - 8000
depends_on: depends_on:
- mongo - mongo
networks: networks:
- DwinzoMajor # Socket server on the same network as the API server - DwinzoMajor # Socket server on the same network as the API server
mongo: mongo:
image: mongo:latest image: mongo:latest
container_name: mongo-Dwinzocontainer container_name: mongo-Dwinzocontainer
ports: ports:
- "27017:27017" - "27017:27017"
volumes: volumes:
- mongo-data:/data/db - mongo-data:/data/db
networks: networks:
- DwinzoMajor # Mongo is now on the same network - DwinzoMajor # Mongo is now on the same network
volumes: volumes:
mongo-data: # Persistent volume for MongoDB data mongo-data: # Persistent volume for MongoDB data
networks: networks:
DwinzoMajor: DwinzoMajor:
driver: bridge driver: bridge

2104
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +1,38 @@
{ {
"name": "dwinzo_major", "name": "dwinzo_major",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start:api": "nodemon --exec ts-node src/api-server/main.ts", "start:api": "nodemon --exec ts-node src/api-server/main.ts",
"start:socket": "nodemon --exec ts-node src/socket-server/index.ts" "start:socket": "nodemon --exec ts-node src/socket-server/index.ts"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.4.5", "dotenv": "^16.4.7",
"express": "^4.21.1", "express": "^4.21.1",
"http": "^0.0.1-security", "http": "^0.0.1-security",
"jsonwebtoken": "^9.0.2", "ip": "^2.0.1",
"mongoose": "^8.8.1", "jsonwebtoken": "^9.0.2",
"socket.io": "^4.8.1" "mongoose": "^8.8.1",
}, "socket.io": "^4.8.1",
"devDependencies": { "swagger-autogen": "^2.23.7",
"@types/cors": "^2.8.17", "swagger-ui-express": "^5.0.1"
"@types/express": "^5.0.0", },
"@types/jsonwebtoken": "^9.0.7", "devDependencies": {
"@types/node": "^22.9.0", "@types/cors": "^2.8.17",
"nodemon": "^3.1.7", "@types/express": "^5.0.0",
"ts-node": "^10.9.2", "@types/ip": "^1.1.3",
"typescript": "^5.6.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"
}
}

View File

@@ -1,50 +1,50 @@
let url_Backend_dwinzoMajor = "http://192.168.0.110:3503"; let url_Backend_dwinzoMajor = "http://192.168.0.110:3503";
//Login Api //Login Api
export const createCamera = async (userId:string, position:Object) => { export const createCamera = async (userId:string, position:Object) => {
try { try {
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/createCamera`, { const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/createCamera`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({ userId, position }), body: JSON.stringify({ userId, position }),
}); });
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to create Camera"); throw new Error("Failed to create Camera");
} }
const result = await response.json(); const result = await response.json();
return result; return result;
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error` throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
} else { } else {
throw new Error("An unknown error occurred"); throw new Error("An unknown error occurred");
} }
} }
}; };
export const getCamera = async (userId:string) => { export const getCamera = async (userId:string) => {
try { try {
const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`, { const response = await fetch(`${url_Backend_dwinzoMajor}/api/v1/getCamera/${userId}`, {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to get Camera"); throw new Error("Failed to get Camera");
} }
const result = await response.json(); const result = await response.json();
return result; return result;
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error` throw new Error(error.message); // Now TypeScript knows `error` is an instance of `Error`
} else { } else {
throw new Error("An unknown error occurred"); throw new Error("An unknown error occurred");
} }
} }
}; };

View File

@@ -1,35 +1,35 @@
ARG NODE_VERSION=lts ARG NODE_VERSION=lts
FROM node:${NODE_VERSION}-alpine AS development FROM node:${NODE_VERSION}-alpine AS development
# Use production node environment by default. # Use production node environment by default.
ENV NODE_ENV development ENV NODE_ENV development
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN npm install -g npm RUN npm install -g npm
COPY package.json /usr/src/app/package.json COPY package.json /usr/src/app/package.json
# COPY package-lock.json /usr/src/app/package-lock.json # COPY package-lock.json /usr/src/app/package-lock.json
RUN npm install RUN npm install
# Run the application as a non-root user. # Run the application as a non-root user.
USER root USER root
# Copy the rest of the source files into the image. # Copy the rest of the source files into the image.
COPY . . COPY . .
# Expose the port that the application listens on. # Expose the port that the application listens on.
EXPOSE 3503 EXPOSE 3503
# Run the application. # Run the application.
CMD ["npm", "run", "start:api"] CMD ["npm", "run", "start:api"]

View File

@@ -1,11 +1,11 @@
import express from 'express'; import express from 'express';
import { camera } from '../controller/camera/camera-Controlle'; import { camera } from '../controller/camera/camera-Controlle';
const router = express.Router(); const router = express.Router();
router.post('/setCamera',camera.createCamera) router.post('/setCamera',camera.createCamera)
router.get('/getCamera/:organization/:userId',camera.getCamera) router.get('/getCamera/:organization/:userId',camera.getCamera)
router.get('/activeCameras/:organization',camera.onlineActiveDatas) router.get('/activeCameras/:organization',camera.onlineActiveDatas)
export default router; export default router;

View File

@@ -1,9 +1,9 @@
import express from 'express'; import express from 'express';
import { environment } from '../controller/environments/environments-controller'; import { environment } from '../controller/environments/environments-controller';
const router = express.Router(); const router = express.Router();
router.post('/setEvironments',environment.setEnvironment) router.post('/setEvironments',environment.setEnvironment)
router.get('/findEnvironments/:organization/:userId',environment.getEnvironment) router.get('/findEnvironments/:organization/:userId',environment.getEnvironment)
export default router; export default router;

View File

@@ -1,10 +1,10 @@
import express from 'express'; import express from 'express';
import { floorItems } from '../controller/assets/flooritem-Controller'; import { floorItems } from '../controller/assets/flooritem-Controller';
const router = express.Router(); const router = express.Router();
router.post('/setfloorItems',floorItems.setFloorItems) router.post('/setfloorItems',floorItems.setFloorItems)
router.get('/findfloorItems/:organization',floorItems.getFloorItems) router.get('/findfloorItems/:organization',floorItems.getFloorItems)
router.delete('/deletefloorItem',floorItems.deleteFloorItems) router.delete('/deletefloorItem',floorItems.deleteFloorItems)
export default router; export default router;

View File

@@ -1,14 +1,14 @@
import express from 'express'; import express from 'express';
import { lines } from '../controller/lines/line-Controller'; import { lines } from '../controller/lines/line-Controller';
const router = express.Router(); const router = express.Router();
router.post('/setLine',lines.setLines) router.post('/setLine',lines.setLines)
router.post('/updatePoint',lines.updateLines) router.post('/updatePoint',lines.updateLines)
router.get('/findLines/:organization',lines.getLines) router.get('/findLines/:organization',lines.getLines)
router.delete('/deleteLine',lines.deleteLineItems) router.delete('/deleteLine',lines.deleteLineItems)
router.delete('/deletePoint',lines.deleteLinPoiteItems) router.delete('/deletePoint',lines.deleteLinPoiteItems)
router.post('/deleteLayer',lines.deleteLayer) router.post('/deleteLayer',lines.deleteLayer)
export default router; export default router;

View File

@@ -1,11 +1,11 @@
import express from 'express'; import express from 'express';
import { share } from '../controller/share/share-Controller'; import { share } from '../controller/share/share-Controller';
const router = express.Router(); const router = express.Router();
router.post('/shareUser',share.shareUser) router.post('/shareUser',share.shareUser)
router.get('/findshareUsers',share.findshareUser) router.get('/findshareUsers',share.findshareUser)
export default router; export default router;

View File

@@ -1,10 +1,10 @@
import express from 'express'; import express from 'express';
import { user } from '../controller/user-Controller'; import { user } from '../controller/user-Controller';
const router = express.Router(); const router = express.Router();
router.post('/signup',user.signup) router.post('/signup',user.signup)
router.post('/login',user.login) router.post('/login',user.login)
export default router; export default router;

View File

@@ -1,11 +1,11 @@
import express from 'express'; import express from 'express';
import { wallItems } from '../controller/assets/wallitem-Controller'; import { wallItems } from '../controller/assets/wallitem-Controller';
const router = express.Router(); const router = express.Router();
router.post('/setWallItems',wallItems.setWallItems) router.post('/setWallItems',wallItems.setWallItems)
router.get('/findWallItems/:organization',wallItems.getWallItems) router.get('/findWallItems/:organization',wallItems.getWallItems)
router.delete('/deleteWallItem',wallItems.deleteWallItems) router.delete('/deleteWallItem',wallItems.deleteWallItems)
export default router; export default router;

View File

@@ -1,31 +1,31 @@
import express from 'express'; import express from 'express';
import cors from 'cors'; import cors from 'cors';
import connectDB from '../shared/connect/mongoose'; import connectDB from '../shared/connect/mongoose';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
import cameraRoutes from './Routes/camera-Routes' import cameraRoutes from './Routes/camera-Routes'
import environmentsRoutes from './Routes/environments-Routes' import environmentsRoutes from './Routes/environments-Routes'
import linesRoutes from './Routes/lines-Routes' import linesRoutes from './Routes/lines-Routes'
import flooritemRoutes from './Routes/flooritem-Routes' import flooritemRoutes from './Routes/flooritem-Routes'
import WallitemRoutes from './Routes/wallItems-Routes' import WallitemRoutes from './Routes/wallItems-Routes'
import userRoutes from './Routes/user-Routes' import userRoutes from './Routes/user-Routes'
import shareRoutes from './Routes/share-Routes' import shareRoutes from './Routes/share-Routes'
const app = express(); const app = express();
app.use(cors()); app.use(cors());
app.use(express.json()); app.use(express.json());
dotenv.config(); dotenv.config();
app.get('/', (req, res) => { app.get('/', (req, res) => {
res.send('Hello, I am Major-Dwinzo API!'); res.send('Hello, I am Major-Dwinzo API!');
}); });
// connectDB(); // connectDB();
app.get('/health',(req,res)=>{ app.get('/health',(req,res)=>{
res.status(200).json({ message: 'Server is running' }); res.status(200).json({ message: 'Server is running' });
}) })
app.use('/api/v1', cameraRoutes); app.use('/api/v1', cameraRoutes);
app.use('/api/v1', environmentsRoutes); app.use('/api/v1', environmentsRoutes);
app.use('/api/v1', linesRoutes); app.use('/api/v1', linesRoutes);
app.use('/api/v1', flooritemRoutes); app.use('/api/v1', flooritemRoutes);
app.use('/api/v1', WallitemRoutes); app.use('/api/v1', WallitemRoutes);
app.use('/api/v1', userRoutes); app.use('/api/v1', userRoutes);
app.use('/api/v1', shareRoutes); app.use('/api/v1', shareRoutes);
export default app; export default app;

View File

@@ -1,68 +1,68 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model"; import floorItemsModel from "../../../shared/model/assets/flooritems-Model";
export class floorItems { export class floorItems {
static async setFloorItems(req: Request, res: Response) { static async setFloorItems(req: Request, res: Response) {
try { try {
const { modeluuid, modelname, position, modelfileID,rotation,isLocked,isVisible,organization } = req.body const { modeluuid, modelname, position, modelfileID,rotation,isLocked,isVisible,organization } = req.body
const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid,modelname:modelname }) const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid,modelname:modelname })
if (findvalue) { if (findvalue) {
const updatevalue = await floorItemsModel(organization).findOneAndUpdate( const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid,modelname:modelname }, { position: position, rotation: rotation,isVisible:isVisible,isLocked:isLocked }, { new: true }); { modeluuid: modeluuid,modelname:modelname }, { position: position, rotation: rotation,isVisible:isVisible,isLocked:isLocked }, { new: true });
res.status(201).json(updatevalue); res.status(201).json(updatevalue);
} else { } else {
const newValue = await floorItemsModel(organization).create({ modeluuid, modelfileID,modelname, position, rotation,isLocked,isVisible, }); const newValue = await floorItemsModel(organization).create({ modeluuid, modelfileID,modelname, position, rotation,isLocked,isVisible, });
res.status(201).json(newValue); res.status(201).json(newValue);
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating flooritems:', error); console.error('Error creating flooritems:', error);
res.status(500).json({ message: "Failed to create flooritems" }); res.status(500).json({ message: "Failed to create flooritems" });
} }
} }
static async getFloorItems(req: Request, res: Response) { static async getFloorItems(req: Request, res: Response) {
try { try {
const { organization } = req.params; const { organization } = req.params;
// console.log('req.params: ', req.params); // console.log('req.params: ', req.params);
const findValue = await floorItemsModel(organization).find() const findValue = await floorItemsModel(organization).find()
if (!findValue) { if (!findValue) {
res.status(200).json("floorItems not found"); res.status(200).json("floorItems not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get flooritems:', error); console.error('Error get flooritems:', error);
res.status(500).json({ error: "Failed to get flooritems" }); res.status(500).json({ error: "Failed to get flooritems" });
} }
} }
static async deleteFloorItems(req: Request, res: Response) { static async deleteFloorItems(req: Request, res: Response) {
try { try {
const { modeluuid,modelname,organization } = req.body; const { modeluuid,modelname,organization } = req.body;
const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname}) const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
if (!findValue) { if (!findValue) {
res.status(200).json("user not found"); res.status(200).json("user not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get flooritems:', error); console.error('Error get flooritems:', error);
res.status(500).json({ error: "Failed to get flooritems" }); res.status(500).json({ error: "Failed to get flooritems" });
} }
} }
} }

View File

@@ -1,80 +1,80 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model"; import wallItenmModel from "../../../shared/model/assets/wallitems-Model";
export class wallItems { export class wallItems {
static async setWallItems(req: Request, res: Response) { static async setWallItems(req: Request, res: Response) {
try { try {
const { modeluuid, modelname, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body const { modeluuid, modelname, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body
const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid}) const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid})
if (findvalue) { if (findvalue) {
const updatevalue = await wallItenmModel(organization).findOneAndUpdate( const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid }, { modeluuid: modeluuid },
{ {
modelname, modelname,
position, position,
type, type,
csgposition, csgposition,
csgscale, csgscale,
quaternion, quaternion,
scale, scale,
}, },
{ new: true } // Return the updated document { new: true } // Return the updated document
); );
res.status(201).json(updatevalue); res.status(201).json(updatevalue);
} else { } else {
const newValue = await wallItenmModel(organization).create({ modeluuid,modelname, position, type, csgposition,csgscale,quaternion,scale }); const newValue = await wallItenmModel(organization).create({ modeluuid,modelname, position, type, csgposition,csgscale,quaternion,scale });
res.status(201).json(newValue); res.status(201).json(newValue);
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating wallitems:', error); console.error('Error creating wallitems:', error);
res.status(500).json({ message: "Failed to create wallitems" }); res.status(500).json({ message: "Failed to create wallitems" });
} }
} }
static async getWallItems(req: Request, res: Response) { static async getWallItems(req: Request, res: Response) {
try { try {
const { organization } = req.params; const { organization } = req.params;
const findValue = await wallItenmModel const findValue = await wallItenmModel
(organization).find() (organization).find()
if (!findValue) { if (!findValue) {
res.status(200).json("wallitems not found"); res.status(200).json("wallitems not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get wallitems:', error); console.error('Error get wallitems:', error);
res.status(500).json({ error: "Failed to get wallitems" }); res.status(500).json({ error: "Failed to get wallitems" });
} }
} }
static async deleteWallItems(req: Request, res: Response) { static async deleteWallItems(req: Request, res: Response) {
try { try {
const { modeluuid,modelname,organization } = req.body; const { modeluuid,modelname,organization } = req.body;
const findValue = await wallItenmModel const findValue = await wallItenmModel
(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname}) (organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
if (!findValue) { if (!findValue) {
res.status(200).json("user not found"); res.status(200).json("user not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get wallitems:', error); console.error('Error get wallitems:', error);
res.status(500).json({ error: "Failed to get wallitems" }); res.status(500).json({ error: "Failed to get wallitems" });
} }
} }
} }

View File

@@ -1,89 +1,89 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import cameraModel from "../../../shared/model/camera/camera-Model"; import cameraModel from "../../../shared/model/camera/camera-Model";
import userModel from "../../../shared/model/user-Model"; import userModel from "../../../shared/model/user-Model";
export class camera { export class camera {
static async createCamera(req: Request, res: Response) { static async createCamera(req: Request, res: Response) {
try { try {
const { userId, position, target, rotation,organization } = req.body const { userId, position, target, rotation,organization } = req.body
const findCamera = await cameraModel(organization).findOne({ userId: userId }) const findCamera = await cameraModel(organization).findOne({ userId: userId })
if (findCamera) { if (findCamera) {
const updateCamera = await cameraModel(organization).findOneAndUpdate( const updateCamera = await cameraModel(organization).findOneAndUpdate(
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true }); { userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
res.status(201).json(updateCamera); res.status(201).json(updateCamera);
} else { } else {
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation }); const newCamera = await cameraModel(organization).create({ userId, position, target,rotation });
res.status(201).json(newCamera); res.status(201).json(newCamera);
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating camera:', error); console.error('Error creating camera:', error);
res.status(500).json({message:"Failed to create camera"}); res.status(500).json({message:"Failed to create camera"});
} }
} }
static async getCamera(req: Request, res: Response) { static async getCamera(req: Request, res: Response) {
try { try {
const { userId, organization } = req.params; const { userId, organization } = req.params;
// if (!userId) { // if (!userId) {
// res.status(201).json("User data is insufficient"); // res.status(201).json("User data is insufficient");
// } // }
const findCamera = await cameraModel(organization).findOne({ userId: userId }) const findCamera = await cameraModel(organization).findOne({ userId: userId })
if (!findCamera) { if (!findCamera) {
res.status(200).json("user not found"); res.status(200).json("user not found");
} else { } else {
res.status(201).json(findCamera); res.status(201).json(findCamera);
} }
} catch (error) { } catch (error) {
console.error('Error get camera:', error); console.error('Error get camera:', error);
res.status(500).json({ error: "Failed to get camera" }); res.status(500).json({ error: "Failed to get camera" });
} }
} }
static async onlineActiveDatas(req: Request, res: Response) { static async onlineActiveDatas(req: Request, res: Response) {
const {organization } = req.params; const {organization } = req.params;
try { try {
const findactiveUsers = await userModel(organization).find({activeStatus:"online"}) const findactiveUsers = await userModel(organization).find({activeStatus:"online"})
const cameraDataPromises = findactiveUsers.map(async (activeUser) => { const cameraDataPromises = findactiveUsers.map(async (activeUser) => {
const cameraData = await cameraModel(organization) const cameraData = await cameraModel(organization)
.findOne({ userId: activeUser._id }) .findOne({ userId: activeUser._id })
.select("position target rotation -_id"); .select("position target rotation -_id");
if (cameraData) { if (cameraData) {
return { return {
position: cameraData.position, position: cameraData.position,
target: cameraData.target, target: cameraData.target,
rotation:cameraData.rotation, rotation:cameraData.rotation,
userData: { userData: {
_id: activeUser._id, _id: activeUser._id,
userName: activeUser.userName, userName: activeUser.userName,
email: activeUser.email, email: activeUser.email,
activeStatus: activeUser.activeStatus, activeStatus: activeUser.activeStatus,
}, },
}; };
} }
// Return null if no camera data is found for the user // Return null if no camera data is found for the user
return null; return null;
}); });
const cameraDatas = (await Promise.all(cameraDataPromises)).filter((singledata:any) => singledata !== null); const cameraDatas = (await Promise.all(cameraDataPromises)).filter((singledata:any) => singledata !== null);
res.status(200).send({ cameraDatas }); res.status(200).send({ cameraDatas });
} catch (error:any) { } catch (error:any) {
res.status(500).send(error); res.status(500).send(error);
} }
} }
} }

View File

@@ -1,50 +1,50 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import environmentModel from "../../../shared/model/environments/environments-Model"; import environmentModel from "../../../shared/model/environments/environments-Model";
export class environment { export class environment {
static async setEnvironment(req: Request, res: Response) { static async setEnvironment(req: Request, res: Response) {
try { try {
const { userId,roofVisibility,wallVisibility, organization } = req.body const { userId,roofVisibility,wallVisibility, organization } = req.body
const findvalue = await environmentModel(organization).findOne({ userId: userId }) const findvalue = await environmentModel(organization).findOne({ userId: userId })
if (findvalue) { if (findvalue) {
const updatevalue = await environmentModel(organization).findOneAndUpdate( const updatevalue = await environmentModel(organization).findOneAndUpdate(
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility }, { new: true }); { userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility }, { new: true });
res.status(201).json(updatevalue); res.status(201).json(updatevalue);
} else { } else {
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility }); const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility });
res.status(201).json(newValue); res.status(201).json(newValue);
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating environments:', error); console.error('Error creating environments:', error);
res.status(500).json({message:"Failed to create environments"}); res.status(500).json({message:"Failed to create environments"});
} }
} }
static async getEnvironment(req: Request, res: Response) { static async getEnvironment(req: Request, res: Response) {
try { try {
const { userId, organization } = req.params; const { userId, organization } = req.params;
const findValue = await environmentModel(organization).findOne({ userId: userId }) const findValue = await environmentModel(organization).findOne({ userId: userId })
if (!findValue) { if (!findValue) {
res.status(200).json("user not found"); res.status(200).json("user not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get environments:', error); console.error('Error get environments:', error);
res.status(500).json({ error: "Failed to get environments" }); res.status(500).json({ error: "Failed to get environments" });
} }
} }
} }

View File

@@ -1,125 +1,125 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import lineModel from "../../../shared/model/lines/lines-Model"; import lineModel from "../../../shared/model/lines/lines-Model";
export class lines { export class lines {
static async setLines(req: Request, res: Response) { static async setLines(req: Request, res: Response) {
try { try {
const {organization,layer,line,type}=req.body const {organization,layer,line,type}=req.body
const newLine = await lineModel(organization).create({ layer,line,type }); const newLine = await lineModel(organization).create({ layer,line,type });
res.status(201).json(newLine); res.status(201).json(newLine);
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating Lines:', error); console.error('Error creating Lines:', error);
res.status(500).json({message:"Failed to create Lines"}); res.status(500).json({message:"Failed to create Lines"});
} }
} }
static async updateLines(req: Request, res: Response) { static async updateLines(req: Request, res: Response) {
try { try {
const {organization,uuid,position,}=req.body const {organization,uuid,position,}=req.body
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid }); // const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
// Update the position of the line matching the uuid // Update the position of the line matching the uuid
const updateResult = await lineModel(organization).updateMany( const updateResult = await lineModel(organization).updateMany(
{ 'line.uuid': uuid }, // Filter: Find the line with the given uuid { 'line.uuid': uuid }, // Filter: Find the line with the given uuid
{ $set: { 'line.$.position': position } } // Update the position and type { $set: { 'line.$.position': position } } // Update the position and type
); );
res.status(201).json(updateResult); res.status(201).json(updateResult);
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating Lines:', error); console.error('Error creating Lines:', error);
res.status(500).json({message:"Failed to create Lines"}); res.status(500).json({message:"Failed to create Lines"});
} }
} }
static async getLines(req: Request, res: Response) { static async getLines(req: Request, res: Response) {
try { try {
const { organization } = req.params; const { organization } = req.params;
const findValue = await lineModel(organization).find() const findValue = await lineModel(organization).find()
if (!findValue) { if (!findValue) {
res.status(200).json("user not found"); res.status(200).json("user not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error get Lines:', error); console.error('Error get Lines:', error);
res.status(500).json({ error: "Failed to get Lines" }); res.status(500).json({ error: "Failed to get Lines" });
} }
} }
static async deleteLineItems(req: Request, res: Response) { static async deleteLineItems(req: Request, res: Response) {
try { try {
const {organization,layer,line,type}=req.body const {organization,layer,line,type}=req.body
const inputUuids = line.map((item: any) => item.uuid); const inputUuids = line.map((item: any) => item.uuid);
// const findValue = await lineModel(organization).findOneAndDelete({ // const findValue = await lineModel(organization).findOneAndDelete({
// line: { $elemMatch: { uuid: { $in: inputUuids } } }, // line: { $elemMatch: { uuid: { $in: inputUuids } } },
// }); // });
const findValue = await lineModel(organization).findOneAndDelete({ const findValue = await lineModel(organization).findOneAndDelete({
"line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key "line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key
}); });
if (!findValue) { if (!findValue) {
res.status(200).json("data not found"); res.status(200).json("data not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error delete Lines:', error); console.error('Error delete Lines:', error);
res.status(500).json({ error: "Failed to delete Lines" }); res.status(500).json({ error: "Failed to delete Lines" });
} }
} }
static async deleteLinPoiteItems(req: Request, res: Response) { static async deleteLinPoiteItems(req: Request, res: Response) {
try { try {
const {organization,layer,uuid,type}=req.body const {organization,layer,uuid,type}=req.body
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid }) const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
if (!findValue) { if (!findValue) {
res.status(200).json("data not found"); res.status(200).json("data not found");
} else { } else {
res.status(201).json(findValue); res.status(201).json(findValue);
} }
} catch (error) { } catch (error) {
console.error('Error delete Lines:', error); console.error('Error delete Lines:', error);
res.status(500).json({ error: "Failed to delete Lines" }); res.status(500).json({ error: "Failed to delete Lines" });
} }
} }
static async deleteLayer(req: Request, res: Response) { static async deleteLayer(req: Request, res: Response) {
try { try {
const {organization,layer}=req.body const {organization,layer}=req.body
// Fetch the documents with the specified layer value // Fetch the documents with the specified layer value
const findValue = await lineModel(organization).find({ layer: layer }); const findValue = await lineModel(organization).find({ layer: layer });
if (!findValue) { if (!findValue) {
res.status(200).json("data not found"); res.status(200).json("data not found");
} else { } else {
await lineModel(organization).deleteMany({ layer: layer }); await lineModel(organization).deleteMany({ layer: layer });
// console.log(`Documents with layer ${layer} have been deleted.`); // console.log(`Documents with layer ${layer} have been deleted.`);
// Update documents with layer greater than -1 // Update documents with layer greater than -1
const updateResult = await lineModel(organization).updateMany( const updateResult = await lineModel(organization).updateMany(
{ layer: { $gt:layer} }, { layer: { $gt:layer} },
{ $inc: { layer: -1 } } // Example operation: decrementing layer by 1 { $inc: { layer: -1 } } // Example operation: decrementing layer by 1
); );
res.status(201).json(updateResult); res.status(201).json(updateResult);
} }
} catch (error) { } catch (error) {
console.error('Error delete Lines:', error); console.error('Error delete Lines:', error);
res.status(500).json({ error: "Failed to delete Lines" }); res.status(500).json({ error: "Failed to delete Lines" });
} }
} }
} }

View File

@@ -1,43 +1,43 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import userModel from "../../../shared/model/user-Model"; import userModel from "../../../shared/model/user-Model";
export class share { export class share {
static async shareUser(req: Request, res: Response) { static async shareUser(req: Request, res: Response) {
try { try {
const { email, isShare, organization } = req.body const { email, isShare, organization } = req.body
const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true}) const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true})
res.status(201).json({message:"scene shared successfully",data:findValue}); res.status(201).json({message:"scene shared successfully",data:findValue});
if (!findValue) { if (!findValue) {
res.status(404).json({message:"Not found"}) res.status(404).json({message:"Not found"})
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating Share:', error); console.error('Error creating Share:', error);
res.status(500).json({message:"Failed to create Share"}); res.status(500).json({message:"Failed to create Share"});
} }
} }
static async findshareUser(req: Request, res: Response) { static async findshareUser(req: Request, res: Response) {
try { try {
const organization = req.query.organization as string; const organization = req.query.organization as string;
const findValue = await userModel(organization).find({}).select("isShare email userName -_id") const findValue = await userModel(organization).find({}).select("isShare email userName -_id")
// console.log('findValue: ', findValue); // console.log('findValue: ', findValue);
res.status(201).json({message:"scene shared datas",data:findValue}); res.status(201).json({message:"scene shared datas",data:findValue});
if (!findValue) { if (!findValue) {
res.status(404).json({message:"Not found"}) res.status(404).json({message:"Not found"})
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error Share:', error); console.error('Error Share:', error);
res.status(500).json({message:"Failed to Share datas "}); res.status(500).json({message:"Failed to Share datas "});
} }
} }
} }

View File

@@ -1,103 +1,103 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import { Server } from 'http'; import { Server } from 'http';
import userModel from "../../shared/model/user-Model"; import userModel from "../../shared/model/user-Model";
import { isSharedArrayBuffer } from "util/types"; import { isSharedArrayBuffer } from "util/types";
const {hashGenerate,hashValidator} = require("../../shared/security/Hasing.ts") const {hashGenerate,hashValidator} = require("../../shared/security/Hasing.ts")
// import {hashGenerate} from '../security/Hasing' // import {hashGenerate} from '../security/Hasing'
let serverAlive = true; let serverAlive = true;
export class user { export class user {
static async signup(req: Request, res: Response) { static async signup(req: Request, res: Response) {
try { try {
let role; let role;
const { userName, email, password,organization,profilePicture } = req.body; const { userName, email, password,organization,profilePicture } = req.body;
const caseChange = email.toLowerCase(); const caseChange = email.toLowerCase();
const emailcheck = await userModel(organization).findOne({ email: caseChange }); const emailcheck = await userModel(organization).findOne({ email: caseChange });
if (emailcheck!==null) { if (emailcheck!==null) {
res.json({ res.json({
message:"User already exists" message:"User already exists"
}); });
} else { } else {
const hashpassword=await hashGenerate(password) const hashpassword=await hashGenerate(password)
const userCount = await userModel(organization).countDocuments({}); const userCount = await userModel(organization).countDocuments({});
role = userCount === 0 ? "Admin" : "User"; role = userCount === 0 ? "Admin" : "User";
const isShare = role === "Admin" ? "true" : "false"; const isShare = role === "Admin" ? "true" : "false";
const newuser = await userModel(organization).create({ const newuser = await userModel(organization).create({
userName: userName, userName: userName,
email: caseChange, email: caseChange,
isShare:isShare, isShare:isShare,
password: hashpassword, password: hashpassword,
role:role, role:role,
profilePicture:profilePicture profilePicture:profilePicture
}); });
newuser.save(); newuser.save();
res.status(200).json({ res.status(200).json({
message:"New User created" message:"New User created"
}); });
} }
} catch (error:any) { } catch (error:any) {
res.status(500).send(error); res.status(500).send(error);
} }
} }
static async login(req: Request, res: Response) { static async login(req: Request, res: Response) {
try { try {
let role; let role;
const { email, password,organization } = req.body; const { email, password,organization } = req.body;
// console.log(' req.body: ', req.body); // console.log(' req.body: ', req.body);
const existingMail = await userModel(organization).findOne({ const existingMail = await userModel(organization).findOne({
email:email email:email
}); });
if (existingMail === null || !existingMail) { if (existingMail === null || !existingMail) {
res.status(404).json({ message: "User Not Found!!! Kindly signup..." }); res.status(404).json({ message: "User Not Found!!! Kindly signup..." });
} else { } else {
const hashedpassword= existingMail.password const hashedpassword= existingMail.password
const checkpassword = await hashValidator( const checkpassword = await hashValidator(
password, password,
hashedpassword hashedpassword
) )
// console.log('checkpassword: ', checkpassword); // console.log('checkpassword: ', checkpassword);
if (checkpassword) { if (checkpassword) {
// const tokenValidation=await tokenGenerator(existingMail.email) // const tokenValidation=await tokenGenerator(existingMail.email)
res.status(200).send({ res.status(200).send({
message: "login successfull", message: "login successfull",
email: existingMail.email, email: existingMail.email,
name: existingMail.userName, name: existingMail.userName,
userId: existingMail._id, userId: existingMail._id,
isShare:existingMail.isShare, isShare:existingMail.isShare,
// token:tokenValidation // token:tokenValidation
}); });
} else { } else {
res.status(404).json({message:"email & password is invalid...Check the credentials"}) res.status(404).json({message:"email & password is invalid...Check the credentials"})
} }
} }
} catch (error:any) { } catch (error:any) {
res.status(500).send(error); res.status(500).send(error);
} }
} }
// static async checkserverHealth(server:Server,organization: string){ // static async checkserverHealth(server:Server,organization: string){
// try { // try {
// if (server.listening) { // if (server.listening) {
// console.log('Server is running'); // console.log('Server is running');
// serverAlive = true; // serverAlive = true;
// // Update all users to online status // // Update all users to online status
// } else { // } else {
// // await userModel(organization).updateMany({}, { activeStatus: "offline" }); // Replace `activeStatus` with your actual field // // await userModel(organization).updateMany({}, { activeStatus: "offline" }); // Replace `activeStatus` with your actual field
// throw new Error('Server is not running'); // throw new Error('Server is not running');
// } // }
// } catch (error:any) { // } catch (error:any) {
// console.error('Server health check failed:', error.message); // console.error('Server health check failed:', error.message);
// serverAlive = false; // serverAlive = false;
// // Update all users to offline status // // Update all users to offline status
// // await userModel(organization).updateMany({}, { activeStatus: "offline" }); // // await userModel(organization).updateMany({}, { activeStatus: "offline" });
// } // }
// } // }
} }
// export const startHealthCheck = (server: Server, organization: string) => { // export const startHealthCheck = (server: Server, organization: string) => {
// setInterval(() => user.checkserverHealth(server, organization), 5000); // setInterval(() => user.checkserverHealth(server, organization), 5000);
// }; // };

View File

@@ -1,19 +1,28 @@
import app from './app'; import app from './app';
import http from 'http'; import http from 'http';
// import { startHealthCheck } from './controller/user-Controller'; import ip from 'ip';
// import { startHealthCheck } from './controller/user-Controller';
const server = http.createServer(app); import swaggerUi from 'swagger-ui-express';
const server = http.createServer(app);
let swaggerDocument;
const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic try {
swaggerDocument = require('../../swagger-output.json');
if (!organization) { } catch (error) {
throw new Error('ORGANIZATION_NAME is not defined in the environment'); console.error('Error loading Swagger JSON:', error);
} swaggerDocument = {}; // Fallback: empty object or some default
}
const PORT = process.env.API_PORT app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
server.listen(PORT, () => { const organization = process.env.ORGANIZATION_NAME || 'defaultOrganization'; // Replace with your logic
console.log(`API-Server running on port ${PORT}`);
// startHealthCheck(server, organization); if (!organization) {
}); throw new Error('ORGANIZATION_NAME is not defined in the environment');
}
const PORT = process.env.API_PORT
server.listen(PORT, () => {
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()}`);
});

View File

@@ -1,47 +1,47 @@
import mongoose, { Schema, Connection, Model } from "mongoose"; import mongoose, { Schema, Connection, Model } from "mongoose";
interface ConnectionCache { interface ConnectionCache {
[key: string]: Connection; [key: string]: Connection;
} }
const connections: ConnectionCache = {}; const connections: ConnectionCache = {};
const MainModel = <T>( const MainModel = <T>(
db: string, db: string,
modelName: string, modelName: string,
schema: Schema<T>, schema: Schema<T>,
collectionName: string collectionName: string
): Model<T> => { ): Model<T> => {
const db1_url = `${process.env.MONGO_URI}${db}`; const db1_url = `${process.env.MONGO_URI}${db}`;
// Check if the connection already exists // Check if the connection already exists
if (connections[db]) { if (connections[db]) {
return connections[db].model<T>(modelName, schema, collectionName); return connections[db].model<T>(modelName, schema, collectionName);
} }
try { try {
const db1 = mongoose.createConnection(db1_url, { const db1 = mongoose.createConnection(db1_url, {
maxPoolSize: 50, maxPoolSize: 50,
}); });
// Cache the connection // Cache the connection
connections[db] = db1; connections[db] = db1;
// Log connection success or handle errors // Log connection success or handle errors
db1.on("connected", () => { db1.on("connected", () => {
console.log(`Connected to MongoDB database: ${db}`); console.log(`Connected to MongoDB database: ${db}`);
}); });
db1.on("error", (err) => { db1.on("error", (err) => {
console.error(`MongoDB connection error for database ${db}:`, err.message); console.error(`MongoDB connection error for database ${db}:`, err.message);
}); });
return db1.model<T>(modelName, schema, collectionName); return db1.model<T>(modelName, schema, collectionName);
} catch (error) { } catch (error) {
console.error("Database connection error:", (error as Error).message); console.error("Database connection error:", (error as Error).message);
throw error; throw error;
} }
}; };
export default MainModel; export default MainModel;

View File

@@ -1,57 +1,57 @@
import mongoose, { Document, Schema } from 'mongoose'; import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose'; import MainModel from '../../connect/mongoose';
// Interface for TypeScript with PascalCase // Interface for TypeScript with PascalCase
export interface floorItenms extends Document { export interface floorItenms extends Document {
modeluuid: string; modeluuid: string;
modelfileID: string; modelfileID: string;
modelname: string modelname: string
isLocked:boolean isLocked:boolean
isVisible:boolean isVisible:boolean
position: [] position: []
rotation: { rotation: {
x: number; x: number;
y: number; y: number;
z: number; z: number;
}; };
} }
// Define the Mongoose Schema // Define the Mongoose Schema
const floorItemsSchema: Schema = new Schema({ const floorItemsSchema: Schema = new Schema({
modeluuid: { type: String }, modeluuid: { type: String },
modelfileID: { type: String }, modelfileID: { type: String },
modelname: { type: String }, modelname: { type: String },
position: { type: Array}, position: { type: Array},
isLocked:{type:Boolean}, isLocked:{type:Boolean},
isVisible:{type:Boolean}, isVisible:{type:Boolean},
rotation: { rotation: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
} }
}); });
// Model for MongoDB collection // Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema); // const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel; // export default cameraModel;
// const floorItemsModel = (db: string) => { // const floorItemsModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ''; // const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set'); // throw new Error('MONGO_URI environment variable is not set');
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// return dbConnection.model<floorItenms>('floorItenms', floorItenmsSchema,`floorItenms`); // return dbConnection.model<floorItenms>('floorItenms', floorItenmsSchema,`floorItenms`);
// } // }
// export default floorItemsModel; // export default floorItemsModel;
const floorItemsModel = (db:string) => { const floorItemsModel = (db:string) => {
return MainModel(db, "floorItems", floorItemsSchema, "floorItems") return MainModel(db, "floorItems", floorItemsSchema, "floorItems")
}; };
export default floorItemsModel; export default floorItemsModel;

View File

@@ -1,46 +1,46 @@
import mongoose, { Document, Schema } from 'mongoose'; import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose'; import MainModel from '../../connect/mongoose';
// Interface for TypeScript with PascalCase // Interface for TypeScript with PascalCase
export interface wallitems extends Document { export interface wallitems extends Document {
modeluuid: string; modeluuid: string;
modelname: string modelname: string
type: string type: string
csgposition: [] csgposition: []
csgscale: [] csgscale: []
position: [] position: []
quaternion: [] quaternion: []
scale: [] scale: []
} }
// Define the Mongoose Schema // Define the Mongoose Schema
const wallItemsSchema: Schema = new Schema({ const wallItemsSchema: Schema = new Schema({
modeluuid: { type: String,unique:true }, modeluuid: { type: String,unique:true },
modelname: { type: String}, modelname: { type: String},
type: { type: String }, type: { type: String },
csgposition: { type: Array}, csgposition: { type: Array},
csgscale: { type: Array,}, csgscale: { type: Array,},
position: { type: Array }, position: { type: Array },
quaternion: { type: Array}, quaternion: { type: Array},
scale: { type: Array} scale: { type: Array}
}); });
// const wallItenmModel = (db: string) => { // const wallItenmModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ''; // const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set'); // throw new Error('MONGO_URI environment variable is not set');
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// return dbConnection.model<wallitenms>('wallitenms', wallItenmsSchema, `wallitenms`); // return dbConnection.model<wallitenms>('wallitenms', wallItenmsSchema, `wallitenms`);
// } // }
// export default wallItenmModel; // export default wallItenmModel;
const wallItenmModel = (db:string) => { const wallItenmModel = (db:string) => {
return MainModel(db, "wallitems", wallItemsSchema, "wallitems") return MainModel(db, "wallitems", wallItemsSchema, "wallitems")
}; };
export default wallItenmModel; export default wallItenmModel;

View File

@@ -1,87 +1,87 @@
import mongoose, { Document, Schema } from 'mongoose'; import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose'; import MainModel from '../../connect/mongoose';
// Interface for TypeScript with PascalCase // Interface for TypeScript with PascalCase
export interface Camera extends Document { export interface Camera extends Document {
userId: string; userId: string;
position: { position: {
x: number; x: number;
y: number; y: number;
z: number; z: number;
} }
target: { target: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
} }
rotation: { rotation: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
} }
} }
// Define the Mongoose Schema // Define the Mongoose Schema
const cameraSchema: Schema = new Schema({ const cameraSchema: Schema = new Schema({
userId: { type: String }, userId: { type: String },
position: { position: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
}, },
target: { target: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
}, },
rotation: { rotation: {
x: { type: Number, required: true }, x: { type: Number, required: true },
y: { type: Number, required: true }, y: { type: Number, required: true },
z: { type: Number, required: true } z: { type: Number, required: true }
} }
}); });
// Model for MongoDB collection // Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema); // const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel; // export default cameraModel;
// const cameraModel = (db: string) => { // const cameraModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ''; // const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set'); // throw new Error('MONGO_URI environment variable is not set');
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// return dbConnection.model<Camera>('Camera', cameraSchema,`Camera`); // return dbConnection.model<Camera>('Camera', cameraSchema,`Camera`);
// } // }
// export default cameraModel; // export default cameraModel;
// const cameraModel = (db: string) => { // const cameraModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ''; // const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set'); // throw new Error('MONGO_URI environment variable is not set');
// } // }
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // dbName: db,
// serverSelectionTimeoutMS: 60000, // Increased timeout // serverSelectionTimeoutMS: 60000, // Increased timeout
// }); // });
// dbConnection.on('error', (err) => { // dbConnection.on('error', (err) => {
// console.error(`MongoDB connection error for database ${db}:`, err); // console.error(`MongoDB connection error for database ${db}:`, err);
// }); // });
// dbConnection.once('open', () => { // dbConnection.once('open', () => {
// console.log(`Connected to MongoDB database: ${db}`); // console.log(`Connected to MongoDB database: ${db}`);
// }); // });
// return dbConnection.model<Camera>('Camera', cameraSchema, 'Camera'); // return dbConnection.model<Camera>('Camera', cameraSchema, 'Camera');
// }; // };
// export default cameraModel // export default cameraModel
const cameraModel = (db:string) => { const cameraModel = (db:string) => {
return MainModel(db, "Camera", cameraSchema, "Camera") return MainModel(db, "Camera", cameraSchema, "Camera")
}; };
export default cameraModel; export default cameraModel;

View File

@@ -1,38 +1,38 @@
import mongoose, { Document, Schema } from 'mongoose'; import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose'; import MainModel from '../../connect/mongoose';
// Interface for TypeScript with PascalCase // Interface for TypeScript with PascalCase
export interface environment extends Document { export interface environment extends Document {
userId: string; userId: string;
roofVisibility:boolean roofVisibility:boolean
wallVisibility:boolean wallVisibility:boolean
} }
// Define the Mongoose Schema // Define the Mongoose Schema
const environmentSchema: Schema = new Schema({ const environmentSchema: Schema = new Schema({
userId: { type: String, unique: true }, userId: { type: String, unique: true },
roofVisibility: { type: Boolean ,default:false}, roofVisibility: { type: Boolean ,default:false},
wallVisibility: { type: Boolean ,default:false}, wallVisibility: { type: Boolean ,default:false},
}); });
// Model for MongoDB collection // Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema); // const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel; // export default cameraModel;
// const environmentModel = (db: string) => { // const environmentModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ''; // const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set'); // throw new Error('MONGO_URI environment variable is not set');
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// return dbConnection.model<environment>('environments', environmentSchema,`environments`); // return dbConnection.model<environment>('environments', environmentSchema,`environments`);
// } // }
// export default environmentModel; // export default environmentModel;
const environmentModel = (db:string) => { const environmentModel = (db:string) => {
return MainModel(db, "environments", environmentSchema, "environments") return MainModel(db, "environments", environmentSchema, "environments")
}; };
export default environmentModel; export default environmentModel;

View File

@@ -1,43 +1,43 @@
import mongoose, { Document, Schema } from "mongoose"; import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose"; import MainModel from "../../connect/mongoose";
const positionSchema = new mongoose.Schema({ const positionSchema = new mongoose.Schema({
x: { type: Number, }, // Optional position fields x: { type: Number, }, // Optional position fields
y: { type: Number, }, y: { type: Number, },
z: { type: Number}, z: { type: Number},
}); });
// Define a schema for the individual line // Define a schema for the individual line
const Vector3 = new mongoose.Schema({ const Vector3 = new mongoose.Schema({
position: { type: positionSchema, required: false }, // Optional position position: { type: positionSchema, required: false }, // Optional position
uuid: { type: String, required: false }, // Optional uuid uuid: { type: String, required: false }, // Optional uuid
}); });
// Define the main schema // Define the main schema
const LineSchema = new mongoose.Schema({ const LineSchema = new mongoose.Schema({
layer: { type: Number, required: true }, // Layer is mandatory layer: { type: Number, required: true }, // Layer is mandatory
line: { type: [Vector3], required: true }, // Array of line objects line: { type: [Vector3], required: true }, // Array of line objects
type: { type: String, required: false }, // Optional type type: { type: String, required: false }, // Optional type
}); });
// Database connection and model creation // Database connection and model creation
// const lineModel = (db: string) => { // const lineModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ""; // const mongoUrl = process.env.MONGO_URI || "";
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error("MONGO_URI environment variable is not set"); // throw new Error("MONGO_URI environment variable is not set");
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// // Return the model // // Return the model
// return dbConnection.model("lines", LineSchema, "lines"); // return dbConnection.model("lines", LineSchema, "lines");
// }; // };
// export default lineModel; // export default lineModel;
const lineModel = (db:string) => { const lineModel = (db:string) => {
return MainModel(db, "lines", LineSchema, "lines") return MainModel(db, "lines", LineSchema, "lines")
}; };
export default lineModel; export default lineModel;

View File

@@ -1,69 +1,69 @@
import mongoose, { Document, Schema } from "mongoose"; import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../connect/mongoose"; import MainModel from "../connect/mongoose";
export interface User extends Document { export interface User extends Document {
userName: String; userName: String;
email: String; email: String;
password: String; password: String;
role: String; role: String;
profilePicture: String; profilePicture: String;
isShare:Boolean, isShare:Boolean,
activeStatus:string activeStatus:string
} }
const signupschema: Schema = new Schema({ const signupschema: Schema = new Schema({
userName: { userName: {
type: String, type: String,
required: true, required: true,
}, },
email: { email: {
type: String, type: String,
unique: true, unique: true,
required: true, required: true,
}, },
password: { password: {
type: String, type: String,
min: 8, min: 8,
required: true, required: true,
}, },
role: { role: {
type: String, type: String,
default: "User", default: "User",
enum: ["User", "Admin", "Project Manager", "Manager", "Owner"], enum: ["User", "Admin", "Project Manager", "Manager", "Owner"],
}, },
profilePicture: { profilePicture: {
type: String, type: String,
// default: "default-profile-picture.jpg" // default: "default-profile-picture.jpg"
}, },
isShare:{ isShare:{
type:Boolean, type:Boolean,
default:false default:false
}, },
activeStatus:{ activeStatus:{
type:String, type:String,
enum: ["online", "offline"], enum: ["online", "offline"],
default: "offline" default: "offline"
} }
}); });
// const userModel = (db: string) => { // const userModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || ""; // const mongoUrl = process.env.MONGO_URI || "";
// if (!mongoUrl) { // if (!mongoUrl) {
// throw new Error("MONGO_URI environment variable is not set"); // throw new Error("MONGO_URI environment variable is not set");
// } // }
// // Connect to the database // // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, { // const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here // dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000, // serverSelectionTimeoutMS: 30000,
// }); // });
// // Return the model // // Return the model
// return dbConnection.model("Users", signupschema, "Users"); // return dbConnection.model("Users", signupschema, "Users");
// }; // };
// export default userModel; // export default userModel;
const userModel = (db:string) => { const userModel = (db:string) => {
return MainModel(db, "Users", signupschema, "Users") return MainModel(db, "Users", signupschema, "Users")
}; };
export default userModel; export default userModel;

View File

@@ -1,24 +1,24 @@
const bcrypt = require("bcryptjs"); const bcrypt = require("bcryptjs");
const saltRounds = 10; const saltRounds = 10;
const hashGenerate = async (Password:String) => { const hashGenerate = async (Password:String) => {
try { try {
const salt = await bcrypt.genSalt(saltRounds); const salt = await bcrypt.genSalt(saltRounds);
const hash = await bcrypt.hash(Password, salt); const hash = await bcrypt.hash(Password, salt);
return hash; return hash;
} catch (error) { } catch (error) {
return error; return error;
} }
}; };
const hashValidator = async (password:String, hashedPassword:String) => { const hashValidator = async (password:String, hashedPassword:String) => {
try { try {
const result = await bcrypt.compare(password, hashedPassword); const result = await bcrypt.compare(password, hashedPassword);
return result; return result;
} catch (error) { } catch (error) {
return false; return false;
} }
}; };
module.exports.hashGenerate = hashGenerate; module.exports.hashGenerate = hashGenerate;
module.exports.hashValidator = hashValidator; module.exports.hashValidator = hashValidator;

View File

@@ -1,38 +1,38 @@
import { Request, Response, NextFunction } from 'express'; import { Request, Response, NextFunction } from 'express';
import * as Jwt from 'jsonwebtoken'; // Correct way to import jsonwebtoken import * as Jwt from 'jsonwebtoken'; // Correct way to import jsonwebtoken
// Define a new interface extending Request // Define a new interface extending Request
interface AuthenticatedRequest extends Request { interface AuthenticatedRequest extends Request {
user?: { user?: {
email: string; email: string;
// Add more fields as needed based on your JWT payload // Add more fields as needed based on your JWT payload
}; };
} }
const tokenGenerator = (email: string) => { const tokenGenerator = (email: string) => {
const token = Jwt.sign({ email: email }, "Milestone", { const token = Jwt.sign({ email: email }, "Milestone", {
expiresIn: "3hours", expiresIn: "3hours",
}); });
return token; return token;
}; };
const tokenValidator = (req: AuthenticatedRequest, res: Response, next: NextFunction): void => { const tokenValidator = (req: AuthenticatedRequest, res: Response, next: NextFunction): void => {
const token: string | undefined = req.headers.token as string | undefined; const token: string | undefined = req.headers.token as string | undefined;
if (!token) { if (!token) {
res.status(403).json({ res.status(403).json({
msg: "No token present", msg: "No token present",
}); });
return; // Make sure to return after sending a response return; // Make sure to return after sending a response
} }
try { try {
const decoded = Jwt.verify(token,"Milestone") as { email: string }; // adjust if your JWT payload has more fields const decoded = Jwt.verify(token,"Milestone") as { email: string }; // adjust if your JWT payload has more fields
req.user = decoded; req.user = decoded;
next(); next();
} catch (err) { } catch (err) {
res.status(401).json({ res.status(401).json({
msg: "Invalid Token", msg: "Invalid Token",
}); });
} }
}; };
export { tokenValidator,tokenGenerator }; export { tokenValidator,tokenGenerator };

View 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!');
})

View File

@@ -1,35 +1,35 @@
ARG NODE_VERSION=lts ARG NODE_VERSION=lts
FROM node:${NODE_VERSION}-alpine AS development FROM node:${NODE_VERSION}-alpine AS development
# Use production node environment by default. # Use production node environment by default.
ENV NODE_ENV development ENV NODE_ENV development
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN npm install -g npm RUN npm install -g npm
COPY package.json /usr/src/app/package.json COPY package.json /usr/src/app/package.json
# COPY package-lock.json /usr/src/app/package-lock.json # COPY package-lock.json /usr/src/app/package-lock.json
RUN npm install RUN npm install
# Run the application as a non-root user. # Run the application as a non-root user.
USER root USER root
# Copy the rest of the source files into the image. # Copy the rest of the source files into the image.
COPY . . COPY . .
# Expose the port that the application listens on. # Expose the port that the application listens on.
EXPOSE 1059 EXPOSE 1059
# Run the application. # Run the application.
CMD ["npm", "run", "start:socket"] CMD ["npm", "run", "start:socket"]

View File

@@ -1,22 +1,23 @@
import express from "express" import express from "express"
import { Response, Request } from "express"; import { Response, Request } from "express";
import http from "http"; import http from "http";
import dotenv from "dotenv"; // Import dotenv import ip from 'ip';
import dotenv from "dotenv"; // Import dotenv
dotenv.config();
dotenv.config();
import { initSocketServer } from "./socket/socketManager";
import { initSocketServer } from "./socket/socketManager";
const app = express();
const PORT = process.env.SOCKET_PORT; const app = express();
const server = http.createServer(app); const PORT = process.env.SOCKET_PORT;
const server = http.createServer(app);
app.get('/', (req: Request, res: Response) => {
res.send('Hello, I am Major-Dwinzo RealTime!'); app.get('/', (req: Request, res: Response) => {
}); res.send('Hello, I am Major-Dwinzo RealTime!');
});
initSocketServer(server);
server.listen(PORT, () => { initSocketServer(server);
console.log(`socket-Server is running on http://localhost:${PORT}`); server.listen(PORT, () => {
}); console.log(`socket-Server is running on http://localhost:${PORT}`);
});

View File

@@ -1,53 +1,53 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model"; import floorItemsModel from "../../../shared/model/assets/flooritems-Model";
export const setFloorItems = async (data: any) => { export const setFloorItems = async (data: any) => {
try { try {
const { modelfileID,modeluuid, modelname, position, rotation,isLocked,isVisible, organization } = data const { modelfileID,modeluuid, modelname, position, rotation,isLocked,isVisible, organization } = data
const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid, modelname: modelname }) const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid, modelname: modelname })
if (findvalue) { if (findvalue) {
const updatevalue = await floorItemsModel(organization).findOneAndUpdate( const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid, modelname: modelname }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true }); { modeluuid: modeluuid, modelname: modelname }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization } return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization }
} else { } else {
const newValue = await floorItemsModel(organization).create({ modeluuid, modelname, modelfileID,position, rotation,isLocked,isVisible }); const newValue = await floorItemsModel(organization).create({ modeluuid, modelname, modelfileID,position, rotation,isLocked,isVisible });
return { success: true, message: 'flooritem created', data: newValue,organization:organization } return { success: true, message: 'flooritem created', data: newValue,organization:organization }
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating flooritems:', error); console.error('Error creating flooritems:', error);
return { success: false, message: 'Error creating or updating camera', error } return { success: false, message: 'Error creating or updating camera', error }
} }
} }
export const deleteFloorItems = async (data: any)=>{ export const deleteFloorItems = async (data: any)=>{
try { try {
const { modeluuid,modelname,organization } = data; const { modeluuid,modelname,organization } = data;
const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname}) const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
if (!findValue) { if (!findValue) {
return { success: false, message: 'model not found',organization:organization } return { success: false, message: 'model not found',organization:organization }
} else { } else {
return { success: true, message: 'flooritem deleted', data: findValue,organization:organization } return { success: true, message: 'flooritem deleted', data: findValue,organization:organization }
} }
} catch (error) { } catch (error) {
console.error('Error get flooritems:', error); console.error('Error get flooritems:', error);
return { success: false, message: 'Failed to delete flooritems', error } return { success: false, message: 'Failed to delete flooritems', error }
} }
} }

View File

@@ -1,60 +1,60 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import wallItenmModel from "../../../shared/model/assets/wallitems-Model"; import wallItenmModel from "../../../shared/model/assets/wallitems-Model";
export const setWallItems = async (data: any) => { export const setWallItems = async (data: any) => {
try { try {
const { modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale, organization } = data const { modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale, organization } = data
const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid }) const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid })
if (findvalue) { if (findvalue) {
const updatevalue = await wallItenmModel(organization).findOneAndUpdate( const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid }, { modeluuid: modeluuid },
{ {
modelname, modelname,
position, position,
type, type,
csgposition, csgposition,
csgscale, csgscale,
quaternion, quaternion,
scale, scale,
}, },
{ new: true } // Return the updated document { new: true } // Return the updated document
); );
return { success: true, message: 'wallIitem updated', data: updatevalue, organization: organization } return { success: true, message: 'wallIitem updated', data: updatevalue, organization: organization }
} else { } else {
const newValue = await wallItenmModel(organization).create({ modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale }); const newValue = await wallItenmModel(organization).create({ modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale });
return { success: true, message: 'wallIitem created', data: newValue, organization: organization } return { success: true, message: 'wallIitem created', data: newValue, organization: organization }
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating wallIitem:', error); console.error('Error creating wallIitem:', error);
return { success: false, message: 'Error creating or updating camera', error } return { success: false, message: 'Error creating or updating camera', error }
} }
} }
export const deleteWallItems = async (data: any) => { export const deleteWallItems = async (data: any) => {
try { try {
const { modeluuid, modelname, organization } = data; const { modeluuid, modelname, organization } = data;
const findValue = await wallItenmModel(organization).findOneAndDelete({ modeluuid: modeluuid, modelname: modelname }) const findValue = await wallItenmModel(organization).findOneAndDelete({ modeluuid: modeluuid, modelname: modelname })
if (!findValue) { if (!findValue) {
return { success: false, message: 'model not found', organization: organization } return { success: false, message: 'model not found', organization: organization }
} else { } else {
return { success: true, message: 'wallitem deleted', data: findValue, organization: organization } return { success: true, message: 'wallitem deleted', data: findValue, organization: organization }
} }
} catch (error) { } catch (error) {
console.error('Error get wallitem:', error); console.error('Error get wallitem:', error);
return { success: false, message: 'Failed to delete wallitem', error } return { success: false, message: 'Failed to delete wallitem', error }
} }
} }

View File

@@ -1,31 +1,31 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import { Socket } from "socket.io"; import { Socket } from "socket.io";
import cameraModel from "../../../shared/model/camera/camera-Model"; import cameraModel from "../../../shared/model/camera/camera-Model";
export const createCamera = async (data: any,) => { export const createCamera = async (data: any,) => {
try { try {
const { userId, position, target, organization,rotation } = data const { userId, position, target, organization,rotation } = data
const findCamera = await cameraModel(organization).findOne({ userId: userId }) const findCamera = await cameraModel(organization).findOne({ userId: userId })
if (findCamera) { if (findCamera) {
const updateCamera = await cameraModel(organization).findOneAndUpdate( const updateCamera = await cameraModel(organization).findOneAndUpdate(
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true }); { userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
// io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera }); // io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera });
return { success: true, message: 'Camera updated', data: updateCamera,organization:organization} return { success: true, message: 'Camera updated', data: updateCamera,organization:organization}
} }
else { else {
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation }) const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
return { success: false, message: 'Camera created' ,data:newCamera,organization:organization} return { success: false, message: 'Camera created' ,data:newCamera,organization:organization}
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating camera:', error); console.error('Error creating camera:', error);
return { success: false, message: 'Error creating or updating camera', error, } return { success: false, message: 'Error creating or updating camera', error, }
} }
} }

View File

@@ -1,33 +1,33 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import environmentModel from "../../../shared/model/environments/environments-Model"; import environmentModel from "../../../shared/model/environments/environments-Model";
export const setEnvironment = async (data: any,) => { export const setEnvironment = async (data: any,) => {
try { try {
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
const findvalue = await environmentModel(organization).findOne({ userId: userId }) const findvalue = await environmentModel(organization).findOne({ userId: userId })
if (findvalue) { if (findvalue) {
const updatevalue = await environmentModel(organization).findOneAndUpdate( const updatevalue = await environmentModel(organization).findOneAndUpdate(
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility }, { new: true }); { userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility }, { new: true });
// res.status(201).json(updatevalue); // res.status(201).json(updatevalue);
return { success: true, message: 'evironments updated', data: updatevalue,organization:organization } return { success: true, message: 'evironments updated', data: updatevalue,organization:organization }
} else { } else {
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility,shadowVisibility }); const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility,shadowVisibility });
return { success: true, message: 'evironments created', data: newValue,organization:organization } return { success: true, message: 'evironments created', data: newValue,organization:organization }
// res.status(201).json(newValue); // res.status(201).json(newValue);
} }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating evironments:', error); console.error('Error creating evironments:', error);
return { success: false, message: 'Error creating or updating evironments', error } return { success: false, message: 'Error creating or updating evironments', error }
} }
} }

View File

@@ -1,100 +1,100 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import lineModel from "../../../shared/model/lines/lines-Model"; import lineModel from "../../../shared/model/lines/lines-Model";
export const createLineItems = async (data: any)=>{ export const createLineItems = async (data: any)=>{
try { try {
const {organization,layer,line,type}=data const {organization,layer,line,type}=data
const newLine = await lineModel(organization).create({ layer,line,type }); const newLine = await lineModel(organization).create({ layer,line,type });
return { success: true, message: 'line create', data: newLine,organization:organization } return { success: true, message: 'line create', data: newLine,organization:organization }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
return { success: false, message: 'Error create line', error } return { success: false, message: 'Error create line', error }
} }
} }
export const updateLineItems = async (data: any)=>{ export const updateLineItems = async (data: any)=>{
try { try {
const {organization,uuid,position,}=data const {organization,uuid,position,}=data
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid }); // const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
// Update the position of the line matching the uuid // Update the position of the line matching the uuid
const updateResult = await lineModel(organization).updateMany( const updateResult = await lineModel(organization).updateMany(
{ 'line.uuid': uuid }, // Filter: Find the line with the given uuid { 'line.uuid': uuid }, // Filter: Find the line with the given uuid
{ $set: { 'line.$.position': position } } // Update the position and type { $set: { 'line.$.position': position } } // Update the position and type
); );
return { success: true, message: 'line updated', data: {uuid:uuid,position:position},organization:organization } return { success: true, message: 'line updated', data: {uuid:uuid,position:position},organization:organization }
// Send response with the created document // Send response with the created document
} catch (error) { } catch (error) {
console.error('Error creating Lines:', error); console.error('Error creating Lines:', error);
return { success: false, message: 'Error updating line', error } return { success: false, message: 'Error updating line', error }
} }
} }
export const deleteLineItems = async (data: any)=>{ export const deleteLineItems = async (data: any)=>{
try { try {
const {organization,line}=data const {organization,line}=data
const inputUuids = line.map((item: any) => item.uuid); const inputUuids = line.map((item: any) => item.uuid);
// const findValue = await lineModel(organization).findOneAndDelete({ // const findValue = await lineModel(organization).findOneAndDelete({
// line: { $elemMatch: { uuid: { $in: inputUuids } } }, // line: { $elemMatch: { uuid: { $in: inputUuids } } },
// }); // });
const findValue = await lineModel(organization).findOneAndDelete({ const findValue = await lineModel(organization).findOneAndDelete({
"line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key "line.uuid": { $all: inputUuids } // Ensure all UUIDs are present in the `line` key
}); });
if (!findValue) { if (!findValue) {
return { success: false, message: 'line not found',organization:organization } return { success: false, message: 'line not found',organization:organization }
} else { } else {
return { success: true, message: 'line deleted', data: findValue,organization:organization } return { success: true, message: 'line deleted', data: findValue,organization:organization }
} }
} catch (error) { } catch (error) {
console.error('Error delete Lines:', error); console.error('Error delete Lines:', error);
return { success: false, message: 'Failed to delete line', error } return { success: false, message: 'Failed to delete line', error }
} }
} }
export const deleteLayer = async (data: any)=>{ export const deleteLayer = async (data: any)=>{
try { try {
const {organization,layer}=data const {organization,layer}=data
const findValue = await lineModel(organization).find({ layer: layer }); const findValue = await lineModel(organization).find({ layer: layer });
if (!findValue) { if (!findValue) {
return { success: false, message: 'layer not found' } return { success: false, message: 'layer not found' }
} else { } else {
await lineModel(organization).deleteMany({ layer: layer }); await lineModel(organization).deleteMany({ layer: layer });
// Update documents with layer greater than -1 // Update documents with layer greater than -1
const updateResult = await lineModel(organization).updateMany( const updateResult = await lineModel(organization).updateMany(
{ layer: { $gt:layer} }, { layer: { $gt:layer} },
{ $inc: { layer: -1 } } // Example operation: decrementing layer by 1 { $inc: { layer: -1 } } // Example operation: decrementing layer by 1
); );
return { success: true, message: 'layer deleted', data: layer,organization:organization } return { success: true, message: 'layer deleted', data: layer,organization:organization }
} }
} catch (error) { } catch (error) {
console.error('Error delete layer:', error); console.error('Error delete layer:', error);
return { success: false, message: 'Failed to delete layer', error } return { success: false, message: 'Failed to delete layer', error }
} }
} }
export const deleteLinPoiteItems = async (data: any)=>{ export const deleteLinPoiteItems = async (data: any)=>{
try { try {
const {organization,uuid}=data const {organization,uuid}=data
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid }) const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
if (!findValue) { if (!findValue) {
return { success: false, message: 'line not found',organization:organization } return { success: false, message: 'line not found',organization:organization }
} else { } else {
return { success: true, message: 'point deleted', data: uuid ,organization:organization} return { success: true, message: 'point deleted', data: uuid ,organization:organization}
} }
} catch (error) { } catch (error) {
console.error('Error delete Lines:', error); console.error('Error delete Lines:', error);
return { success: false, message: 'Failed to delete point', error } return { success: false, message: 'Failed to delete point', error }
} }
} }

View File

@@ -1,97 +1,97 @@
import cameraModel from "../../../shared/model/camera/camera-Model" import cameraModel from "../../../shared/model/camera/camera-Model"
import userModel from "../../../shared/model/user-Model" import userModel from "../../../shared/model/user-Model"
export const activeUsers = async (data: any) => { export const activeUsers = async (data: any) => {
try { try {
if (data && data.email) { if (data && data.email) {
const email = data.email const email = data.email
const organization = email.split("@")[1].split(".")[0] const organization = email.split("@")[1].split(".")[0]
const findUser = await userModel(organization).findOne({email}) const findUser = await userModel(organization).findOne({email})
if (findUser) { if (findUser) {
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:findUser.email},{activeStatus:"online"},{new:true}) const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:findUser.email},{activeStatus:"online"},{new:true})
if (updateActiveStatus) { if (updateActiveStatus) {
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id}) const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
.select("position target rotation -_id"); .select("position target rotation -_id");
if (cameraDatas) { if (cameraDatas) {
const result = { const result = {
position: cameraDatas.position, position: cameraDatas.position,
target: cameraDatas.target, target: cameraDatas.target,
rotation: cameraDatas.rotation, rotation: cameraDatas.rotation,
userData: { userData: {
_id: updateActiveStatus._id, _id: updateActiveStatus._id,
userName: updateActiveStatus.userName, userName: updateActiveStatus.userName,
email: updateActiveStatus.email, email: updateActiveStatus.email,
}, },
}; };
return { success: true, message: 'user connect ', data: result,organization:organization } return { success: true, message: 'user connect ', data: result,organization:organization }
// return result; // return result;
} }
} }
} }
}else { }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 // Handle the error or return a default value
// Example: Return an error response if the email is invalid // Example: Return an error response if the email is invalid
return { success: false, message: 'Email is missing or invalid', } return { success: false, message: 'Email is missing or invalid', }
// return res.status(400).send({ message: 'Email is missing or invalid' }); // return res.status(400).send({ message: 'Email is missing or invalid' });
} }
// // return []; // // return [];
} catch (error) { } catch (error) {
return { success: false, message:error} return { success: false, message:error}
} }
} }
export const activeUserOffline = async (data: any) => { export const activeUserOffline = async (data: any) => {
try { try {
const email = data.email const email = data.email
const organization = email.split("@")[1].split(".")[0] const organization = email.split("@")[1].split(".")[0]
const findUsers = await userModel(organization).findOne({email}) const findUsers = await userModel(organization).findOne({email})
// console.log('findUsers: ', findUsers); // console.log('findUsers: ', findUsers);
if (findUsers) { if (findUsers) {
const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:email},{activeStatus:"offline"},{new:true}) const updateActiveStatus = await userModel(organization).findOneAndUpdate({email:email},{activeStatus:"offline"},{new:true})
// console.log('updateActiveStatus: ',updateActiveStatus); // console.log('updateActiveStatus: ',updateActiveStatus);
if (updateActiveStatus) { if (updateActiveStatus) {
const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id}) const cameraDatas=await cameraModel(organization).findOne({userId:updateActiveStatus._id})
.select("position target rotation -_id"); .select("position target rotation -_id");
// console.log('cameraDatas: ', cameraDatas); // console.log('cameraDatas: ', cameraDatas);
if (cameraDatas) { if (cameraDatas) {
const result = { const result = {
position: cameraDatas.position, position: cameraDatas.position,
target: cameraDatas.target, target: cameraDatas.target,
rotation: cameraDatas.rotation, rotation: cameraDatas.rotation,
userData: { userData: {
_id: updateActiveStatus._id, _id: updateActiveStatus._id,
userName: updateActiveStatus.userName, userName: updateActiveStatus.userName,
email: updateActiveStatus.email, email: updateActiveStatus.email,
}, },
}; };
// console.log("Formatted Result:", result); // console.log("Formatted Result:", result);
// return result; // return result;
return { success: true, message: 'user disconnect', data: result,organization:organization } return { success: true, message: 'user disconnect', data: result,organization:organization }
} }
} }
} }
// // return []; // // return [];
} catch (error) { } catch (error) {
return { success: false, message: error} return { success: false, message: error}
} }
} }

View File

@@ -1,45 +1,45 @@
export const EVENTS = { export const EVENTS = {
connection: "connection", connection: "connection",
disconnect:"disconnect", disconnect:"disconnect",
//userActiveStatus //userActiveStatus
userConnect:"userConnectRespones", userConnect:"userConnectRespones",
userDisConnect:"userDisConnectRespones", userDisConnect:"userDisConnectRespones",
// Room management events // Room management events
joinRoom: 'joinRoom', joinRoom: 'joinRoom',
createroom: "createRoom", // When a client joins a room createroom: "createRoom", // When a client joins a room
leaveRoom: 'leaveRoom', // When a client leaves a room leaveRoom: 'leaveRoom', // When a client leaves a room
roomCreated: 'roomCreated', // When a new room is created roomCreated: 'roomCreated', // When a new room is created
roomDeleted: 'roomDeleted', // When a room is deleted roomDeleted: 'roomDeleted', // When a room is deleted
// Camera //response // Camera //response
setCamera: 'v1:Camera:set', setCamera: 'v1:Camera:set',
cameraCreateResponse: "cameraCreateResponse", // Response for camera creation cameraCreateResponse: "cameraCreateResponse", // Response for camera creation
cameraUpdateResponse: "cameraUpdateResponse", // Response for camera update cameraUpdateResponse: "cameraUpdateResponse", // Response for camera update
cameraError: "cameraError", cameraError: "cameraError",
//Environment //Environment
setenvironment: "v1:Environment:set", setenvironment: "v1:Environment:set",
EnvironmentUpdateResponse: "EnvironmentUpdateResponse", EnvironmentUpdateResponse: "EnvironmentUpdateResponse",
//FloorItems //FloorItems
setFloorItems: "v1:FloorItems:set", setFloorItems: "v1:FloorItems:set",
FloorItemsUpdateResponse: "FloorItemsUpdateResponse", FloorItemsUpdateResponse: "FloorItemsUpdateResponse",
deleteFloorItems: "v1:FloorItems:delete", deleteFloorItems: "v1:FloorItems:delete",
FloorItemsDeleteResponse: "FloorItemsDeleteResponse", FloorItemsDeleteResponse: "FloorItemsDeleteResponse",
floorItemError: "floorItemError", floorItemError: "floorItemError",
//WALLItems //WALLItems
setWallItems: "v1:wallItems:set", setWallItems: "v1:wallItems:set",
wallItemsUpdateResponse: "wallItemsUpdateResponse", wallItemsUpdateResponse: "wallItemsUpdateResponse",
deleteWallItems: "v1:wallItems:delete", deleteWallItems: "v1:wallItems:delete",
wallItemsDeleteResponse: "wallItemsDeleteResponse", wallItemsDeleteResponse: "wallItemsDeleteResponse",
wallItemError: "wallItemError", wallItemError: "wallItemError",
//Lines //Lines
createLine:"v1:Line:create", createLine:"v1:Line:create",
createLineResponse:"Line:response:create", createLineResponse:"Line:response:create",
updateLine:"v1:Line:update", updateLine:"v1:Line:update",
updateLineResponse:"Line:response:update", updateLineResponse:"Line:response:update",
deleteLine:"v1:Line:delete", deleteLine:"v1:Line:delete",
deleteLineResponse:"Line:response:delete", deleteLineResponse:"Line:response:delete",
deletePoint:"v1:Line:delete:point", deletePoint:"v1:Line:delete:point",
deletePointResponse:"Line:response:delete:point", deletePointResponse:"Line:response:delete:point",
deleteLineLayer:"v1:Line:delete:layer", deleteLineLayer:"v1:Line:delete:layer",
deleteLineLayerResponse:"Line:response:delete:layer", deleteLineLayerResponse:"Line:response:delete:layer",
} }

View File

@@ -1,421 +1,421 @@
import { Server, Socket } from 'socket.io'; import { Server, Socket } from 'socket.io';
import { EVENTS } from './events'; import { EVENTS } from './events';
import { createCamera } from '../services/camera/camera-Controller'; import { createCamera } from '../services/camera/camera-Controller';
import { setEnvironment } from '../services/environments/environments-controller'; import { setEnvironment } from '../services/environments/environments-controller';
import { deleteFloorItems, setFloorItems } from '../services/assets/flooritem-Controller'; import { deleteFloorItems, setFloorItems } from '../services/assets/flooritem-Controller';
import { deleteWallItems, setWallItems } from '../services/assets/wallitem-Controller'; import { deleteWallItems, setWallItems } from '../services/assets/wallitem-Controller';
import { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller'; import { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller';
import { activeUserOffline, activeUsers } from '../services/users/user-controller'; import { activeUserOffline, activeUsers } from '../services/users/user-controller';
const cameraHandleEvent =async (event: string, socket: Socket, data: any,io:any) => { const cameraHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.setCamera: case EVENTS.setCamera:
const result = await createCamera(data,); const result = await createCamera(data,);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
// console.log('result.success: ', result.success); // console.log('result.success: ', result.success);
// if (result.message === 'Camera updated') { // if (result.message === 'Camera updated') {
// Emit update response // Emit update response
io.emit(EVENTS.cameraUpdateResponse, { io.emit(EVENTS.cameraUpdateResponse, {
success: true, success: true,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else if (result.message === 'Camera created') { } else if (result.message === 'Camera created') {
// Emit create response // Emit create response
io.emit(EVENTS.cameraCreateResponse, { io.emit(EVENTS.cameraCreateResponse, {
success: true, success: true,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
// } // }
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.cameraError, { socket.emit(EVENTS.cameraError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} }
break; break;
// case EVENTS.updataControlle_iot: // case EVENTS.updataControlle_iot:
// updateControlle(data); // updateControlle(data);
break; break;
// case EVENTS.deleteControlle_iot: // case EVENTS.deleteControlle_iot:
// deleteControlle(data); // deleteControlle(data);
break; break;
default: default:
// console.error(`Unhandled event type: ${event}`); // console.error(`Unhandled event type: ${event}`);
} }
} }
const EnvironmentHandleEvent =async (event: string, socket: Socket, data: any,io:any) => { const EnvironmentHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.setenvironment: case EVENTS.setenvironment:
const result = await setEnvironment(data,); const result = await setEnvironment(data,);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
// if (result.message === 'Camera updated') { // if (result.message === 'Camera updated') {
// Emit update response // Emit update response
io.emit(EVENTS.EnvironmentUpdateResponse, { io.emit(EVENTS.EnvironmentUpdateResponse, {
success: true, success: true,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
// } else if (result.message === 'evironments created') { // } else if (result.message === 'evironments created') {
// // Emit create response // // Emit create response
// io.emit(EVENTS.cameraCreateResponse, { // io.emit(EVENTS.cameraCreateResponse, {
// success: true, // success: true,
// message: result.message, // message: result.message,
// data: result.data, // data: result.data,
// }); // });
// } // }
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.cameraError, { socket.emit(EVENTS.cameraError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} }
break; break;
// case EVENTS.updataControlle_iot: // case EVENTS.updataControlle_iot:
// updateControlle(data); // updateControlle(data);
break; break;
// case EVENTS.deleteControlle_iot: // case EVENTS.deleteControlle_iot:
// deleteControlle(data); // deleteControlle(data);
break; break;
default: default:
// console.error(`Unhandled event type: ${event}`); // console.error(`Unhandled event type: ${event}`);
} }
} }
const floorItemsHandleEvent =async (event: string, socket: Socket, data: any,io:any) => { const floorItemsHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.setFloorItems:{ case EVENTS.setFloorItems:{
const result = await setFloorItems(data); const result = await setFloorItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.FloorItemsUpdateResponse, { io.emit(EVENTS.FloorItemsUpdateResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.floorItemError, { socket.emit(EVENTS.floorItemError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} }
break;} break;}
case EVENTS.deleteFloorItems:{ case EVENTS.deleteFloorItems:{
const result = await deleteFloorItems(data); const result = await deleteFloorItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.FloorItemsDeleteResponse, { io.emit(EVENTS.FloorItemsDeleteResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.floorItemError, { socket.emit(EVENTS.floorItemError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} }
break;} break;}
default: default:
// console.error(`Unhandled event type: ${event}`); // console.error(`Unhandled event type: ${event}`);
} }
} }
const wallItemsHandleEvent =async (event: string, socket: Socket, data: any,io:any) => { const wallItemsHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.setWallItems:{ case EVENTS.setWallItems:{
const result = await setWallItems(data); const result = await setWallItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.wallItemsUpdateResponse, { io.emit(EVENTS.wallItemsUpdateResponse, {
success: true, success: true,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.wallItemError, { socket.emit(EVENTS.wallItemError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
}); });
} }
break; break;
} }
case EVENTS.deleteWallItems:{ case EVENTS.deleteWallItems:{
const result = await deleteWallItems(data); const result = await deleteWallItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.wallItemsDeleteResponse, { io.emit(EVENTS.wallItemsDeleteResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
socket.emit(EVENTS.wallItemError, { socket.emit(EVENTS.wallItemError, {
success: false, success: false,
message: result.message, message: result.message,
error: result.error, error: result.error,
}); });
} }
break; break;
} }
default: default:
// console.error(`Unhandled event type: ${event}`); // console.error(`Unhandled event type: ${event}`);
} }
} }
const lineHandleEvent =async (event: string, socket: Socket, data: any,io:any) => { const lineHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.createLine:{ case EVENTS.createLine:{
const result = await createLineItems(data); const result = await createLineItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.createLineResponse, { io.emit(EVENTS.createLineResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
// socket.emit(EVENTS.wallItemError, { // socket.emit(EVENTS.wallItemError, {
// success: false, // success: false,
// message: result.message, // message: result.message,
// error: result.error, // error: result.error,
// }); // });
} }
break; break;
} }
case EVENTS.updateLine: { case EVENTS.updateLine: {
const result = await updateLineItems(data); const result = await updateLineItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.updateLineResponse, { io.emit(EVENTS.updateLineResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization: result.organization organization: result.organization
}); });
} }
break; break;
} }
case EVENTS.deleteLine:{ case EVENTS.deleteLine:{
const result = await deleteLineItems(data); const result = await deleteLineItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.deleteLineResponse, { io.emit(EVENTS.deleteLineResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
// socket.emit(EVENTS.wallItemError, { // socket.emit(EVENTS.wallItemError, {
// success: false, // success: false,
// message: result.message, // message: result.message,
// error: result.error, // error: result.error,
// }); // });
} }
break; break;
} }
case EVENTS.deletePoint:{ case EVENTS.deletePoint:{
const result = await deleteLinPoiteItems(data); const result = await deleteLinPoiteItems(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.deletePointResponse, { io.emit(EVENTS.deletePointResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
// socket.emit(EVENTS.wallItemError, { // socket.emit(EVENTS.wallItemError, {
// success: false, // success: false,
// message: result.message, // message: result.message,
// error: result.error, // error: result.error,
// }); // });
} }
break; break;
} }
case EVENTS.deleteLineLayer:{ case EVENTS.deleteLineLayer:{
const result = await deleteLayer(data); const result = await deleteLayer(data);
// console.log('result: ', result); // console.log('result: ', result);
if (result.success) { if (result.success) {
io.emit(EVENTS.deleteLineLayerResponse, { io.emit(EVENTS.deleteLineLayerResponse, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
}); });
} else { } else {
// Emit error response // Emit error response
// socket.emit(EVENTS.wallItemError, { // socket.emit(EVENTS.wallItemError, {
// success: false, // success: false,
// message: result.message, // message: result.message,
// error: result.error, // error: result.error,
// }); // });
} }
break; break;
} }
default: default:
// console.error(`Unhandled event type: ${event}`); // console.error(`Unhandled event type: ${event}`);
} }
} }
const userStatus =async (event: string, socket: Socket, data: any,io:any) => { const userStatus =async (event: string, socket: Socket, data: any,io:any) => {
switch (event) { switch (event) {
case EVENTS.connection: { case EVENTS.connection: {
// console.log('EVENTS.connection: ', EVENTS.connection); // console.log('EVENTS.connection: ', EVENTS.connection);
// console.log('event: ', event); // console.log('event: ', event);
const result = await activeUsers(data); const result = await activeUsers(data);
if (result?.success) { if (result?.success) {
// console.log('result.success: ', result.success) // console.log('result.success: ', result.success)
io.emit(EVENTS.userConnect, { io.emit(EVENTS.userConnect, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
});} });}
break; break;
} }
case EVENTS.disconnect: { case EVENTS.disconnect: {
// console.log('EVENTS.disconnect: ', EVENTS.connection); // console.log('EVENTS.disconnect: ', EVENTS.connection);
// console.log('event: ', event); // console.log('event: ', event);
const result = await activeUserOffline(data); const result = await activeUserOffline(data);
if (result?.success) { if (result?.success) {
// console.log('result.success: ', result.success) // console.log('result.success: ', result.success)
io.emit(EVENTS.userDisConnect, { io.emit(EVENTS.userDisConnect, {
success: true || false, success: true || false,
message: result.message, message: result.message,
data: result.data, data: result.data,
socketId: socket.id, socketId: socket.id,
organization:result.organization organization:result.organization
});} });}
break; break;
} }
} }
} }
export const initSocketServer = (httpServer: any) => { export const initSocketServer = (httpServer: any) => {
const io = new Server(httpServer, { const io = new Server(httpServer, {
cors: { cors: {
origin: '*', // Allow CORS for all origins (adjust in production) origin: '*', // Allow CORS for all origins (adjust in production)
methods: ['GET', 'POST'], methods: ['GET', 'POST'],
}, },
}); });
// Listen for new connections // Listen for new connections
io.on(EVENTS.connection, (socket: Socket) => { io.on(EVENTS.connection, (socket: Socket) => {
// console.log(`New client connected: ${socket.id}`); // console.log(`New client connected: ${socket.id}`);
// console.log(socket.handshake.auth); // console.log(socket.handshake.auth);
userStatus(EVENTS.connection, socket, socket.handshake.auth,io); userStatus(EVENTS.connection, socket, socket.handshake.auth,io);
// Handle all incoming events with the handleEvent function // Handle all incoming events with the handleEvent function
socket.onAny((event: string, data: any,) => { socket.onAny((event: string, data: any,) => {
cameraHandleEvent(event, socket, data,io); cameraHandleEvent(event, socket, data,io);
EnvironmentHandleEvent(event, socket, data,io); EnvironmentHandleEvent(event, socket, data,io);
floorItemsHandleEvent(event, socket, data,io); floorItemsHandleEvent(event, socket, data,io);
wallItemsHandleEvent(event, socket, data,io); wallItemsHandleEvent(event, socket, data,io);
lineHandleEvent(event, socket, data,io); lineHandleEvent(event, socket, data,io);
}); });
socket.on(EVENTS.disconnect, (reason: string) => { socket.on(EVENTS.disconnect, (reason: string) => {
// console.log(`Client disconnected: ${socket.id}, Reason: ${reason}`); // console.log(`Client disconnected: ${socket.id}, Reason: ${reason}`);
// console.log(socket.handshake.auth); // console.log(socket.handshake.auth);
userStatus(EVENTS.disconnect, socket, socket.handshake.auth,io); userStatus(EVENTS.disconnect, socket, socket.handshake.auth,io);
// Perform cleanup or other necessary actions // Perform cleanup or other necessary actions
}); });
}); });
return io; return io;
}; };

728
swagger-output.json Normal file
View 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"
}
}
}
}
}
}

View File

@@ -1,110 +1,110 @@
{ {
"compilerOptions": { "compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */ /* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */ /* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */ /* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */ // "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */ /* Modules */
"module": "commonjs", /* Specify what module code is generated. */ "module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */ // "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */ // "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */ /* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */ /* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */ // "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */ // "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */ // "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */ // "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Interop Constraints */ /* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */ /* Type Checking */
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */
} }
} }