Skip to content

Commit e3743c1

Browse files
author
Mohammad Ayub
committed
added basic app settings
1 parent 57b1e43 commit e3743c1

File tree

4 files changed

+579
-0
lines changed

4 files changed

+579
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

app.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const express = require("express");
2+
const mongoose = require("mongoose");
3+
const app = express();
4+
app.use(express.static("public"));
5+
app.set("view engine", "ejs");
6+
7+
// DB CONNECTION SETUP
8+
var DATABASE_URL = process.env.MONGODB_DATABASE_URL;
9+
mongoose.Promise = global.Promise;
10+
mongoose.connect(DATABASE_URL, {
11+
useNewUrlParser: true,
12+
useUnifiedTopology: true
13+
});
14+
var db = mongoose.connection;
15+
db.on('error', console.error.bind(console, 'connection error:'));
16+
db.once('open', function() {
17+
console.log("We are connected to the database!!");
18+
});
19+
20+
//SCHEMA SETUP
21+
var blogSchema = mongoose.Schema({
22+
name: String,
23+
image: String,
24+
description: String
25+
});
26+
27+
// Mongoose Model setup
28+
var Blog = mongoose.model('Blog', blogSchema);
29+
30+
// APP ROUTES
31+
app.get("/", (req, res) => {
32+
res.send("Welcome to the Blog App!!!!");
33+
});
34+
35+
// RUN APP SERVER
36+
const port = process.env.PORT || 5000;
37+
38+
app.listen(port, () => `Server running on port ${port} 🔥`);
39+
40+
41+
42+
43+
44+
45+

0 commit comments

Comments
 (0)