mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-24 03:12:38 +01:00
run prettier
This commit is contained in:
parent
93219757a6
commit
f5d6394c38
@ -11,10 +11,11 @@ const __dirname = path.dirname(__filename);
|
|||||||
const compat = new FlatCompat({
|
const compat = new FlatCompat({
|
||||||
baseDirectory: __dirname,
|
baseDirectory: __dirname,
|
||||||
recommendedConfig: js.configs.recommended,
|
recommendedConfig: js.configs.recommended,
|
||||||
allConfig: js.configs.all
|
allConfig: js.configs.all,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default [{
|
export default [
|
||||||
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
"**/node_modules",
|
"**/node_modules",
|
||||||
"**/dist",
|
"**/dist",
|
||||||
@ -24,7 +25,12 @@ export default [{
|
|||||||
"**/scripts/",
|
"**/scripts/",
|
||||||
"**/assets",
|
"**/assets",
|
||||||
],
|
],
|
||||||
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), {
|
},
|
||||||
|
...compat.extends(
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
),
|
||||||
|
{
|
||||||
plugins: {
|
plugins: {
|
||||||
"@typescript-eslint": typescriptEslint,
|
"@typescript-eslint": typescriptEslint,
|
||||||
},
|
},
|
||||||
@ -44,4 +50,5 @@ export default [{
|
|||||||
"@typescript-eslint/no-require-imports": "off",
|
"@typescript-eslint/no-require-imports": "off",
|
||||||
"@typescript-eslint/no-unused-vars": "off",
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
},
|
},
|
||||||
}];
|
},
|
||||||
|
];
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": "src"
|
"path": "src",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "assets"
|
"path": "assets",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "scripts"
|
"path": "scripts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "."
|
"path": ".",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"typescript.tsdk": "util\\node_modules\\typescript\\lib"
|
"typescript.tsdk": "util\\node_modules\\typescript\\lib",
|
||||||
},
|
},
|
||||||
"launch": {
|
"launch": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": []
|
"configurations": [],
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,7 @@ export class SpacebarServer extends Server {
|
|||||||
this.app.set("json replacer", JSONReplacer);
|
this.app.set("json replacer", JSONReplacer);
|
||||||
|
|
||||||
const trustedProxies = Config.get().security.trustedProxies;
|
const trustedProxies = Config.get().security.trustedProxies;
|
||||||
if(trustedProxies)
|
if (trustedProxies) this.app.set("trust proxy", trustedProxies);
|
||||||
this.app.set("trust proxy", trustedProxies);
|
|
||||||
|
|
||||||
this.app.use(CORS);
|
this.app.use(CORS);
|
||||||
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));
|
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));
|
||||||
|
@ -89,11 +89,13 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await Sentry.startSpan( // Emma [it/its]@Rory&: is this the right function to migrate to in v8?
|
return await Sentry.startSpan(
|
||||||
|
// Emma [it/its]@Rory&: is this the right function to migrate to in v8?
|
||||||
{
|
{
|
||||||
op: "websocket.server",
|
op: "websocket.server",
|
||||||
name: `GATEWAY ${OPCODES[data.op]}`,
|
name: `GATEWAY ${OPCODES[data.op]}`,
|
||||||
attributes: { // this needs to be reworked :)
|
attributes: {
|
||||||
|
// this needs to be reworked :)
|
||||||
...data.d,
|
...data.d,
|
||||||
token: data?.d?.token ? "[Redacted]" : undefined,
|
token: data?.d?.token ? "[Redacted]" : undefined,
|
||||||
},
|
},
|
||||||
|
@ -82,7 +82,7 @@ export async function setupListener(this: WebSocket) {
|
|||||||
|
|
||||||
const opts: {
|
const opts: {
|
||||||
acknowledge: boolean;
|
acknowledge: boolean;
|
||||||
channel?: AMQChannel & { queues?: unknown, ch?: number };
|
channel?: AMQChannel & { queues?: unknown; ch?: number };
|
||||||
} = {
|
} = {
|
||||||
acknowledge: true,
|
acknowledge: true,
|
||||||
};
|
};
|
||||||
@ -91,10 +91,20 @@ export async function setupListener(this: WebSocket) {
|
|||||||
|
|
||||||
console.log("[RabbitMQ] setupListener: open for ", this.user_id);
|
console.log("[RabbitMQ] setupListener: open for ", this.user_id);
|
||||||
if (RabbitMQ.connection) {
|
if (RabbitMQ.connection) {
|
||||||
console.log("[RabbitMQ] setupListener: opts.channel = ", typeof opts.channel, "with channel id", opts.channel?.ch);
|
console.log(
|
||||||
|
"[RabbitMQ] setupListener: opts.channel = ",
|
||||||
|
typeof opts.channel,
|
||||||
|
"with channel id",
|
||||||
|
opts.channel?.ch,
|
||||||
|
);
|
||||||
opts.channel = await RabbitMQ.connection.createChannel();
|
opts.channel = await RabbitMQ.connection.createChannel();
|
||||||
opts.channel.queues = {};
|
opts.channel.queues = {};
|
||||||
console.log("[RabbitMQ] channel created: ", typeof opts.channel, "with channel id", opts.channel?.ch);
|
console.log(
|
||||||
|
"[RabbitMQ] channel created: ",
|
||||||
|
typeof opts.channel,
|
||||||
|
"with channel id",
|
||||||
|
opts.channel?.ch,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.events[this.user_id] = await listenEvent(this.user_id, consumer, opts);
|
this.events[this.user_id] = await listenEvent(this.user_id, consumer, opts);
|
||||||
@ -132,7 +142,14 @@ export async function setupListener(this: WebSocket) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.once("close", () => {
|
this.once("close", () => {
|
||||||
console.log("[RabbitMQ] setupListener: close for", this.user_id, "=", typeof opts.channel, "with channel id", opts.channel?.ch);
|
console.log(
|
||||||
|
"[RabbitMQ] setupListener: close for",
|
||||||
|
this.user_id,
|
||||||
|
"=",
|
||||||
|
typeof opts.channel,
|
||||||
|
"with channel id",
|
||||||
|
opts.channel?.ch,
|
||||||
|
);
|
||||||
if (opts.channel) opts.channel.close();
|
if (opts.channel) opts.channel.close();
|
||||||
else {
|
else {
|
||||||
Object.values(this.events).forEach((x) => x?.());
|
Object.values(this.events).forEach((x) => x?.());
|
||||||
|
@ -132,18 +132,22 @@ export class Permissions extends BitField {
|
|||||||
init?: bigint,
|
init?: bigint,
|
||||||
) {
|
) {
|
||||||
// TODO: do not deny any permissions if admin
|
// TODO: do not deny any permissions if admin
|
||||||
return overwrites.reduce((permission, overwrite) => {
|
return overwrites.reduce(
|
||||||
|
(permission, overwrite) => {
|
||||||
// apply disallowed permission
|
// apply disallowed permission
|
||||||
// * permission: current calculated permission (e.g. 010)
|
// * permission: current calculated permission (e.g. 010)
|
||||||
// * deny contains all denied permissions (e.g. 011)
|
// * deny contains all denied permissions (e.g. 011)
|
||||||
// * allow contains all explicitly allowed permisions (e.g. 100)
|
// * allow contains all explicitly allowed permisions (e.g. 100)
|
||||||
return (
|
return (
|
||||||
(permission & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow)
|
(permission & ~BigInt(overwrite.deny)) |
|
||||||
|
BigInt(overwrite.allow)
|
||||||
);
|
);
|
||||||
// ~ operator inverts deny (e.g. 011 -> 100)
|
// ~ operator inverts deny (e.g. 011 -> 100)
|
||||||
// & operator only allows 1 for both ~deny and permission (e.g. 010 & 100 -> 000)
|
// & operator only allows 1 for both ~deny and permission (e.g. 010 & 100 -> 000)
|
||||||
// | operators adds both together (e.g. 000 + 100 -> 100)
|
// | operators adds both together (e.g. 000 + 100 -> 100)
|
||||||
}, init || BigInt(0));
|
},
|
||||||
|
init || BigInt(0),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static rolePermission(roles: Role[]) {
|
static rolePermission(roles: Role[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user