error fix
This commit is contained in:
@@ -4,8 +4,6 @@ const database = require('./helper/database');
|
|||||||
var MongoClient = require ('mongodb').MongoClient;
|
var MongoClient = require ('mongodb').MongoClient;
|
||||||
var ObjectID = require ('mongodb').ObjectID;
|
var ObjectID = require ('mongodb').ObjectID;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var datetime = require('node-datetime');
|
|
||||||
var http = require('http');
|
|
||||||
|
|
||||||
|
|
||||||
MongoClient.connect(config.databaseURL).then(mongoDatabase => {
|
MongoClient.connect(config.databaseURL).then(mongoDatabase => {
|
||||||
@@ -28,33 +26,36 @@ MongoClient.connect(config.databaseURL).then(mongoDatabase => {
|
|||||||
config.words = config.words.map(word=>{
|
config.words = config.words.map(word=>{
|
||||||
return word.toLowerCase();
|
return word.toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let getDomainListPromises = [];
|
||||||
|
|
||||||
config.domainList.map(url=>{
|
config.domainList.map(url=>{
|
||||||
links.getDomainList(url).then(res=>{
|
let p = links.getDomainList(url).then(res=>{
|
||||||
database.insertTodayDomains(db,res).then(()=>{
|
console.log("One promise done");
|
||||||
database.getYesterdayDomains(db).then((result)=>{
|
let p2 = database.insertTodayDomains(db,res).then(()=>{
|
||||||
|
let p3 = database.getYesterdayDomains(db).then((result)=>{
|
||||||
|
|
||||||
result.map((domain)=>{
|
result.map((domain)=>{
|
||||||
db.collection('today').findOne({domainName:domain.domainName}, (err,result)=>{
|
getDomainListPromises.push(database.cleanExpired(db,domain));
|
||||||
if ((result===null) &&(datetime.create().format('Y-m-d')===domain.expirationDate)){
|
|
||||||
db.collection('expired_list').insert(domain);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
database.getExpiredDomains(db).then((result)=>{
|
|
||||||
links.checkExpiredDomains(db,result).then(()=>{
|
|
||||||
console.log("Done");
|
|
||||||
db.close();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}).catch((e)=>{
|
}).catch((e)=>{
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
getDomainListPromises.push(p3);
|
||||||
});
|
});
|
||||||
});
|
getDomainListPromises.push(p2);
|
||||||
|
});
|
||||||
|
getDomainListPromises.push(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.all(getDomainListPromises).then(()=>{
|
||||||
|
console.log("All promises done");
|
||||||
|
database.getExpiredDomains(db).then((result)=>{
|
||||||
|
links.checkExpiredDomains(db,result).then(()=>{
|
||||||
|
db.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
var datetime = require('node-datetime');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
insertTodayDomains : function (db, domains){
|
insertTodayDomains : function (db, domains){
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
@@ -13,6 +15,21 @@ module.exports = {
|
|||||||
|
|
||||||
getExpiredDomains : function (db){
|
getExpiredDomains : function (db){
|
||||||
return getArrayFromDatabase(db, 'expired_list');
|
return getArrayFromDatabase(db, 'expired_list');
|
||||||
|
},
|
||||||
|
|
||||||
|
cleanExpired : function (db, domain){
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
db.collection('today').findOne({domainName:domain.domainName}, (err,result)=>{
|
||||||
|
if (err){
|
||||||
|
reject(err);
|
||||||
|
}else{
|
||||||
|
if ((result===null) &&(datetime.create().format('Y-m-d')===domain.expirationDate)){
|
||||||
|
db.collection('expired_list').insert(domain);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const config = require('../config');
|
|||||||
const https = require("https");
|
const https = require("https");
|
||||||
const punycode = require('punycode');
|
const punycode = require('punycode');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var http = require('http');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getDomainList : function(url){
|
getDomainList : function(url){
|
||||||
|
|||||||
@@ -19,25 +19,28 @@ class DomainList extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<ReactTable
|
<div>
|
||||||
data = {this.state.domains}
|
<ReactTable
|
||||||
columns={[
|
data = {this.state.domains}
|
||||||
{
|
columns={[
|
||||||
Header: 'Domain name',
|
{
|
||||||
accessor: 'domainName',
|
Header: 'Domain name',
|
||||||
},
|
accessor: 'domainName',
|
||||||
{
|
},
|
||||||
Header: 'TLD domain',
|
{
|
||||||
accessor: 'tld',
|
Header: 'TLD domain',
|
||||||
},
|
accessor: 'tld',
|
||||||
{
|
},
|
||||||
Header: 'Expiration date',
|
{
|
||||||
accessor: 'expirationDate',
|
Header: 'Expiration date',
|
||||||
}
|
accessor: 'expirationDate',
|
||||||
]}
|
}
|
||||||
defaultPageSize={10}
|
]}
|
||||||
className="-striped -highlight"
|
defaultPageSize={10}
|
||||||
/>
|
className="-striped -highlight"
|
||||||
|
/>
|
||||||
|
<h3> Total : {this.state.domains.length} </h3>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user