Add ability to make junk-drawer private-ish

This commit is contained in:
2024-10-01 17:04:08 -06:00
parent 12290c7095
commit 9394e1cc5a
5 changed files with 24 additions and 2 deletions

View File

@@ -74,8 +74,12 @@ export class JunkDrawerController {
async handleFileUpload(
@UploadedFiles() files: Express.Multer.File[],
@Body('description') description: string,
@Body('private-ish') privateIsh: boolean,
): Promise<any> {
const uniqueSlug = generateUniqueSlug();
console.log(privateIsh);
const uniqueSlug = generateUniqueSlug({
random: privateIsh,
});
const metadata: JunkDrawerMetadata = {
slug: uniqueSlug,
version: '1.0.0',

View File

@@ -1,3 +1,5 @@
import { v4 } from 'uuid';
interface SlugOptions {
year: boolean;
month: boolean;
@@ -36,7 +38,7 @@ export const generateUniqueSlug = (
hour ? String(date.getHours()).padStart(2, '0') : '',
minute ? String(date.getMinutes()).padStart(2, '0') : '',
second ? String(date.getSeconds()).padStart(2, '0') : '',
random ? Math.random().toString(36).substring(2, 15) : '',
random ? '-' + v4() : '',
].filter(Boolean);
return parts.join(separator);