Skip to content

Commit

Permalink
Merge pull request #1236 from dank074/patch/prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyUnderStars authored Nov 20, 2024
2 parents 9321975 + f5d6394 commit 43b342a
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 128 deletions.
69 changes: 38 additions & 31 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,46 @@ import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [{
ignores: [
"**/node_modules",
"**/dist",
"**/README.md",
"**/COPYING",
"src/webrtc",
"**/scripts/",
"**/assets",
],
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), {
plugins: {
"@typescript-eslint": typescriptEslint,
},
export default [
{
ignores: [
"**/node_modules",
"**/dist",
"**/README.md",
"**/COPYING",
"src/webrtc",
"**/scripts/",
"**/assets",
],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
globals: {
...globals.node,
},
languageOptions: {
globals: {
...globals.node,
},

parser: tsParser,
},
parser: tsParser,
},

rules: {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": "off",
},
}];
rules: {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": "off",
},
},
];
118 changes: 59 additions & 59 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions server.code-workspace
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"folders": [
{
"path": "src"
"path": "src",
},
{
"path": "assets"
"path": "assets",
},
{
"path": "scripts"
"path": "scripts",
},
{
"path": "."
}
"path": ".",
},
],
"settings": {
"typescript.tsdk": "util\\node_modules\\typescript\\lib"
"typescript.tsdk": "util\\node_modules\\typescript\\lib",
},
"launch": {
"version": "0.2.0",
"configurations": []
}
"configurations": [],
},
}
3 changes: 1 addition & 2 deletions src/api/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export class SpacebarServer extends Server {
this.app.set("json replacer", JSONReplacer);

const trustedProxies = Config.get().security.trustedProxies;
if(trustedProxies)
this.app.set("trust proxy", trustedProxies);
if (trustedProxies) this.app.set("trust proxy", trustedProxies);

this.app.use(CORS);
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/auth/generate-registration-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ router.get(
`${Config.get().general.frontPage}/register?token=${
x.token
}`,
)
)
: tokens.map((x) => x.token);

if (req.query.plain) return res.send(ret.join("\n"));
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/channels/#channel_id/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ router.post(
? Member.update(
{ id: req.user_id, guild_id: message.guild_id },
{ last_message_id: message.id },
)
)
: null,
channel.save(),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/channels/#channel_id/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ router.post(
...member,
roles: member?.roles?.map((x) => x.id),
},
}
}
: null),
channel_id,
timestamp,
Expand Down
8 changes: 4 additions & 4 deletions src/api/routes/discoverable-guilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ router.get(
guilds = showAllGuilds
? await Guild.find({
take: Math.abs(Number(limit || configLimit)),
})
})
: await Guild.find({
where: { features: Like(`%DISCOVERABLE%`) },
take: Math.abs(Number(limit || configLimit)),
});
});
} else {
guilds = showAllGuilds
? await Guild.find({
where: { primary_category_id: categories.toString() },
take: Math.abs(Number(limit || configLimit)),
})
})
: await Guild.find({
where: {
primary_category_id: categories.toString(),
features: Like("%DISCOVERABLE%"),
},
take: Math.abs(Number(limit || configLimit)),
});
});
}

const total = guilds ? guilds.length : undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/guild-recommendations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ router.get(
: await Guild.find({
where: { features: Like("%DISCOVERABLE%") },
take: Math.abs(Number(limit || 24)),
});
});
res.send({
recommended_guilds: guilds,
load_id: `server_recs/${genLoadId(32)}`,
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/oauth2/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ router.get(
guild: {
roles: x?.roles || [],
},
});
});

return {
id: x.guild.id,
Expand Down
6 changes: 4 additions & 2 deletions src/gateway/events/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
}

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",
name: `GATEWAY ${OPCODES[data.op]}`,
attributes: { // this needs to be reworked :)
attributes: {
// this needs to be reworked :)
...data.d,
token: data?.d?.token ? "[Redacted]" : undefined,
},
Expand Down
25 changes: 21 additions & 4 deletions src/gateway/listener/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function setupListener(this: WebSocket) {

const opts: {
acknowledge: boolean;
channel?: AMQChannel & { queues?: unknown, ch?: number };
channel?: AMQChannel & { queues?: unknown; ch?: number };
} = {
acknowledge: true,
};
Expand All @@ -91,10 +91,20 @@ export async function setupListener(this: WebSocket) {

console.log("[RabbitMQ] setupListener: open for ", this.user_id);
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.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);
Expand Down Expand Up @@ -132,7 +142,14 @@ export async function setupListener(this: WebSocket) {
});

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();
else {
Object.values(this.events).forEach((x) => x?.());
Expand Down
2 changes: 1 addition & 1 deletion src/util/entities/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class Channel extends BaseClass {
event: "CHANNEL_CREATE",
data: channel,
guild_id: channel.guild_id,
} as ChannelCreateEvent)
} as ChannelCreateEvent)
: Promise.resolve(),
Guild.insertChannelInOrder(guild.id, ret.id, position, guild),
]);
Expand Down
Loading

0 comments on commit 43b342a

Please sign in to comment.