🏗️ Migrate config list to tRPC

This commit is contained in:
Meier Lukas
2023-06-10 11:28:35 +02:00
parent dc5bcbe9b2
commit 62cfce4ba1
3 changed files with 18 additions and 10 deletions

View File

@@ -0,0 +1,12 @@
import fs from 'fs';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const configRouter = createTRPCRouter({
all: publicProcedure.query(async () => {
// 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
return files.map((file) => file.replace('.json', ''));
}),
});