fix: add client-specific constants, close #664
This commit is contained in:
4 files changed
+22
-5
No files matched your search
+9
-2
@@ -1,5 +1,5 @@
|
||||
import { env } from '$env/dynamic/public';
|
||||
import * as types from './types';
|
||||
import { env } from '$env/dynamic/public'
|
||||
import * as types from './types'
|
||||
|
||||
export type ClientType =
|
||||
| { name: 'lemmy'; baseUrl: '/api/v3' }
|
||||
@@ -19,6 +19,13 @@ export const DEFAULT_CLIENT_TYPE: ClientType =
|
||||
export abstract class BaseClient {
|
||||
abstract type: ClientType
|
||||
|
||||
static constants: {
|
||||
password: {
|
||||
minLength: number
|
||||
maxLength: number
|
||||
}
|
||||
}
|
||||
|
||||
abstract getSite(): Promise<types.GetSiteResponse>
|
||||
abstract editSite(form: types.EditSite): Promise<types.SiteResponse>
|
||||
abstract generateTotpSecret(): Promise<types.GenerateTotpSecretResponse>
|
||||
|
||||
@@ -5,6 +5,8 @@ import { fromGetPosts, toListingType } from './rewrite'
|
||||
export class LemmyClient implements BaseClient {
|
||||
type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' }
|
||||
|
||||
static constants = { password: { minLength: 8, maxLength: 60 } }
|
||||
|
||||
#client: LemmyHttp
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -38,6 +38,8 @@ import type { paths } from './schema'
|
||||
export class PiefedClient implements BaseClient {
|
||||
type: ClientType = { name: 'piefed', baseUrl: '/api/alpha' }
|
||||
|
||||
static constants = { password: { minLength: 6, maxLength: 128 } }
|
||||
|
||||
#client: ReturnType<typeof createClient<paths>>
|
||||
|
||||
constructor(
|
||||
|
||||
Reference in new issue
Block a user