Skip to content

Commit

Permalink
fix: change mimetype naming convention to PascalCase (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh authored Mar 9, 2023
1 parent e73ce03 commit a73ae7e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
11 changes: 6 additions & 5 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export * from './context';
export * from './itemType';
export * from './permissionLevel';
export * from './constants';
export * from './context';
export * from './httpMethod';
export * from './mentions';
export * from './limits';
export * from './itemLogin';
export * from './itemType';
export * from './limits';
export * from './mentions';
export * from './mimeTypes';
export * from './permissionLevel';
export * from './ui';
20 changes: 10 additions & 10 deletions src/constants/mimeTypes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const IMAGE = {
const Image = {
JPG: 'image/jpg',
JPEG: 'image/jpeg',
PNG: 'image/png',
GIF: 'image/gif',
SVG: 'image/svg+xml',
};

const VIDEO = {
const Video = {
MP4: 'video/mp4',
// https://stackoverflow.com/questions/15277147/m4v-mimetype-video-mp4-or-video-m4v
MP4_Apple: 'video/x-m4v',
Expand All @@ -15,7 +15,7 @@ const VIDEO = {
WEBM: 'video/webm',
};

const AUDIO = {
const Audio = {
MPEG: 'audio/mpeg',
MP3: 'audio/mp3',
WAV: 'audio/wav',
Expand All @@ -26,15 +26,15 @@ const PDF = 'application/pdf';

const ZIP = 'application/zip';

export const MIME_TYPES = {
IMAGE,
VIDEO,
AUDIO,
export const MimeTypes = {
Image,
Video,
Audio,
PDF,
ZIP,
isImage: (mimetype: string) => Object.values(IMAGE).includes(mimetype),
isAudio: (mimetype: string) => Object.values(AUDIO).includes(mimetype),
isVideo: (mimetype: string) => Object.values(VIDEO).includes(mimetype),
isImage: (mimetype: string) => Object.values(Image).includes(mimetype),
isAudio: (mimetype: string) => Object.values(Audio).includes(mimetype),
isVideo: (mimetype: string) => Object.values(Video).includes(mimetype),
isPdf: (mimetype: string) => [PDF].includes(mimetype),
isZip: (mimetype: string) => [ZIP].includes(mimetype),
} as const;
9 changes: 9 additions & 0 deletions src/constants/ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Size of Thumbnail to use
*/
export const ThumbnailSize = {
Small: 'small',
Medium: 'medium',
Large: 'large',
Original: 'original',
} as const;
11 changes: 2 additions & 9 deletions src/frontend/ui.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* Size of Thumbnail to use
*/
export const ThumbnailSize = {
SMALL: 'small',
MEDIUM: 'medium',
LARGE: 'large',
ORIGINAL: 'original',
} as const;
import { ThumbnailSize } from '@/constants/ui';

export type ThumbnailSizeVariant =
`${(typeof ThumbnailSize)[keyof typeof ThumbnailSize]}`;
3 changes: 2 additions & 1 deletion src/utils/extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ export const buildShortcutExtra = (target: string): ShortcutItemExtra => ({
// todo: improve extra typing
export const buildItemLoginSchemaExtra = (
schema?: ItemLoginSchema,
): { itemLogin?: ItemLogin } => schema ? ({ itemLogin: { loginSchema: schema }, }) : ({});
): { itemLogin?: ItemLogin } =>
schema ? { itemLogin: { loginSchema: schema } } : {};

0 comments on commit a73ae7e

Please sign in to comment.