Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add a `create` method to the `session.Client`
Sebastian Martinez committed 2 years ago
commit 0327cf21e5e40e291b5d2ded1626885685ce8337
parent d5857952aa200ae64ae0b9c95667a7798ff81d99
1 file changed +20 -1
modified httpd-client/lib/session.ts
@@ -1,11 +1,19 @@
import type { Fetcher, RequestOptions } from "./fetcher.js";
import type { SuccessResponse } from "./shared.js";
-
import type { ZodSchema } from "zod";
+
import type { ZodSchema, z } from "zod";

import { number, object, string } from "zod";

import { successResponseSchema } from "./shared.js";

+
export const sessionPayloadSchema = object({
+
  sessionId: string(),
+
  signature: string(),
+
  publicKey: string(),
+
});
+

+
export type SessionPayload = z.infer<typeof sessionPayloadSchema>;
+

interface Session {
  sessionId: string;
  status: string;
@@ -40,6 +48,17 @@ export class Client {
    );
  }

+
  public async create(options?: RequestOptions): Promise<Session> {
+
    return this.#fetcher.fetchOk(
+
      {
+
        method: "POST",
+
        path: "sessions",
+
        options,
+
      },
+
      sessionSchema,
+
    );
+
  }
+

  public async update(
    id: string,
    body: {