cuy-cli 3.0.0 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/database.js +4 -3
- package/bin/index.js +2 -2
- package/package.json +1 -1
package/bin/database.js
CHANGED
@@ -7,11 +7,12 @@ 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
|
-
|
11
|
-
|
12
|
-
|
10
|
+
ssl: {
|
11
|
+
ca: fs.readFileSync(__dirname + '/ca-certificate.crt')
|
12
|
+
}
|
13
13
|
});
|
14
14
|
conn.connect(function (err) {
|
15
15
|
if (err) conn.destroy();
|
16
|
+
console.info('connected');
|
16
17
|
});
|
17
18
|
module.exports = conn;
|
package/bin/index.js
CHANGED
@@ -57,7 +57,7 @@ const cuyPost = (data) => {
|
|
57
57
|
console.warn('Maaf, saat ini data yang anda masukan tidak dapat kami proses.')
|
58
58
|
return db.destroy();
|
59
59
|
}
|
60
|
-
if (rows
|
60
|
+
if (!err && rows.length > 0) {
|
61
61
|
const { username, id } = rows[0]
|
62
62
|
db.query(`INSERT INTO posts (description, hashtag, author, user_id, created_at, updated_at) VALUES ('${data.description}', '${data.hashtag.replaceAll(' ', '')}', '${username}', '${id}', '${now}', '${now}')`, (err, rows) => {
|
63
63
|
if (!err) {
|
@@ -78,7 +78,7 @@ 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
|
-
if (rows
|
81
|
+
if (!err && rows.length > 0) {
|
82
82
|
last_seen = rows[0].last_seen
|
83
83
|
if (last_seen == null) {
|
84
84
|
console.info(`${username} belum pernah login`);
|