35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { APINamespace, APINamespaceType, ngGET } from "../defs";
|
|
import type { structure } from "../../apiStructure/sammoRootAPI";
|
|
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 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,
|
|
}
|
|
}
|
|
|
|
const newNonce = "1234567890";
|
|
await ctx.setValue("nonce", newNonce);
|
|
return {
|
|
loginNonce: newNonce,
|
|
result: true,
|
|
}
|
|
}
|
|
);
|
|
|
|
type BaseAPI2 = APINamespaceType<typeof structure.Login>['ReqNonce'];
|
|
type A = typeof ReqNonce; |