fix: use FileSize and ImageSize types
This commit is contained in:
@@ -9,6 +9,7 @@ import fileExists from '../../uploads/fileExists';
|
||||
import { BeforeOperationHook, Collection } from '../config/types';
|
||||
import { Document, Where } from '../../types';
|
||||
import { hasWhereAccessResult } from '../../auth/types';
|
||||
import { FileSize } from '../../uploads/types';
|
||||
|
||||
export type Arguments = {
|
||||
depth?: number
|
||||
@@ -118,7 +119,7 @@ async function deleteQuery(incomingArgs: Arguments): Promise<Document> {
|
||||
}
|
||||
|
||||
if (resultToDelete.sizes) {
|
||||
Object.values(resultToDelete.sizes).forEach(async (size) => {
|
||||
Object.values(resultToDelete.sizes).forEach(async (size: FileSize) => {
|
||||
if (await fileExists(`${staticPath}/${size.filename}`)) {
|
||||
fs.unlink(`${staticPath}/${size.filename}`, (err) => {
|
||||
if (err) {
|
||||
|
||||
@@ -4,9 +4,9 @@ import sanitize from 'sanitize-filename';
|
||||
import getImageSize from './getImageSize';
|
||||
import fileExists from './fileExists';
|
||||
import { CollectionConfig } from '../collections/config/types';
|
||||
import { FileSizes } from './types';
|
||||
import { FileSizes, ImageSize } from './types';
|
||||
|
||||
function getOutputImage(sourceImage, size) {
|
||||
function getOutputImage(sourceImage: string, size: ImageSize) {
|
||||
const extension = sourceImage.split('.').pop();
|
||||
const name = sanitize(sourceImage.substr(0, sourceImage.lastIndexOf('.')) || sourceImage);
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
export type FileSize = {
|
||||
filename: string;
|
||||
filesize: number;
|
||||
mimeType: string;
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
crop: string;
|
||||
}
|
||||
|
||||
export type FileSizes = {
|
||||
[size: string]: {
|
||||
filename: string;
|
||||
filesize: number;
|
||||
mimeType: string;
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
crop: string;
|
||||
}
|
||||
[size: string]: FileSize
|
||||
}
|
||||
|
||||
export type FileData = {
|
||||
|
||||
Reference in New Issue
Block a user