optimizations
This commit is contained in:
16
index.js
16
index.js
@ -27,15 +27,15 @@ app.use(cookieParser());
|
||||
app.use(express.json({ limit: "10mb" }));
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(express.text());
|
||||
app.use("/", (req, res, next) => {
|
||||
next();
|
||||
});
|
||||
// app.use("/", (req, res, next) => {
|
||||
// next();
|
||||
// });
|
||||
// setInterval(()=>{
|
||||
|
||||
// }, 1000)
|
||||
import WebSocket, { WebSocketServer } from "ws";
|
||||
const wss = new WebSocketServer({ noServer: true });
|
||||
let openSockets = 0;
|
||||
// let openSockets = 0;
|
||||
wss.on("connection", function connection(ws, req, res) {
|
||||
ws.send(`online=${wss.clients.size}`);
|
||||
setInterval(() => {
|
||||
@ -125,7 +125,7 @@ app.post("/api/account/upload", async (req, res, next) => {
|
||||
res.status(400).send(status);
|
||||
}
|
||||
} else {
|
||||
return "KILL YOURSELF";
|
||||
// return "KILL YOURSELF";
|
||||
}
|
||||
});
|
||||
|
||||
@ -243,14 +243,12 @@ app.use("/data/:id/:file", async (req, res) => {
|
||||
const filePath = path.join(process.env.DATA_PATH, "data", id, file);
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
|
||||
const image = await fs.readFile(filePath);
|
||||
if (mime.lookup(filePath) == "image/webp") {
|
||||
res.type("image/webp");
|
||||
res.status(200).send(image);
|
||||
res.status(200).send(await fs.readFile(filePath));
|
||||
} else if (mime.lookup(filePath) == "audio/ogg") {
|
||||
res.type("audio/ogg");
|
||||
res.status(200).send(image);
|
||||
res.status(200).send(await fs.readFile(filePath));
|
||||
} else {
|
||||
res.status(404).send("File not found");
|
||||
}
|
||||
|
||||
@ -2,4 +2,8 @@ module.exports = {
|
||||
name: "Selenite", // Name of your application
|
||||
script: "index.js", // Entry point of your application
|
||||
interpreter: "bun", // Path to the Bun interpreter
|
||||
watch: true,
|
||||
cron_restart: '0 0 * * *',
|
||||
instances : "max",
|
||||
exec_mode : "cluster"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user