Compare commits
No commits in common. "eb83e221e432676c6d75f43ce4f99cdd4961241f" and "02f3cd9bd1cd3d7a55f6e07d8bc1a18a97081fc7" have entirely different histories.
eb83e221e4
...
02f3cd9bd1
@ -1,7 +1,4 @@
|
||||
export const BASE_API_URL = 'http://localhost:8080/';
|
||||
|
||||
export async function fetcher(url: string) {
|
||||
const u = new URL(url, BASE_API_URL);
|
||||
const res = await fetch(u);
|
||||
const res = await fetch(url);
|
||||
return res.json();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { atom, useAtomValue, setAtomValue } from "../lib/atom.ts";
|
||||
import { BASE_API_URL } from "../hook/fetcher.ts";
|
||||
|
||||
type LoginLocalStorage = {
|
||||
username: string;
|
||||
@ -23,9 +22,8 @@ function getUserSessions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function refresh() {
|
||||
const u = new URL("/user/refresh", BASE_API_URL);
|
||||
const res = await fetch(u, {
|
||||
async function refresh() {
|
||||
const res = await fetch("/user/refresh", {
|
||||
method: "POST",
|
||||
});
|
||||
if (res.status !== 200) throw new Error("Maybe Network Error");
|
||||
@ -49,8 +47,7 @@ export async function refresh() {
|
||||
}
|
||||
|
||||
export const doLogout = async () => {
|
||||
const u = new URL("/user/refresh", BASE_API_URL);
|
||||
const req = await fetch(u, {
|
||||
const req = await fetch("/api/user/logout", {
|
||||
method: "POST",
|
||||
});
|
||||
const setVal = setAtomValue(userLoginStateAtom);
|
||||
@ -79,8 +76,7 @@ export const doLogin = async (userLoginInfo: {
|
||||
username: string;
|
||||
password: string;
|
||||
}): Promise<string | LoginLocalStorage> => {
|
||||
const u = new URL("/user/refresh", BASE_API_URL);
|
||||
const res = await fetch(u, {
|
||||
const res = await fetch("/api/user/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(userLoginInfo),
|
||||
headers: { "content-type": "application/json" },
|
||||
|
@ -103,6 +103,7 @@ async function renderZipImage(ctx: Context, path: string, page: number) {
|
||||
|
||||
ctx.body = nodeReadableStream;
|
||||
ctx.response.length = entry.uncompressedSize;
|
||||
// console.log(`${entry.name}'s ${page}:${entry.size}`);
|
||||
ctx.response.type = entry.filename.split(".").pop() as string;
|
||||
ctx.status = 200;
|
||||
ctx.set("Date", new Date().toUTCString());
|
||||
|
@ -24,6 +24,7 @@ const ContentIDHandler = (controller: DocumentAccessor) => async (ctx: Context,
|
||||
}
|
||||
ctx.body = document;
|
||||
ctx.type = "json";
|
||||
console.log(document.additional);
|
||||
};
|
||||
const ContentTagIDHandler = (controller: DocumentAccessor) => async (ctx: Context, next: Next) => {
|
||||
const num = Number.parseInt(ctx.params.num);
|
||||
|
@ -98,14 +98,12 @@ class ServerApplication {
|
||||
if (setting.mode === "development") {
|
||||
let mm_count = 0;
|
||||
app.use(async (ctx, next) => {
|
||||
console.log(`=== Request No ${mm_count++} \t===`);
|
||||
const ip = ctx.get("X-Real-IP").length > 0 ? ctx.get("X-Real-IP") : ctx.ip;
|
||||
console.log(`==========================${mm_count++}`);
|
||||
const ip = ctx.get("X-Real-IP") ?? ctx.ip;
|
||||
const fromClient = ctx.state.user.username === "" ? ip : ctx.state.user.username;
|
||||
console.log(`${mm_count} ${fromClient} : ${ctx.method} ${ctx.url}`);
|
||||
const start = Date.now();
|
||||
console.log(`${fromClient} : ${ctx.method} ${ctx.url}`);
|
||||
await next();
|
||||
const end = Date.now();
|
||||
console.log(`${mm_count} ${fromClient} : ${ctx.method} ${ctx.url} ${ctx.status} ${end - start}ms`);
|
||||
// console.log(`404`);
|
||||
});
|
||||
}
|
||||
app.use(router.routes());
|
||||
|
@ -39,7 +39,9 @@ export async function readZip(path: string): Promise<{
|
||||
return { reader, handle: fd };
|
||||
}
|
||||
export async function entriesByNaturalOrder(zip: ZipReader<FileHandle>) {
|
||||
// console.log(zip);
|
||||
const entries = await zip.getEntries();
|
||||
// console.log(entries.map((v) => v.filename));
|
||||
const ret = orderBy(entries, (v) => v.filename);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user