fix(core): update

This commit is contained in:
2020-03-04 14:21:44 +00:00
commit 3a067a7aae
13 changed files with 2074 additions and 0 deletions

33
ts/index.ts Normal file
View 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
View File

@ -0,0 +1,13 @@
// node native scope
import * as path from 'path';
export {
path
};
// thirdparty scope
import mimeTypes from 'mime-types';
export {
mimeTypes
};