@@ -4,6 +4,7 @@ import { get } from 'https'
44import { config } from './config'
55import { Areas , GetArea , parentArea , singletonArea } from './const'
66import { addDotSeparator } from './utils'
7+ import { NextResponse } from 'next/server'
78
89export type Query < Area extends Areas > = {
910 limit ?: number
@@ -94,7 +95,7 @@ export async function getSpecificData<Area extends Areas>(
9495export async function getBoundaryData ( area : Areas , code : string ) {
9596 const url = `${ config . dataSource . boundary . url } /${ area } /${ addDotSeparator ( code . replaceAll ( '.' , '' ) ) } .geojson`
9697
97- return new Promise < Response > ( ( resolve , reject ) => {
98+ return new Promise < NextResponse > ( ( resolve , reject ) => {
9899 // Create encoding to convert token (string) to Uint8Array
99100 const encoder = new TextEncoder ( )
100101
@@ -105,11 +106,11 @@ export async function getBoundaryData(area: Areas, code: string) {
105106 get ( url , ( res ) => {
106107 if ( res . statusCode !== 200 ) {
107108 resolve (
108- new Response (
109- JSON . stringify ( {
109+ NextResponse . json (
110+ {
110111 statusCode : res . statusCode ,
111112 message : res . statusMessage ,
112- } ) ,
113+ } ,
113114 { status : res . statusCode } ,
114115 ) ,
115116 )
@@ -121,7 +122,7 @@ export async function getBoundaryData(area: Areas, code: string) {
121122
122123 res . on ( 'end' , ( ) => {
123124 writer . close ( )
124- resolve ( new Response ( stream . readable , { status : res . statusCode } ) )
125+ resolve ( new NextResponse ( stream . readable , { status : res . statusCode } ) )
125126 } )
126127
127128 res . on ( 'error' , ( error ) => {
0 commit comments