-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (25 loc) · 874 Bytes
/
Copy pathapp.js
File metadata and controls
33 lines (25 loc) · 874 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
28
29
30
31
32
33
var express = require('express'),
bodyParser = require('body-parser'),
mongoose = require('mongoose'),
app = express();
mongoose.connect("mongodb://localhost/restful-blog-app");
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended: true}));
//Mongoose Model Config
var blogSchema = new mongoose.Schema({
title : String,
image: String,
body : String,
created: {type: Date, default: Date.now}
})
var Blog = mongoose.model("Blog",blogSchema);
Blog.create({
title : "Test Blog",
image: "https://images.unsplash.com/photo-1590182180713-354f28fe68c3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80",
body: "HELLO This is a blog post!"
});
// RESTful Routes
app.listen(process.env.PORT,process.env.IP,function() {
console.log("Server is running !")
})