From ae22d37e7ac608926fba257eb2a3a57936028984 Mon Sep 17 00:00:00 2001 From: shwtea <shwetagupta0711754@gmail.com> Date: Fri, 6 Sep 2024 11:47:18 +0530 Subject: [PATCH] working --- .env | 4 ++++ api/models/template.js | 5 +++++ package.json | 1 + server.js | 9 +++++---- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..be82493 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +NODE_ENV=development +SERVICE_BASE_URL=https://30dd-206-84-239-127.ngrok-free.app +SERVICE_PORT=5000 +LOG_LEVEL=debug diff --git a/api/models/template.js b/api/models/template.js index 98426ca..d1de027 100644 --- a/api/models/template.js +++ b/api/models/template.js @@ -13,6 +13,11 @@ const WidgetRefSchema = new Schema({ const TemplateSchema = new Schema({ name: { type: String, required: true }, desc: { type: String }, + platform: { + type: String, + enum: ['web', 'mobile', 'both'], + required: true + }, widgets: [WidgetRefSchema], hashId: { type: String, unique: true, required: true }, createdAt: { type: Date, default: Date.now }, diff --git a/package.json b/package.json index 67e81ce..0e24b61 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.20.2", + "dotenv": "^16.4.5", "express": "^4.19.2", "mongoose": "^8.6.0", "nodemon": "^3.1.4", diff --git a/server.js b/server.js index 524f6cb..f8fe990 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -// server.js +require('dotenv').config(); const express = require('express'); const bodyParser = require('body-parser'); const swaggerUi = require('swagger-ui-express'); @@ -19,10 +19,11 @@ app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); // API base URL app.use(apiBaseRouter); - // Start the server -const PORT = process.env.PORT || 5000; +const PORT = process.env.SERVICE_PORT || 5000; +const BASE_URL = process.env.SERVICE_BASE_URL || `http://localhost:${PORT}`; + app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); - console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`); + console.log(`Swagger UI available at ${BASE_URL}/api-docs`); }); -- GitLab