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