This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import { Dispatch, SetStateAction, useEffect, useState } from 'react'; | |
// types | |
type Entries = Entry[]; | |
type Setter = Dispatch<SetStateAction<object>>; | |
type Params = { [key: string]: any }; | |
interface Entry { | |
key: string; | |
url: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code for https://medium.com/@sina-byn/code-an-express-middleware-to-optimize-your-images-c9225308e4ba | |
const { createReadStream } = require('fs'); | |
const express = require('express'); | |
const fs = require('fs/promises'); | |
const sharp = require('sharp'); | |
const path = require('path'); | |
// * utils | |
const getContentType = fileName => { | |
const ext = path.extname(fileName).slice(1); |