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

100
src/routes/linkRoutes.ts Normal file
View File

@@ -0,0 +1,100 @@
import { Router } from 'express';
import validateSchema from '../tools/validateSchema';
import * as lc from '../controllers/linkController';
import * as ls from '../schemas/linkSchema';
const linkRouter = Router();
/**
* @openapi
*
* /api/v1/link/short:
* get:
* description: Generates a new short link
* tags: [Link]
* summary: Get a new short link
* parameters:
* - name: length
* in: query
* description: generated URL's length
* required: false
* schema:
* type: integer
* format: int32
* default: 9
* minimum: 2
* maximum: 127
* - name: alphanum
* in: query
* description: whether to use numbers in generated URL
* required: false
* schema:
* type: boolean
* default: true
* - name: case
* in: query
* description: whether to use uppercase ("upper"), lowercase ("lower") or mixed case (default)
* schema:
* type: string
* - name: withSubdomain
* in: query
* description: whether to generate a subdomain too (will be generated only if supported by server)
* required: false
* schema:
* type: boolean
* default: false
* produces:
* - application/json
* responses:
* 200:
* description: Link generated successfully
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/LinkResponseDTO'
* 400:
* description: Bad request
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ErrorDTO'
*/
linkRouter.get('/api/v1/link/short', validateSchema(ls.shortLinkRequestSchema), lc.generateShortLinkHandler);
/**
* @openapi
*
* /api/v1/link/fromWordlist:
* get:
* description: Generates a new pseudosentence link from wordlist.
* tags: [Link]
* summary: Get a new "sentence" link
* parameters:
* - name: withSubdomain
* in: query
* description: whether to generate a subdomain too (will be generated only if supported by server)
* required: false
* schema:
* type: boolean
* default: false
* produces:
* - application/json
* responses:
* 200:
* description: Link generated successfully
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/LinkResponseDTO'
* 400:
* description: Bad request
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ErrorDTO'
*/
linkRouter.get('/api/v1/link/fromWordlist', validateSchema(ls.sentenceLinkRequestSchema), lc.generateSentenceLinkHandler);
export default linkRouter;