Fix not filtering .json files for config

This commit is contained in:
ajnart
2023-01-08 13:11:48 +09:00
parent 4e61eae59b
commit a4eabce37a
2 changed files with 9 additions and 4 deletions

View File

@@ -88,7 +88,9 @@ function Get(req: NextApiRequest, res: NextApiResponse) {
}
// Loop over all the files in the /data/configs directory
const files = fs.readdirSync('data/configs');
// Get all the configs in the /data/configs folder
// All the files that end in ".json"
const files = fs.readdirSync('./data/configs').filter((file) => file.endsWith('.json'));
// Strip the .json extension from the file name
const configs = files.map((file) => file.replace('.json', ''));
@@ -134,7 +136,9 @@ function Delete(req: NextApiRequest, res: NextApiResponse<any>) {
}
// Loop over all the files in the /data/configs directory
const files = fs.readdirSync('data/configs');
// Get all the configs in the /data/configs folder
// All the files that end in ".json"
const files = fs.readdirSync('./data/configs').filter((file) => file.endsWith('.json'));
// Strip the .json extension from the file name
const configs = files.map((file) => file.replace('.json', ''));

View File

@@ -2,8 +2,9 @@ import { NextApiRequest, NextApiResponse } from 'next';
import fs from 'fs';
function Get(req: NextApiRequest, res: NextApiResponse) {
// Loop over all the files in the /data/configs directory
const files = fs.readdirSync('data/configs');
// Get all the configs in the /data/configs folder
// All the files that end in ".json"
const files = fs.readdirSync('./data/configs').filter((file) => file.endsWith('.json'));
// Strip the .json extension from the file name
const configs = files.map((file) => file.replace('.json', ''));