fix(core): update
This commit is contained in:
33
ts/index.ts
Normal file
33
ts/index.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import * as plugins from './smartmime.plugins';
|
||||
|
||||
export const binaryFileTypes = [
|
||||
'jpg',
|
||||
'png',
|
||||
'pdf'
|
||||
];
|
||||
|
||||
export const supportedFileTypes = [
|
||||
'json',
|
||||
'html',
|
||||
'svg',
|
||||
'jpg',
|
||||
'ts',
|
||||
'js',
|
||||
];
|
||||
|
||||
export type TMimeTypes = 'image/jpeg' | 'image/svg+xml' | 'application/json' | 'text/html';
|
||||
|
||||
export const detectMimeType = (pathArg: string) => {
|
||||
return plugins.mimeTypes.lookup(pathArg) as TMimeTypes;
|
||||
};
|
||||
|
||||
export const isBinary = (pathArg: string) => {
|
||||
let isBinary = false;
|
||||
for (const binaryFileType of binaryFileTypes) {
|
||||
if (isBinary) {
|
||||
continue;
|
||||
}
|
||||
isBinary = pathArg.endsWith(`.${binaryFileType}`);
|
||||
}
|
||||
return isBinary;
|
||||
}
|
13
ts/smartmime.plugins.ts
Normal file
13
ts/smartmime.plugins.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
};
|
||||
|
||||
// thirdparty scope
|
||||
import mimeTypes from 'mime-types';
|
||||
|
||||
export {
|
||||
mimeTypes
|
||||
};
|
Reference in New Issue
Block a user