Fix depreacted api

This commit is contained in:
2024-03-26 17:52:58 +08:00
parent 9aa1bba248
commit 867756a70e
3 changed files with 7 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
import { FreshContext } from "$fresh/server.ts";
import { join } from "std/path/mod.ts";
import {
get_file_response,
@@ -10,7 +10,7 @@ import { build_sw } from "../server/build_sw.ts";
const STATIC_FILES = ["/common.css", "/scrollBar.css", "/sw.js", "/sw.js.map"];
export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
export async function handler(req: Request, ctx: FreshContext) {
const url = new URL(req.url);
if (url.pathname == "/sw.js") {
build_sw();

View File

@@ -1,10 +1,10 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
import { FreshContext } from "$fresh/server.ts";
import { get_task_manager } from "../../server.ts";
import { parse_cookies } from "../../server/cookies.ts";
import { return_error } from "../../server/utils.ts";
import type { Token } from "../../db.ts";
function handle_auth(req: Request, ctx: MiddlewareHandlerContext) {
function handle_auth(req: Request, ctx: FreshContext) {
if (req.method === "OPTIONS") return true;
const m = get_task_manager();
if (m.db.get_user_count() === 0) return true;
@@ -40,7 +40,7 @@ function handle_auth(req: Request, ctx: MiddlewareHandlerContext) {
return true;
}
export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
export async function handler(req: Request, ctx: FreshContext) {
const m = get_task_manager();
if (!(handle_auth(req, ctx))) {
const headers: HeadersInit = {};

View File

@@ -1,7 +1,7 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
import { FreshContext } from "$fresh/server.ts";
import { get_task_manager } from "../../server.ts";
export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
export async function handler(req: Request, ctx: FreshContext) {
const res = await ctx.next();
const m = get_task_manager();
if (req.method === "OPTIONS" && res.status === 405) {