Compare commits
4 Commits
2a2df58b7d
...
wisdom
| Author | SHA1 | Date | |
|---|---|---|---|
| 47c99c878a | |||
| 436ea1cf89 | |||
| 8e0dc4bb88 | |||
| b680a249d5 |
14
.env.example
14
.env.example
@@ -45,4 +45,18 @@ IMAGEKIT_PRIVATE_KEY=private_vhO/jXHnEoaVYptOHIuZDPMbxIA=
|
|||||||
# CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
|
# CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
# REFRESH_TOKEN=1//XXXXXXXX
|
# REFRESH_TOKEN=1//XXXXXXXX
|
||||||
|
|
||||||
|
ENDPOINT_WHATSAPP=https://117.102.231.130:9531/send
|
||||||
|
# ENDPOINT_WHATSAPP=http://localhost:9529/send
|
||||||
|
|
||||||
|
# ENDPOINT_FE=http://localhost:8592
|
||||||
|
# ENDPOINT_FE=http://203.153.114.226:8466
|
||||||
|
ENDPOINT_FE=https://117.102.231.130:9529
|
||||||
|
|
||||||
|
|
||||||
|
# MQTT Connection
|
||||||
|
MQTT_HOST=ws://117.102.231.130:7001
|
||||||
|
MQTT_USERNAME=morekmorekmorek
|
||||||
|
MQTT_PASSWORD=morek888
|
||||||
|
TOPIC_COD=PIU_COD/ERROR_CODE
|
||||||
|
|
||||||
VITE_KEY_SESSION=PetekRombonganPetekMorekMorakMarek
|
VITE_KEY_SESSION=PetekRombonganPetekMorekMorakMarek
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,4 +4,3 @@ node_modules
|
|||||||
request.http
|
request.http
|
||||||
*.rest
|
*.rest
|
||||||
package-lock.json
|
package-lock.json
|
||||||
*.log
|
|
||||||
@@ -292,11 +292,11 @@ const mqttOptions = {
|
|||||||
clientId: 'express_mqtt_client_' + Math.random().toString(16).substr(2, 8),
|
clientId: 'express_mqtt_client_' + Math.random().toString(16).substr(2, 8),
|
||||||
clean: true,
|
clean: true,
|
||||||
connectTimeout: 4000,
|
connectTimeout: 4000,
|
||||||
username: '', // jika ada
|
username: process.env.MQTT_USERNAME ?? 'morekmorekmorek', // jika ada
|
||||||
password: '', // jika ada
|
password: process.env.MQTT_PASSWORD ?? 'morek888', // jika ada
|
||||||
};
|
};
|
||||||
|
|
||||||
const mqttUrl = 'ws://localhost:1884'; // Ganti dengan broker kamu
|
const mqttUrl = process.env.MQTT_HOST; // Ganti dengan broker kamu
|
||||||
const topic = process.env.TOPIC_COD ?? 'morek';
|
const topic = process.env.TOPIC_COD ?? 'morek';
|
||||||
|
|
||||||
const mqttClient = mqtt.connect(mqttUrl, mqttOptions);
|
const mqttClient = mqtt.connect(mqttUrl, mqttOptions);
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ class AuthController {
|
|||||||
const bytes = CryptoJS.AES.decrypt(tokenRedirect, process.env.VITE_KEY_SESSION);
|
const bytes = CryptoJS.AES.decrypt(tokenRedirect, process.env.VITE_KEY_SESSION);
|
||||||
const decrypted = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
const decrypted = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
||||||
|
|
||||||
|
console.log("decrypted: ", decrypted);
|
||||||
|
|
||||||
const userPhone = decrypted?.user_phone
|
const userPhone = decrypted?.user_phone
|
||||||
const userName = decrypted?.user_name
|
const userName = decrypted?.user_name
|
||||||
const idData = decrypted?.id
|
const idData = decrypted?.id
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ const getAllNotificationDb = async (searchParams = {}) => {
|
|||||||
],
|
],
|
||||||
queryParams
|
queryParams
|
||||||
);
|
);
|
||||||
if (whereParamAnd) queryParams = whereParamAnd;
|
|
||||||
|
queryParams = whereParamAnd ? whereParamAnd : queryParams;
|
||||||
|
|
||||||
const queryText = `
|
const queryText = `
|
||||||
SELECT
|
SELECT
|
||||||
@@ -108,12 +109,12 @@ const getAllNotificationDb = async (searchParams = {}) => {
|
|||||||
a.is_delivered,
|
a.is_delivered,
|
||||||
a.is_read,
|
a.is_read,
|
||||||
a.is_active,
|
a.is_active,
|
||||||
|
a.created_at,
|
||||||
|
|
||||||
b.error_code,
|
b.error_code,
|
||||||
b.error_code_name,
|
b.error_code_name,
|
||||||
b.error_code_color,
|
b.error_code_color,
|
||||||
b.path_icon,
|
b.path_icon,
|
||||||
b.created_at,
|
|
||||||
|
|
||||||
c.solution_name,
|
c.solution_name,
|
||||||
c.type_solution,
|
c.type_solution,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
apps: [
|
apps: [
|
||||||
{
|
{
|
||||||
name: "cod-api",
|
name: "bengkel-api",
|
||||||
script: "./index.js", // Path to your entry file
|
script: "./index.js", // Path to your entry file
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: "development",
|
NODE_ENV: "development",
|
||||||
@@ -9,14 +9,6 @@ module.exports = {
|
|||||||
env_production: {
|
env_production: {
|
||||||
NODE_ENV: "production",
|
NODE_ENV: "production",
|
||||||
},
|
},
|
||||||
// Logging configuration
|
|
||||||
// error_file: "C:\IDETAMA\pm2-log\cod-api\cod-api-error.log",
|
|
||||||
// out_file: "C:\IDETAMA\pm2-log\cod-api\cod-api-out.log",
|
|
||||||
// log_file: "C:\IDETAMA\pm2-log\cod-api\cod-api-combined.log", // optional combined file
|
|
||||||
error_file: "cod-api-error.log",
|
|
||||||
out_file: "cod-api-out.log",
|
|
||||||
log_file: "cod-api-combined.log", // optional combined file
|
|
||||||
time: true, // adds timestamps to logs
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -173,8 +173,7 @@ class NotificationService {
|
|||||||
|
|
||||||
static async resendNotification(id) {
|
static async resendNotification(id) {
|
||||||
const deviceNotification = await getNotificationByIdDb(id);
|
const deviceNotification = await getNotificationByIdDb(id);
|
||||||
if (!deviceNotification)
|
if (!deviceNotification) throw new ErrorHandler(404, "Data not found");
|
||||||
throw new ErrorHandler(404, "Notification Data not found");
|
|
||||||
|
|
||||||
const errorCode = await getErrorCodeByIdDb(
|
const errorCode = await getErrorCodeByIdDb(
|
||||||
deviceNotification.error_code_id
|
deviceNotification.error_code_id
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ class NotifikasiWaService {
|
|||||||
for (const dataUser of dataUsers) {
|
for (const dataUser of dataUsers) {
|
||||||
if (dataUser.is_active) {
|
if (dataUser.is_active) {
|
||||||
const tokenRedirect = await generateTokenRedirect(
|
const tokenRedirect = await generateTokenRedirect(
|
||||||
dataUser.userPhone,
|
dataUser.contact_phone,
|
||||||
dataUser.userName,
|
dataUser.contact_name,
|
||||||
resultNotificationError.notification_error_id
|
resultNotificationError.notification_error_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -105,6 +105,8 @@ class NotifikasiWaService {
|
|||||||
param.bodyMessage
|
param.bodyMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("resultSend: ", resultSend);
|
||||||
|
|
||||||
await updateNotificationErrorUserDb(
|
await updateNotificationErrorUserDb(
|
||||||
resultNotificationErrorUser[0].notification_error_user_id,
|
resultNotificationErrorUser[0].notification_error_user_id,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user