diff --git a/src/scenes/scenes.controller.ts b/src/scenes/scenes.controller.ts index 77bf841..55a0cf5 100644 --- a/src/scenes/scenes.controller.ts +++ b/src/scenes/scenes.controller.ts @@ -11,7 +11,7 @@ import { import { Response } from 'express'; import { StorageNamespace, StorageService } from 'src/storage/storage.service'; import { Readable } from 'stream'; -import { nanoid } from 'nanoid'; +import { customAlphabet } from 'nanoid'; @Controller() export class ScenesController { @@ -31,9 +31,11 @@ export class ScenesController { @Post() async create(@Body() payload: Buffer) { + // Excalidraw front-end only support numeric id, we can't use nanoid default alphabet + const nanoid = customAlphabet('0123456789', 16); const id = nanoid(); - // Nanoid has similar collision probability as uuid v4, so the following should *never* happen + // Check for collision if (await this.storageService.get(id, this.namespace)) { throw new InternalServerErrorException(); } diff --git a/src/storage/storage.service.ts b/src/storage/storage.service.ts index 9936243..8a47383 100644 --- a/src/storage/storage.service.ts +++ b/src/storage/storage.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; -import * as Keyv from 'keyv'; +import * as Keyv from '@keyvhq/core'; @Injectable() export class StorageService {