Moved types to folder

This commit is contained in:
Alexis
2026-03-24 21:51:58 +01:00
parent 5a52b08107
commit 2685a7c868
4 changed files with 44 additions and 41 deletions

View File

@@ -1,50 +1,11 @@
<script lang="ts" setup>
import type { ApiResponse } from '@/types/Api'
import type { BikeParking } from '@/types/Bikes'
import { ref } from 'vue'
const BASE_URL = 'https://data.rennesmetropole.fr/api/explore/v2.1/catalog/datasets/parkings_velos_sur_rennes_metropole/records'
const LIMIT = 100
interface GeoPoint {
lon: number
lat: number
}
interface GeoShape {
type: 'Feature'
geometry: {
coordinates: [number, number]
type: 'Point'
}
properties: Record<string, unknown>
}
interface BikeParking {
geo_point_2d: GeoPoint
geo_shape: GeoShape
gml_id: string
id_parc_velo: number
nom: string | null
code_insee: number
nom_commune: string
nom_voie: string
id_voie: number
type: string
gestionnaire: string
localisation: string
condition_acces: string
annee_mes: number
nb_support_std: number | null
nb_support_cargo: number | null
nb_total_place: number
date_maj: string
commentaire: string | null
}
interface ApiResponse {
total_count: number
results: BikeParking[]
}
const res = ref<BikeParking[]>([])
const firstPage = await fetch(`${BASE_URL}?limit=${LIMIT}`).then(r => r.json()) as ApiResponse

6
src/types/Api.ts Normal file
View File

@@ -0,0 +1,6 @@
import type { BikeParking } from './Bikes'
export interface ApiResponse {
total_count: number
results: BikeParking[]
}

23
src/types/Bikes.ts Normal file
View File

@@ -0,0 +1,23 @@
import type { GeoPoint, GeoShape } from './Geo'
export interface BikeParking {
geo_point_2d: GeoPoint
geo_shape: GeoShape
gml_id: string
id_parc_velo: number
nom: string | null
code_insee: number
nom_commune: string
nom_voie: string
id_voie: number
type: string
gestionnaire: string
localisation: string
condition_acces: string
annee_mes: number
nb_support_std: number | null
nb_support_cargo: number | null
nb_total_place: number
date_maj: string
commentaire: string | null
}

13
src/types/Geo.ts Normal file
View File

@@ -0,0 +1,13 @@
export interface GeoPoint {
lon: number
lat: number
}
export interface GeoShape {
type: 'Feature'
geometry: {
coordinates: [number, number]
type: 'Point'
}
properties: Record<string, unknown>
}