-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (26 loc) · 907 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @fileoverview Entry point for your Express application.
* @module index
* @requires dotenv
* @requires ./config/env.config
* @requires express
* @requires cors
* @requires ./config/mongoose.config
* @requires ./routes/your_model_name.routes
*/
// Load environment variables from .env file
require("dotenv").config();
// Configuration for environment variables
const env = require("./config/env.config");
// Import required modules
const express = require("express");
const app = express();
const cors = require("cors");
// Configure Express middleware
app.use(cors(), express.json(), express.urlencoded({ extended: true }));
// Connect to MongoDB using Mongoose
require("./config/mongoose.config");
// Set up routes for your model
require("./routes/your_model_name.routes")(app);
// Start the Express server
app.listen(env.PORT, () => console.log(`Listening on port ${env.PORT}...`));