diff --git a/server/api/Login/ReqNonce.ts b/server/api/Login/ReqNonce.ts index f3c4d86..8adc15a 100644 --- a/server/api/Login/ReqNonce.ts +++ b/server/api/Login/ReqNonce.ts @@ -1,4 +1,4 @@ -import { POST } from "../defs"; +import { GET } from "../defs"; import type { structure } from "../../apiStructure/sammoRootAPI"; import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStructure/defs"; @@ -7,7 +7,7 @@ type RType = ExtractResponse; type EType = ExtractError; type QType = ExtractQuery; -export class ReqNonce extends POST{ +export class ReqNonce extends GET{ protected ReqNonce = Symbol("ReqNonce");//TODO: remove this protected override async api(query: QType): Promise { throw new Error("Method not implemented."); diff --git a/server/api/Login/index.ts b/server/api/Login/index.ts index 1d88121..31b12e4 100644 --- a/server/api/Login/index.ts +++ b/server/api/Login/index.ts @@ -1,5 +1,5 @@ -import { structure } from "../../apiStructure/sammoRootAPI"; -import { APINamespaceType } from "../defs"; +import type { structure } from "../../apiStructure/sammoRootAPI"; +import type { APINamespaceType } from "../defs"; import { LoginByID } from "./LoginByID"; import { LoginByToken } from "./LoginByToken"; import { ReqNonce } from "./ReqNonce"; diff --git a/server/api/defs.ts b/server/api/defs.ts index 3f43b90..2b4c78f 100644 --- a/server/api/defs.ts +++ b/server/api/defs.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express'; -import type { APICallT, Callable, DefAPINamespace, EmptyAPICallT, HttpMethod, InvalidResponse, RawArgType, ValidResponse, recoveryMethod } from '../apiStructure/defs'; +import type { APICallT, Callable, DefAPINamespace, DeleteAPICallT, EmptyAPICallT, GetAPICallT, HeadAPICallT, HttpMethod, InvalidResponse, PatchAPICallT, PostAPICallT, PutAPICallT, RawArgType, ValidResponse, recoveryMethod } from '../apiStructure/defs'; export const treatedSpecial = Symbol('treatedSpecial'); export type APINamespace = { @@ -83,7 +83,12 @@ export type GetClassGenerator = { prototype: T }; export type APIServerType = - T extends APICallT ? GetClassGenerator> : + T extends GetAPICallT ? GetClassGenerator> : + T extends PostAPICallT ? GetClassGenerator> : + T extends PutAPICallT ? GetClassGenerator> : + T extends DeleteAPICallT ? GetClassGenerator> : + T extends PatchAPICallT ? GetClassGenerator> : + T extends HeadAPICallT ? GetClassGenerator> : never; export type APINamespaceType = { [K in keyof T]: diff --git a/server/api/root.ts b/server/api/root.ts index e69de29..ebb2f4c 100644 --- a/server/api/root.ts +++ b/server/api/root.ts @@ -0,0 +1,7 @@ +import type { structure } from "../apiStructure/sammoRootAPI"; +import type { APINamespaceType } from "./defs"; +import { Login } from "./Login"; + +export const sammoRootAPI = { + Login, +} satisfies APINamespaceType; \ No newline at end of file diff --git a/server/apiStructure/defs.ts b/server/apiStructure/defs.ts index 75452d1..2e24517 100644 --- a/server/apiStructure/defs.ts +++ b/server/apiStructure/defs.ts @@ -129,6 +129,12 @@ export type PatchAPICallT< ErrorType extends InvalidResponse = InvalidResponse > = ArgType extends undefined ? EmptyPatchAPICallT : BasicPatchAPICallT; +export type HeadAPICallT< + ArgType extends RawArgType, + ResultType extends ValidResponse = ValidResponse, + ErrorType extends InvalidResponse = InvalidResponse +> = ArgType extends undefined ? EmptyHeadAPICallT : BasicHeadAPICallT; + export type APITail = ReturnType | ReturnType | ReturnType | ReturnType | ReturnType | ReturnType; export function GET< diff --git a/server/apiStructure/sammoRootAPI.ts b/server/apiStructure/sammoRootAPI.ts index cd2add5..364a39b 100644 --- a/server/apiStructure/sammoRootAPI.ts +++ b/server/apiStructure/sammoRootAPI.ts @@ -1,4 +1,4 @@ -import { DefAPINamespace, GET, POST } from "./defs"; +import { type DefAPINamespace, GET, POST } from "./defs"; export type LoginResponse = { result: true, @@ -40,7 +40,6 @@ export const structure = { hashedToken: string, token_id: number, }, AutoLoginResponse, AutoLoginFailed>(), - Test: POST(), ReqNonce: GET() }, } satisfies DefAPINamespace; \ No newline at end of file