-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (35 loc) · 996 Bytes
/
index.js
File metadata and controls
39 lines (35 loc) · 996 Bytes
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
const log = require('./log');
const settings = require('./settings');
const utilSQL = require('./mysql/util');
const util = require('./util');
var link = process.argv.slice(2);
var uuid = util.createUUID();
var key;
main();
function main() {
utilSQL.getData(link, (error, data) => {
if(error) throw error;
key = data;
});
setTimeout(() => {
if(key != null) {
log.error('This link already shorted: ' + settings.websiteLink + key);
process.exit();
return;
}
if(!util.checkLink(link)) {
log.error('Link as wrong, please check link.');
process.exit();
return;
}
short();
process.exit();
}, 400);
}
function short() {
var shortedLink = settings.websiteLink + uuid;
utilSQL.setData(uuid, link);
log.success('Link successfully shorted: ' + shortedLink);
util.copyString(shortedLink);
log.success('Link copied to clipboard.');
}