forked from atums.world/backend
add clearTable command, simple webpage start
This commit is contained in:
parent
f14daf041a
commit
9a93e6269d
10 changed files with 156 additions and 11 deletions
|
@ -48,12 +48,7 @@ async function handler(
|
|||
);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof key !== "string" ||
|
||||
(typeof value !== "string" &&
|
||||
typeof value !== "boolean" &&
|
||||
typeof value !== "number")
|
||||
) {
|
||||
if (!["string", "boolean", "number"].includes(typeof value)) {
|
||||
return Response.json(
|
||||
{
|
||||
success: false,
|
||||
|
|
20
src/routes/auth/login.ts
Normal file
20
src/routes/auth/login.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { getSetting } from "@config/sql/settings";
|
||||
import { renderEjsTemplate } from "@helpers/ejs";
|
||||
|
||||
const routeDef: RouteDef = {
|
||||
method: "GET",
|
||||
accepts: "*/*",
|
||||
returns: "text/html",
|
||||
};
|
||||
|
||||
async function handler(): Promise<Response> {
|
||||
const ejsTemplateData: EjsTemplateData = {
|
||||
title: "Hello, World!",
|
||||
instance_name:
|
||||
(await getSetting("instance_name")) || "Unnamed Instance",
|
||||
};
|
||||
|
||||
return await renderEjsTemplate("auth/login", ejsTemplateData);
|
||||
}
|
||||
|
||||
export { handler, routeDef };
|
|
@ -6,7 +6,11 @@ const routeDef: RouteDef = {
|
|||
returns: "text/html",
|
||||
};
|
||||
|
||||
async function handler(): Promise<Response> {
|
||||
async function handler(request: ExtendedRequest): Promise<Response> {
|
||||
if (!request.session) {
|
||||
return Response.redirect("/auth/login");
|
||||
}
|
||||
|
||||
const ejsTemplateData: EjsTemplateData = {
|
||||
title: "Hello, World!",
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@ import { isValidUsername } from "@config/sql/users";
|
|||
import { type BunFile, type ReservedSQL, sql } from "bun";
|
||||
import { resolve } from "path";
|
||||
|
||||
import { isUUID, nameWithoutExtension } from "@/helpers/char";
|
||||
import { getBaseUrl, isUUID, nameWithoutExtension } from "@/helpers/char";
|
||||
import { logger } from "@/helpers/logger";
|
||||
|
||||
const routeDef: RouteDef = {
|
||||
|
@ -70,7 +70,13 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
|||
|
||||
if (json === "true" || json === "1") {
|
||||
return Response.json(
|
||||
{ success: true, code: 200, data: avatar },
|
||||
{
|
||||
success: true, code: 200,
|
||||
avatar: {
|
||||
...avatar,
|
||||
url: `${getBaseUrl(request)}/user/avatar/${user.id}`,
|
||||
}
|
||||
},
|
||||
{ status: 200 },
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue