feat/fix: UPLOADER_RANDOM_WORDS_sEPERATOR

This commit is contained in:
diced
2023-09-29 20:06:18 -07:00
parent 23af36563f
commit d112c3a509
4 changed files with 7 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ export interface ConfigUploader {
format_date: string;
default_expiration: string;
assume_mimetypes: boolean;
random_words_separator: string;
}
export interface ConfigUrls {

View File

@@ -98,6 +98,7 @@ export default function readConfig() {
map('UPLOADER_FORMAT_DATE', 'string', 'uploader.format_date'),
map('UPLOADER_DEFAULT_EXPIRATION', 'string', 'uploader.default_expiration'),
map('UPLOADER_ASSUME_MIMETYPES', 'boolean', 'uploader.assume_mimetypes'),
map('UPLOADER_RANDOM_WORDS_SEPARATOR', 'string', 'uploader.random_words_separator'),
map('URLS_ROUTE', 'string', 'urls.route'),
map('URLS_LENGTH', 'number', 'urls.length'),

View File

@@ -97,6 +97,7 @@ const validator = s.object({
format_date: s.string.default('YYYY-MM-DD_HH:mm:ss'),
default_expiration: s.string.optional.default(null),
assume_mimetypes: s.boolean.default(false),
random_words_separator: s.string.default('-'),
})
.default({
default_format: 'RANDOM',

View File

@@ -1,4 +1,5 @@
import { readFile } from 'fs/promises';
import config from 'lib/config';
export type GfyCatWords = {
adjectives: string[];
@@ -22,5 +23,7 @@ function randomWord(words: string[]) {
export default async function gfycat() {
const words = await importWords();
return `${randomWord(words.adjectives)} ${randomWord(words.adjectives)} ${randomWord(words.animals)}`;
return `${randomWord(words.adjectives)}${config.uploader.random_words_separator}${randomWord(
words.adjectives
)}${config.uploader.random_words_separator}${randomWord(words.animals)}`;
}