Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Mar 29, 2024
1 parent bb586a4 commit 7e8f108
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 10 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"version": "1.0.50",
"scripts": {
"dev": "bun run --watch src/index.ts",

"check": "biome check .",
"check:apply": "biome check --apply .",

"edgedb": "bunx @edgedb/generate edgeql-js"
},
"dependencies": {
"@elysiajs/swagger": "^1.0.3",
"edgedb": "^1.4.1",
"elysia": "latest",
"elysia-http-status-code": "^1.0.9",
Expand Down
1 change: 1 addition & 0 deletions src/constants/general.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = "a2.0.0";
43 changes: 38 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { swagger } from "@elysiajs/swagger";
import { VERSION } from "constants/general";
import { Elysia } from "elysia";
import { accessTokenRouter } from "routes/auth/accessToken";
import { refreshTokenRouter } from "routes/auth/refreshToken";
Expand All @@ -7,11 +9,42 @@ import { edgedb } from "../dbschema/edgeql-js/imports";
export const client = edgedb.createClient();

const app = new Elysia()
.get("/", () => ({
name: "Dlool",
isDlool: true,
version: "a2.0.0",
}))
.use(
swagger({
documentation: {
info: {
title: "Dlool API",
license: {
name: "GPL-3.0",
url: "https://www.gnu.org/licenses/gpl-3.0.html",
},
version: VERSION,
},
externalDocs: {
description:
"The Dlool documentation for general information and usage of the frontend.",
url: "https://dlool.me/documentation",
},
tags: [
{ name: "App", description: "General app information" },
{ name: "Auth", description: "Authentication endpoints" },
],
},
}),
)
.get(
"/",
() => ({
name: "Dlool",
isDlool: true,
version: VERSION,
}),
{
detail: {
tags: ["App"],
},
},
)
.group("/auth", (app) =>
app.use(registerRouter).use(refreshTokenRouter).use(accessTokenRouter),
)
Expand Down
1 change: 1 addition & 0 deletions src/routes/auth/accessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export const accessTokenRouter = new Elysia({ prefix: "/access-token" })
body: t.Object({
refreshToken: t.String({ minLength: 1 }),
}),
detail: { tags: ["Auth"] },
},
);
1 change: 1 addition & 0 deletions src/routes/auth/refreshToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ export const refreshTokenRouter = new Elysia({ prefix: "/refresh-token" })
username: t.String({ minLength: 1 }),
password: t.String({ minLength: 1 }),
}),
detail: { tags: ["Auth"] },
},
);
15 changes: 12 additions & 3 deletions src/routes/auth/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@ export const registerRouter = new Elysia({ prefix: "/register" })
body: t.Object({
username: t.String({
minLength: 1,
description: "The username must be unique and will be used to login",
}),
displayname: t.String({
minLength: 1,
description:
"The display name will be shown to other users and does not need to be unique",
}),
password: t.RegExp(
/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,
),
password: t.String({
minLength: 8,
description:
"Password must contain at least 8 characters, one uppercase letter, one lowercase letter, one number, and one special character",
pattern:
"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$",
}),
// t.RegExp(),
}),
detail: { tags: ["Auth"] },
},
);

0 comments on commit 7e8f108

Please sign in to comment.