Initial food blog app

This commit is contained in:
Andy
2026-03-21 11:57:08 +00:00
commit b83762bfc3
33 changed files with 8621 additions and 0 deletions

18
app/lib/restaurants.ts Normal file
View File

@@ -0,0 +1,18 @@
import fs from 'fs'
import path from 'path'
import { Restaurant } from '@/app/types'
const DATA_FILE = path.join(process.cwd(), 'data', 'restaurants.json')
export function readRestaurants(): Restaurant[] {
try {
const raw = fs.readFileSync(DATA_FILE, 'utf-8')
return JSON.parse(raw) as Restaurant[]
} catch {
return []
}
}
export function writeRestaurants(restaurants: Restaurant[]): void {
fs.writeFileSync(DATA_FILE, JSON.stringify(restaurants, null, 2), 'utf-8')
}