feat: add link generation support (short/sentence links) + wordlist
All checks were successful
Update changelog / changelog (push) Successful in 26s

This commit is contained in:
2026-01-02 17:50:52 +01:00
parent f0ca4e897c
commit f86630c51e
12 changed files with 7462 additions and 6 deletions

View File

@@ -58,7 +58,7 @@ export type LoginRequestDTO = z.TypeOf<typeof loginRequestSchema>;
* properties:
* status:
* type: string
* default: ok on success otherwise ErrorDTO with error
* default: ok on success, otherwise ErrorDTO with error
* name:
* type: string
* default: username

61
src/schemas/linkSchema.ts Normal file
View File

@@ -0,0 +1,61 @@
import z from 'zod';
const shortLinkRequestSchemaQuery = z.object({
// https://zod.dev/v4?id=stringbool
length: z.coerce
.number('Length must be a number')
.min( 3, 'Length is too small (try something longer than 3)')
.max(128, 'Length is too long (try something shorter than 128)')
.optional(),
alphanum: z.stringbool('Alphanum must be a boolean')
.optional(),
case: z.enum(['lower', 'upper'])
.optional(),
withSubdomain: z.stringbool('WithSubdomain must be a boolean')
.optional()
});
export const shortLinkRequestSchema = z.object({
query: shortLinkRequestSchemaQuery
});
export type ShortLinkRequestDTO = z.TypeOf<typeof shortLinkRequestSchema>;
const sentenceLinkRequestSchemaQuery = z.object({
// https://zod.dev/v4?id=stringbool
withSubdomain: z.stringbool('WithSubdomain must be a boolean')
.optional()
});
export const sentenceLinkRequestSchema = z.object({
query: sentenceLinkRequestSchemaQuery
});
export type SentenceLinkRequestDTO = z.TypeOf<typeof sentenceLinkRequestSchema>;
/**
* @swagger
* components:
* schemas:
* LinkResponseDTO:
* type: object
* required:
* - status
* - uri
* - subdomain
* properties:
* status:
* type: string
* default: ok on success, otherwise ErrorDTO with error
* uri:
* type: string
* default: username
* subdomain:
* type: string
* default: subdomain or null
*/
export type LinkResponseDTO = {
status: 'ok';
uri: string;
subdomain?: string | null; // null when server does not support generating subdomains
};