mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 23:15:46 +01:00
🏗️ Migrate config list to tRPC
This commit is contained in:
12
src/server/api/routers/config.ts
Normal file
12
src/server/api/routers/config.ts
Normal 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', ''));
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user