-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
71 lines (51 loc) · 1.44 KB
/
test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var http = require('http');
var express = require('express');
const mongo = require('mongoose');
const blogModel = require('./blog');
var name = (cool) =>
{
console.log(cool);
return cool;
}
let val = name("hello");
// setTimeout(()=>{
// console.log('In the timeout');
// }, 3000);
// const v = setInterval(()=>
// {
// console.log("in the interval");
// }, 1500);
// const server = http.createServer((req , res) =>
// {
// console.log("BACKEND IS WORKING, hello ");
// res.setHeader('Content-Type','text/plain');
// res.write('Cool');
// res.end();
// });
const app = express();
const dbURL = "mongodb+srv://test-user-sagnik:12345@cluster0.2j5oc.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
mongo.connect(dbURL,{ useNewUrlParser : true , useUnifiedTopology : true })
.then((result) => console.log(" CONNECTED TO DATABASE ") )
.catch( (err) => console.log(err) );
app.get('/about',(req,res) => {
// res.sendFile('/pages/backendPage.html',{ root : __dirname });
const blog = new blogModel(
{
title : 'IEMA R&D',
description : 'An Incredible Private Corporation'
}
)
blog.save().then(
(result) => {
res.send(result)
}
).catch(
(Err) => {
console.log(Err);
}
);
})
app.listen(3000);
// server.listen(3000,'localhost',() => {
// console.log("listening to server at 3000");
// });