-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
55 lines (40 loc) · 1.43 KB
/
server.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
const express = require('express');
const app = express();
const schedule = require('node-schedule');
var zipcodes = require('zipcodes');
const puppeteer = require('puppeteer');
const path = require('path');
var nodemailer = require('nodemailer');
const controller = require('./controllers/controller.js');
const routes = require('./routes/router.js');
const bodyParser = require('body-parser');
const userModel = require('./models/user.js');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use('/static', express.static('public'))
app.use(bodyParser.urlencoded({
extended: true
}));
app.use('/', routes);
// Set up mongoose connection
const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://admin:[email protected]/myFirstDatabase?retryWrites=true&w=majority', { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.Promise = global.Promise;
mongoose.set('useFindAndModify', false);
let db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
let port = process.env.PORT || 8080;
app.use(express.static(__dirname));
app.listen(port, () => {
console.log("Server Started");
userModel.updateMany(
{}, // Filter
{$set: {"status": 'stopped'}}, // Update
).then((obj) => {
console.log('All Searches Stoped');
})
.catch((err) => {
console.log('Error: ' + err);
})
})