Spaces:
Building
Building
File size: 791 Bytes
656c481 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import express from "express";
import { homeRoute, pingRoute } from "./routes";
import bodyParser from "body-parser";
import dotenv from "dotenv";
import cors from "cors";
import { connectToWhatsApp } from "./baileys";
const app = express();
const PORT = process.env.PORT || 8080;
dotenv.config();
app.set("views", "./views");
app.set("view engine", "ejs");
app.use(cors({ origin: "*" }));
app.use(express.static("public"));
app.use(bodyParser.json({ limit: "20mb" }));
app.use(express.urlencoded({ extended: true }));
app.use(homeRoute);
app.use(pingRoute);
app.use((_, res) => {
res.status(404).json({ message: "Resource not found" });
});
(async () => {
await connectToWhatsApp();
})();
app.listen(PORT, () => {
console.log(`server is listening on localhost:${PORT}`);
});
|