Implement testing framework with Vitest, add unit tests for API routes and utility functions, and configure CI workflow for automated testing. Update package dependencies for testing libraries and add test scripts to package.json.
Some checks are pending
CI / test (push) Waiting to run
Some checks are pending
CI / test (push) Waiting to run
This commit is contained in:
22
lib/mime.ts
Normal file
22
lib/mime.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { AudioFormat, VideoFormat, FormatType } from './types';
|
||||
|
||||
export const VIDEO_MIME: Record<VideoFormat, string> = {
|
||||
mp4: 'video/mp4',
|
||||
webm: 'video/webm',
|
||||
mkv: 'video/x-matroska',
|
||||
avi: 'video/x-msvideo',
|
||||
};
|
||||
|
||||
export const AUDIO_MIME: Record<AudioFormat, string> = {
|
||||
mp3: 'audio/mpeg',
|
||||
wav: 'audio/wav',
|
||||
m4a: 'audio/mp4',
|
||||
opus: 'audio/ogg',
|
||||
};
|
||||
|
||||
export function getMimeType(formatType: FormatType, format: VideoFormat | AudioFormat): string {
|
||||
if (formatType === 'video') {
|
||||
return VIDEO_MIME[format as VideoFormat] || 'application/octet-stream';
|
||||
}
|
||||
return AUDIO_MIME[format as AudioFormat] || 'application/octet-stream';
|
||||
}
|
||||
Reference in New Issue
Block a user