add more error codes
All checks were successful
Build SMS Gateway / Build image (push) Successful in 15s
All checks were successful
Build SMS Gateway / Build image (push) Successful in 15s
This commit is contained in:
@@ -43,16 +43,16 @@ function writeMessages(messages) {
|
||||
}
|
||||
|
||||
// POST /send-msg - receive and log SMS
|
||||
router.post("/send-msg", (req, res) => {
|
||||
router.post("/send", (req, res) => {
|
||||
const { login, psw, phones, mes } = req.body;
|
||||
|
||||
if (!login || !psw || !phones || !mes) {
|
||||
return res.status(400).json({ error: "Missing required parameters" });
|
||||
return res.json({ error: "Отсутствуют обязательные параметры", error_code: 1 });
|
||||
}
|
||||
|
||||
// Validate credentials
|
||||
if (login !== AUTH_LOGIN || psw !== AUTH_PASSWORD) {
|
||||
return res.status(401).json({ error: "Invalid credentials" });
|
||||
return res.json({ error: "Ошибка авторизации", error_code: 2 });
|
||||
}
|
||||
|
||||
const message = {
|
||||
@@ -69,7 +69,7 @@ router.post("/send-msg", (req, res) => {
|
||||
|
||||
console.log(`[${message.timestamp}] SMS to ${phones}: ${mes}`);
|
||||
|
||||
res.json({ status: "ok", id: message.id });
|
||||
res.json({ id: message.id, cnt: 1 });
|
||||
});
|
||||
|
||||
// GET /view-all-sms - view all logged messages
|
||||
|
||||
Reference in New Issue
Block a user