대충이런느낌

This commit is contained in:
2023-08-08 17:10:15 +00:00
parent c7d0702e66
commit e381dd5a7e
10 changed files with 296 additions and 94 deletions
+26 -14
View File
@@ -1,23 +1,35 @@
import { ngGET } from "../defs";
import { APINamespace, APINamespaceType, ngGET } from "../defs";
import type { structure } from "../../apiStructure/sammoRootAPI";
import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStructure/defs";
import type { DefAPINamespace, ExtractError, ExtractQuery, ExtractResponse } from "../../apiStructure/defs";
import { StartSession } from "../ProcDecorator/StartSession";
type BaseAPI = typeof structure.Login.ReqNonce;
type RType = ExtractResponse<BaseAPI>;
type EType = ExtractError<BaseAPI>;
type QType = ExtractQuery<BaseAPI>;
const argValidator = undefined;
const procDecorator = [
StartSession,
] as const;
/*export class ReqNonce extends GET<RType, EType, QType>{
readonly argValidator = undefined;
readonly procDecorator = [] as const;
protected ReqNonce = Symbol("ReqNonce");//TODO: remove this
protected override async api(query: QType): Promise<RType | EType | true> {
throw new Error("Method not implemented.");
}
}*/
export const ReqNonce = ngGET<RType, EType, QType>(argValidator)(procDecorator)(
async (query, ctx) => {
const nonce = await ctx.getValue<string>("nonce");
if(nonce !== undefined){
return {
loginNonce: nonce,
result: true,
}
}
export const ReqNonce = ngGET<RType, EType, QType>(undefined)([] as const)(
(query, ctx, req, res) => {
throw new Error("Method not implemented.");
const newNonce = "1234567890";
await ctx.setValue("nonce", newNonce);
return {
loginNonce: newNonce,
result: true,
}
}
);
);
type BaseAPI2 = APINamespaceType<typeof structure.Login>['ReqNonce'];
type A = typeof ReqNonce;