-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 692 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (22 loc) · 692 Bytes
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
// const express = require("express");
//"type":"module", in package.json to use import statement
import express from 'express';
import mongoose from 'mongoose';
//Importing the contact model
import {connectDB} from './config/database.js';
//creating port variaable
const PORT = process.env.PORT;
const app = express();
//Database connection
connectDB();
//Importing router files
import contactRoutes from './routes/contacts.routes.js';
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
//MIddle ware
app.set('view engine','ejs');
app.use(express.urlencoded({ extended: true }));
app.use(express.static('public'));
//Routes
app.use("/",contactRoutes);