Jump to content
Bicrypto v4.5.0 + All Plugins

Anmol Ind

Members
  • Last visited

  • Posts

    1
  • Reputation

    0
  1. Node server not connaction and Qr alson not shoing and othser screenshots attaced my server.js 'use strict'; const wa = require("./server/whatsapp"); const fs = require("fs"); const dbs = require('./server/database/index'); require("dotenv").config(); const lib = require("./server/lib"); global.log = lib.log; /** * EXPRESS FOR ROUTING */ const express = require("express"); const app = express(); /** * HTTPS CONFIGURATION */ const https = require("https"); const privateKey = fs.readFileSync('mydomain/key.pem'); const certificate = fs.readFileSync('mydoinin/cert.pem'); const ca = fs.readFileSync('whatsapp.anmoll.in/csr.pem'); const credentials = { key: privateKey, cert: certificate, ca: ca }; const server = https.createServer(credentials, app); /** * SOCKET.IO */ const { Server } = require("socket.io"); const io = new Server(server, { pingInterval: 25000, pingTimeout: 10000, }); const port = process.env.PORT_NODE; app.use((req, res, next) => { res.set("Cache-Control", "no-store"); req.io = io; next(); }); const bodyParser = require("body-parser"); app.use( bodyParser.urlencoded({ extended: false, limit: "50mb", parameterLimit: 100000, }) ); app.use(bodyParser.json()); app.use(express.static("src/public")); app.use(require("./server/router")); io.on("connection", (socket) => { console.log("A user connected"); socket.on("StartConnection", (data) => { wa.connectToWhatsApp(data, io); }); socket.on("ConnectViaCode", (data) => { wa.connectToWhatsApp(data, io, true); }); socket.on("LogoutDevice", (device) => { wa.deleteCredentials(device, io); }); socket.on("disconnect", () => { console.log("A user disconnected"); }); }); server.listen(port, () => { console.log(`Server running and listening on port: ${port}`); }); dbs.db.query("SELECT * FROM devices WHERE status = 'Connected'", (err, results) => { if (err) { console.error('Error executing query:', err); } results.forEach(row => { const number = row.body; if (/^\d+$/.test(number)) { wa.connectToWhatsApp(number); } }); });