diff --git a/pages/api/beatsaver/art/[hash].js b/pages/api/beatsaver/art/[hash].js index 5c7f436..65dcc94 100644 --- a/pages/api/beatsaver/art/[hash].js +++ b/pages/api/beatsaver/art/[hash].js @@ -2,12 +2,7 @@ import fs from "fs"; import fetch from "node-fetch"; import path from "path"; import sharp from "sharp"; - -const cacheDir = process.cwd() + path.sep + "cache"; -if (!fs.existsSync(cacheDir)) { - fs.mkdirSync(cacheDir); - console.log("Created cache directory"); -} +import cacheDir from "../../../../src/caches/SongArtCacheDir"; export default async function handler(req, res) { const mapHash = req.query.hash.replace("custom_level_", "").toLowerCase(); diff --git a/src/caches/SongArtCacheDir.js b/src/caches/SongArtCacheDir.js new file mode 100644 index 0000000..36c813f --- /dev/null +++ b/src/caches/SongArtCacheDir.js @@ -0,0 +1,7 @@ +const cacheDir = process.cwd() + path.sep + "cache"; +if (!fs.existsSync(cacheDir)) { + fs.mkdirSync(cacheDir); + console.log("Created art cache directory"); +} + +module.exports = cacheDir;