cuy-cli 3.0.3 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/database.js +7 -4
- package/bin/index.js +10 -8
- package/package.json +1 -1
package/bin/database.js
CHANGED
@@ -7,12 +7,15 @@ var conn = mysql.createConnection({
|
|
7
7
|
password: process.env.DB_PASSWORD,
|
8
8
|
database: process.env.DB_DATABASE,
|
9
9
|
port: process.env.DB_PORT,
|
10
|
-
ssl: {
|
11
|
-
|
12
|
-
}
|
10
|
+
// ssl: {
|
11
|
+
// ca: fs.readFileSync(__dirname + '/ca-certificate.crt')
|
12
|
+
// }
|
13
13
|
});
|
14
14
|
conn.connect(function (err) {
|
15
|
-
if (err)
|
15
|
+
if (err) return console.log('err conn', err)
|
16
16
|
console.info('connected');
|
17
17
|
});
|
18
|
+
|
19
|
+
|
20
|
+
|
18
21
|
module.exports = conn;
|
package/bin/index.js
CHANGED
@@ -44,18 +44,18 @@ const search = [
|
|
44
44
|
const cuyPost = (data) => {
|
45
45
|
if (data.description.length < 8 || data.description.length > 100) {
|
46
46
|
console.log('deskripsi terlalu panjang! min:8 max:100');
|
47
|
-
return db.destroy();
|
47
|
+
// return db.destroy();
|
48
48
|
}
|
49
49
|
|
50
50
|
if (data.hashtag.length < 2 || data.hashtag.length > 20) {
|
51
51
|
console.log('hashtag terlalu panjang! min:2 max:20');
|
52
|
-
return db.destroy();
|
52
|
+
// return db.destroy();
|
53
53
|
}
|
54
54
|
|
55
55
|
db.query(`SELECT * from users where secret='${data.secret}' AND cuycli=1`, (err, rows) => {
|
56
56
|
if (err) {
|
57
57
|
console.warn('Maaf, saat ini data yang anda masukan tidak dapat kami proses.')
|
58
|
-
return db.destroy();
|
58
|
+
// return db.destroy();
|
59
59
|
}
|
60
60
|
if (!err && rows.length > 0) {
|
61
61
|
const { username, id } = rows[0]
|
@@ -63,10 +63,10 @@ const cuyPost = (data) => {
|
|
63
63
|
if (!err) {
|
64
64
|
if (rows != null) {
|
65
65
|
console.info(`congrats ${username} :) anda berhasil membuat postingan baru. silahkan cek di https://cuyuniverse.co`);
|
66
|
-
db.destroy();
|
66
|
+
// db.destroy();
|
67
67
|
} else {
|
68
68
|
console.log('Terjadi kesalahan, saat ini anda tidak dapat membuat postingan via cuycli. Coba lagi nanti!');
|
69
|
-
db.destroy();
|
69
|
+
// db.destroy();
|
70
70
|
}
|
71
71
|
} else {
|
72
72
|
console.warn('Maaf, saat ini data yang anda masukan tidak dapat kami proses.')
|
@@ -78,19 +78,21 @@ const cuyPost = (data) => {
|
|
78
78
|
|
79
79
|
const lastSeen = ({ username }) => {
|
80
80
|
db.query(`select last_seen from users where username='${username}'`, (err, rows) => {
|
81
|
+
console.log('error: ', err)
|
82
|
+
console.log('rowsss: ', rows)
|
81
83
|
if (!err && rows.length > 0) {
|
82
84
|
last_seen = rows[0].last_seen
|
83
85
|
if (last_seen == null) {
|
84
86
|
console.info(`${username} belum pernah login`);
|
85
|
-
db.destroy();
|
87
|
+
// db.destroy();
|
86
88
|
} else {
|
87
89
|
console.info(`${username} terahir terlihat pada ${last_seen}`);
|
88
|
-
db.destroy();
|
90
|
+
// db.destroy();
|
89
91
|
}
|
90
92
|
}
|
91
93
|
else {
|
92
94
|
console.warn('Maaf, saat ini data yang anda masukan tidak dapat kami proses.')
|
93
|
-
return db.destroy();
|
95
|
+
// return db.destroy();
|
94
96
|
}
|
95
97
|
})
|
96
98
|
}
|