build-address added tested

This commit is contained in:
2025-11-18 16:25:03 +03:00
parent 6a5acd28db
commit 688576a1de
129 changed files with 8116 additions and 385 deletions

View File

@@ -0,0 +1,43 @@
'use server';
import { NextResponse } from 'next/server';
import { GraphQLClient, gql } from 'graphql-request';
const endpoint = "http://localhost:3001/graphql";
export async function POST(request: Request) {
const body = await request.json();
const { limit, skip, sort, filters } = body;
try {
const client = new GraphQLClient(endpoint);
const query = gql`
query GetBuildAddresses($input: ListArguments!) {
buildAddresses(input: $input) {
totalCount
data {
_id
uuid
buildNumber
doorNumber
floorNumber
commentAddress
letterAddress
shortLetterAddress
latitude
longitude
street
createdAt
updatedAt
expiryStarts
expiryEnds
}
}
}`;
const variables = { input: { limit, skip, sort, filters } };
console.dir({ variables })
const data = await client.request(query, variables);
return NextResponse.json({ data: data.buildAddresses.data, totalCount: data.buildAddresses.totalCount });
} catch (err: any) {
console.error(err);
return NextResponse.json({ error: err.message }, { status: 500 });
}
}