tweaking property meta and condition report apis

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-02 14:13:53 +01:00
parent 52cb8790a6
commit a3b7de9873
2 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,34 @@
import { db } from "@/app/db/db";
import { property } from "@/app/db/schema/property";
import { serializeBigInt } from "@/app/utils";
import { eq } from "drizzle-orm";
export async function GET(
request: Request,
{ params }: { params: { propertyId: string } }
) {
const propertyId = params.propertyId;
const propertyMeta = await db.query.property.findFirst({
columns: {
id: true,
address: true,
postcode: true,
hasPreConditionReport: true,
hasRecommendations: true,
createdAt: true,
propertyType: true,
builtForm: true,
localAuthority: true,
constituency: true,
numberOfRooms: true,
yearBuilt: true,
tenure: true,
currentEpcRating: true,
currentSapPoints: true,
},
where: eq(property.id, BigInt(propertyId)),
});
return new Response(JSON.stringify(propertyMeta, serializeBigInt));
}

View file

@ -1,5 +1,5 @@
import { db } from "@/app/db/db";
import { PropertyMeta, property } from "@/app/db/schema/property";
import { property } from "@/app/db/schema/property";
import { serializeBigInt } from "@/app/utils";
import { eq } from "drizzle-orm";