mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 13:24:27 +00:00
35 lines
829 B
TypeScript
35 lines
829 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { supabase } from '@/lib/supabase/client'
|
|
|
|
/**
|
|
* @description Retrieves all active locations
|
|
*/
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { data: locations, error } = await supabase
|
|
.from('locations')
|
|
.select('*')
|
|
.eq('is_active', true)
|
|
.order('name', { ascending: true })
|
|
|
|
if (error) {
|
|
console.error('Locations GET error:', error)
|
|
return NextResponse.json(
|
|
{ error: error.message },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
locations: locations || []
|
|
})
|
|
} catch (error) {
|
|
console.error('Locations GET error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Internal server error' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|