import express from "express" ; import { getAllForEntity , seedDatabase } from "./database" ; import { validateMiddleware } from "./helpers" ; import { isValidEntityValidator } from "./validators" ; import { DbSchema } from "../src/models/db-schema" ; const router = express . Router ( ) ; router . post ( "/seed" , ( req , res ) => { seedDatabase ( ) ; res . sendStatus ( 200 ) ; } ) ; router . get ( "/:entity" , validateMiddleware ( [ ... isValidEntityValidator ] ) , ( req , res ) => { const { entity } = req . params ; const results = getAllForEntity ( entity as keyof DbSchema ) ; res . status ( 200 ) ; res . json ( { results } ) ; } ) ; export default router ;