Fix: Todo Multi refresh ...
fix some promises problem
This commit is contained in:
@@ -11,6 +11,7 @@ const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const path = require('path');
|
||||
|
||||
|
||||
i18n = require("i18n");
|
||||
|
||||
if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')) {
|
||||
@@ -42,6 +43,8 @@ console.log("MONGODB_URI: " + process.env.MONGODB_URI);
|
||||
|
||||
var app = express();
|
||||
|
||||
const tools = require('./tools/general');
|
||||
|
||||
// app.use(express.static(path.join(__dirname, 'client')));
|
||||
|
||||
app.use(bodyParser.json());
|
||||
@@ -66,7 +69,6 @@ app.use(bodyParser.json());
|
||||
app.use(i18n.init);
|
||||
|
||||
|
||||
|
||||
// Use Routes
|
||||
app.use('/', index_router);
|
||||
app.use('/subscribe', subscribe_router);
|
||||
@@ -91,7 +93,7 @@ if (app.get('env') === 'development') {
|
||||
app.use(function (err, req, res, next) {
|
||||
console.log('Error: ', err.message);
|
||||
// console.trace();
|
||||
res.status(err.status || 500).send({error: err.message});
|
||||
res.status(err.status || 500).send({ error: err.message });
|
||||
// res.render('error', {
|
||||
// message: err.message,
|
||||
// error: err
|
||||
@@ -109,6 +111,27 @@ if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')
|
||||
httpServer.listen(port);
|
||||
}
|
||||
|
||||
testmsgwebpush();
|
||||
|
||||
function testmsgwebpush() {
|
||||
var { User } = require('./models/user');
|
||||
// const tools = require('./tools/general');
|
||||
|
||||
User.findOne().then((user) => {
|
||||
if (user !== null) {
|
||||
tools.sendNotificationToUser(user._id, 'Titolo msg Test', 'Test Messaggio', '/', 'msg')
|
||||
.then(ris => {
|
||||
if (ris) {
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//app.listen(port, () => {
|
||||
// console.log(`Server started at port ${port}`);
|
||||
//});
|
||||
|
||||
Reference in New Issue
Block a user