-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
76 lines (64 loc) · 1.67 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
71
72
73
74
75
/**
* 测试文件, 之后会删除
*/
const fs = require('fs/promises');
const path = require('path');
const axios = require('axios');
const dlcfg = require('./src/downloader-manager');
// const dlmg = dlcfg('./downloader');
const StorageManager = require('./src/storage-manager')('./storage');
const DBConfiger = require('./src/data-manager');
const DBManager = DBConfiger('./data-base');
const dl = require('./downloader/downloader-1');
const cheerio = require('cheerio');
function delay(timeout) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(timeout);
resolve(0);
}, timeout);
});
}
const downloadURL = 'https://zha.qqhentai.com/g/380744/';
async function test (url) {
const id = 351786;
const storage = StorageManager.new(id);
const manhuaDB = DBManager('manhua');
let data = {};
const db = {
save (_data) {
data = _data;
}
};
const client = {
send (msg) {
console.log(msg);
}
}
dl.download(url, db, storage, client);
manhuaDB.insert(data);
}
async function get(url) {
return await axios.get(url);
}
async function post(url) {
return await axios.post(url);
}
(async () => {
// const $ = cheerio.load(page);
const origin = (path) => 'http://127.0.0.1:3000/' + (path || '');
// const wsP = post(origin('ws'));
const aP = axios.get(origin('index.html'));
const adata = (await aP).data;
console.log(adata);
// const wsData = (await wsP).data;
// console.log(wsData);
});
async function test() {
console.log('test start');
await (new Promise((res, rej) => setTimeout(() => {
res(0);
}, 1000)));
console.log('test end');
}
// const server = require('./src/server');