summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Server.ts8
-rw-r--r--src/routes/auth/login.ts2
-rw-r--r--src/routes/auth/register.ts4
-rw-r--r--src/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--src/routes/guilds/#guild_id/regions.ts10
-rw-r--r--src/routes/guilds/index.ts2
6 files changed, 23 insertions, 5 deletions
diff --git a/src/Server.ts b/src/Server.ts

index 39b1930d..52e217f8 100644 --- a/src/Server.ts +++ b/src/Server.ts
@@ -103,6 +103,14 @@ export class FosscordServer extends Server { app.use("/api/v8", prefix); app.use("/api/v9", prefix); app.use("/api", prefix); // allow unversioned requests + + prefix.get("*", (req: Request, res: Response) => { + res.status(404).json({ + message: "404: Not Found", + code: 0 + }); + }); + this.app = app; this.app.use(ErrorHandler); const indexHTML = fs.readFileSync(path.join(__dirname, "..", "client_test", "index.html"), { encoding: "utf8" }); diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts
index 82cefae8..af00a46d 100644 --- a/src/routes/auth/login.ts +++ b/src/routes/auth/login.ts
@@ -15,7 +15,7 @@ router.post( RateLimit({ count: 5, window: 60, onylIp: true }), check({ login: new Length(String, 2, 100), // email or telephone - password: new Length(String, 8, 64), + password: new Length(String, 8, 72), $undelete: Boolean, $captcha_key: String, $login_source: String, diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts
index 25c7b3dd..41798552 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts
@@ -16,8 +16,8 @@ router.post( check({ username: new Length(String, 2, 32), // TODO: check min password length in config - // prevent Denial of Service with max length of 64 chars - password: new Length(String, 8, 64), + // prevent Denial of Service with max length of 72 chars + password: new Length(String, 8, 72), consent: Boolean, $email: new Length(Email, 5, 100), $fingerprint: String, diff --git a/src/routes/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts
index 053a2a02..4e42d546 100644 --- a/src/routes/channels/#channel_id/messages/index.ts +++ b/src/routes/channels/#channel_id/messages/index.ts
@@ -126,7 +126,7 @@ router.post("/", messageUpload.single("file"), async (req: Request, res: Respons const embeds = []; if (body.embed) embeds.push(body.embed); - const data = await sendMessage({ ...body, type: 0, pinned: false, author_id: req.user_id, embeds, channel_id, attachments }); + const data = await sendMessage({ ...body, type: 0, pinned: false, author_id: req.user_id, embeds, channel_id, attachments, edited_timestamp: null }); return res.send(data); }); diff --git a/src/routes/guilds/#guild_id/regions.ts b/src/routes/guilds/#guild_id/regions.ts new file mode 100644
index 00000000..3a46d766 --- /dev/null +++ b/src/routes/guilds/#guild_id/regions.ts
@@ -0,0 +1,10 @@ +import { Config } from "@fosscord/server-util"; +import { Request, Response, Router } from "express"; + +const router = Router(); + +router.get("/", async (req: Request, res: Response) => { + return res.json(Config.get().regions.available); +}); + +export default router; \ No newline at end of file diff --git a/src/routes/guilds/index.ts b/src/routes/guilds/index.ts
index 17ade355..25b55896 100644 --- a/src/routes/guilds/index.ts +++ b/src/routes/guilds/index.ts
@@ -24,7 +24,7 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) = const guild_id = Snowflake.generate(); const guild: Guild = { name: body.name, - region: body.region || "en-US", + region: Config.get().regions.default, owner_id: req.user_id, icon: undefined, afk_channel_id: undefined,