forked from This-is-Ayush-Sharma/url-shortner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (19 loc) · 664 Bytes
/
server.js
File metadata and controls
25 lines (19 loc) · 664 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
const express = require('express');
const app = express();
const path = require('path');
const cors = require('cors');
const routes = require('./routes/routes');
const bodyParser = require('body-parser');
const { dbConnection } = require('./config/db');
require('dotenv').config();
// Serve static files from the "public" directory
app.use(express.static(path.join(__dirname, 'public')));
app.set('view engine', 'ejs');
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
app.use('/', routes);
app.listen(process.env.PORT, ()=>{
dbConnection();
console.log(`app is running on port ${process.env.PORT}`);
});