Skip to content

Commit 71cea09

Browse files
authored
Merge pull request #678 from danactive/map-search
Map search get map filter
2 parents 659496b + 9fe7b5b commit 71cea09

File tree

20 files changed

+2223
-1879
lines changed

20 files changed

+2223
-1879
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.14.0
1+
v24.11.0

app/api/admin/classify/route.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ export type Prediction = {
1212
export async function POST(req: Request) {
1313
try {
1414
const utils = utilsFactory()
15-
16-
const { path: relativePath } = await req.json()
15+
const { path: relativePath }: { path?: string } = await req.json()
1716

1817
if (!relativePath) {
1918
return NextResponse.json({ error: 'Missing image path' }, { status: 400 })
2019
}
2120

2221
const fullPath = utils.safePublicPath(relativePath)
2322
const buffer = await fs.readFile(fullPath)
23+
const body = new Uint8Array(buffer) // TS-compatible BodyInit
2424

2525
const classifyUrl = `http://localhost:${config.pythonPort}/classify`
2626

2727
const res = await fetch(classifyUrl, {
2828
method: 'POST',
29-
headers: {
30-
'Content-Type': 'image/jpeg',
31-
},
32-
body: buffer,
29+
headers: { 'Content-Type': 'image/jpeg' },
30+
body,
3331
})
3432

3533
if (!res.ok) {
@@ -38,9 +36,8 @@ export async function POST(req: Request) {
3836

3937
const data = await res.json()
4038
return NextResponse.json(data)
41-
42-
} catch (err: any) {
43-
console.error(err)
44-
return NextResponse.json({ error: err.message || 'Unexpected error' }, { status: 500 })
39+
} catch (err: unknown) {
40+
const message = err instanceof Error ? err.message : 'Unexpected error'
41+
return NextResponse.json({ error: message }, { status: 500 })
4542
}
4643
}

app/api/admin/scores/route.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ import config from '../../../../src/models/config'
77
export async function POST(req: Request) {
88
try {
99
const utils = utilsFactory()
10-
11-
const { path: relativePath } = await req.json()
10+
const { path: relativePath }: { path?: string } = await req.json()
1211

1312
if (!relativePath) {
1413
return NextResponse.json({ error: 'Missing image path' }, { status: 400 })
1514
}
1615

1716
const fullPath = utils.safePublicPath(relativePath)
1817
const buffer = await fs.readFile(fullPath)
18+
const body = new Uint8Array(buffer)
1919

20-
const classifyUrl = `http://localhost:${config.pythonPort}/scores`
20+
const scoresUrl = `http://localhost:${config.pythonPort}/scores`
2121

22-
const res = await fetch(classifyUrl, {
22+
const res = await fetch(scoresUrl, {
2323
method: 'POST',
24-
headers: {
25-
'Content-Type': 'image/jpeg',
26-
},
27-
body: buffer,
24+
headers: { 'Content-Type': 'image/jpeg' },
25+
body,
2826
})
2927

3028
if (!res.ok) {
@@ -33,9 +31,8 @@ export async function POST(req: Request) {
3331

3432
const data = await res.json()
3533
return NextResponse.json(data)
36-
37-
} catch (err: any) {
38-
console.error(err)
39-
return NextResponse.json({ error: err.message || 'Unexpected error' }, { status: 500 })
34+
} catch (err: unknown) {
35+
const message = err instanceof Error ? err.message : 'Unexpected error'
36+
return NextResponse.json({ error: message }, { status: 500 })
4037
}
4138
}

next-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)