mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 03:33:33 +01:00
🎨 clean up
This commit is contained in:
parent
a467c86399
commit
d8b01058b3
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@ -65,11 +65,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Extract version
|
||||
id: extract_version
|
||||
uses: Saionaro/extract-package-version@v1.1.1
|
||||
with:
|
||||
path: api
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: fosscord-server-windows.exe
|
||||
|
4
api/package-lock.json
generated
4
api/package-lock.json
generated
@ -43,6 +43,7 @@
|
||||
"@types/i18next-node-fs-backend": "^2.1.0",
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
"@types/mongodb": "^3.6.9",
|
||||
"@types/mongoose": "^5.10.5",
|
||||
"@types/mongoose-autopopulate": "^0.10.1",
|
||||
"@types/mongoose-lean-virtuals": "^0.5.1",
|
||||
"@types/multer": "^1.4.5",
|
||||
@ -60,7 +61,8 @@
|
||||
}
|
||||
},
|
||||
"../util": {
|
||||
"version": "1.3.55",
|
||||
"name": "@fosscord/util",
|
||||
"version": "1.0.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPLV3",
|
||||
"dependencies": {
|
||||
|
@ -27,11 +27,12 @@ declare global {
|
||||
|
||||
export async function Authentication(req: Request, res: Response, next: NextFunction) {
|
||||
if (req.method === "OPTIONS") return res.sendStatus(204);
|
||||
if (req.url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore
|
||||
const url = req.url.replace(API_PREFIX, "");
|
||||
if (url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore
|
||||
if (
|
||||
NO_AUTHORIZATION_ROUTES.some((x) => {
|
||||
if (typeof x === "string") return req.url.startsWith(x);
|
||||
return x.test(req.url);
|
||||
if (typeof x === "string") return url.startsWith(x);
|
||||
return x.test(url);
|
||||
})
|
||||
)
|
||||
return next();
|
||||
|
@ -4,7 +4,6 @@ import bcrypt from "bcrypt";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { Config, UserModel } from "@fosscord/util";
|
||||
import { adjustEmail } from "./register";
|
||||
import RateLimit from "../../middlewares/RateLimit";
|
||||
|
||||
const router: Router = Router();
|
||||
export default router;
|
||||
|
@ -33,9 +33,8 @@ async function main() {
|
||||
},
|
||||
});
|
||||
|
||||
await api.start();
|
||||
await cdn.start();
|
||||
await gateway.start();
|
||||
await Promise.all([api.start(), cdn.start(), gateway.start()]);
|
||||
console.log(`[Server] listening on port ${port}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
@ -2,6 +2,7 @@ import os from "os";
|
||||
import osu from "node-os-utils";
|
||||
|
||||
export function initStats() {
|
||||
console.log(`[Path] running in ${__dirname}`);
|
||||
console.log(`[CPU] ${osu.cpu.model()} Cores x${osu.cpu.count()}`);
|
||||
console.log(`[System] ${os.platform()} ${os.arch()}`);
|
||||
console.log(`[Database] started`);
|
||||
|
@ -211,11 +211,11 @@ export const DefaultOptions: DefaultOptions = {
|
||||
},
|
||||
webhook: {
|
||||
count: 5,
|
||||
window: 5,
|
||||
window: 20,
|
||||
},
|
||||
channel: {
|
||||
count: 5,
|
||||
window: 5,
|
||||
window: 20,
|
||||
},
|
||||
auth: {
|
||||
login: {
|
||||
|
@ -6,7 +6,7 @@ const events = new EventEmitter();
|
||||
|
||||
export async function emitEvent(payload: Omit<Event, "created_at">) {
|
||||
const id = (payload.channel_id || payload.user_id || payload.guild_id) as string;
|
||||
if (!id) console.error("event doesn't contain any id", payload);
|
||||
if (!id) return console.error("event doesn't contain any id", payload);
|
||||
|
||||
if (RabbitMQ.connection) {
|
||||
const data = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.data; // use rabbitmq for event transmission
|
||||
@ -16,7 +16,6 @@ export async function emitEvent(payload: Omit<Event, "created_at">) {
|
||||
const successful = RabbitMQ.channel?.publish(id, "", Buffer.from(`${data}`), { type: payload.event });
|
||||
if (!successful) throw new Error("failed to send event");
|
||||
} else {
|
||||
console.log("emit event", id);
|
||||
events.emit(id, payload);
|
||||
}
|
||||
}
|
||||
@ -46,10 +45,8 @@ export async function listenEvent(event: string, callback: (event: EventOpts) =>
|
||||
return rabbitListen(opts?.channel || RabbitMQ.channel, event, callback, { acknowledge: opts?.acknowledge });
|
||||
} else {
|
||||
const cancel = () => {
|
||||
console.log("cancel event", event);
|
||||
events.removeListener(event, callback);
|
||||
};
|
||||
console.log("listen event", event);
|
||||
events.addListener(event, (opts) => callback({ ...opts, cancel }));
|
||||
|
||||
return cancel;
|
||||
|
Loading…
Reference in New Issue
Block a user