chore: move types to separate file
This commit is contained in:
parent
ba7a0e04c8
commit
bd229982f6
5 changed files with 29 additions and 37 deletions
|
@ -1,29 +1,3 @@
|
|||
import type { GeoJSON } from "leaflet";
|
||||
|
||||
export interface GameOptions {
|
||||
mode: "easy" | "hard" | "extreme demon ultra miguel";
|
||||
metro: boolean;
|
||||
tram: boolean;
|
||||
}
|
||||
|
||||
export interface GameData {
|
||||
lines: [GeoJSON.Feature, string][];
|
||||
stops: [number, number][];
|
||||
stopName: string;
|
||||
gameId: string;
|
||||
}
|
||||
|
||||
export interface CheckData {
|
||||
gameId: string;
|
||||
latlng: [number, number];
|
||||
}
|
||||
|
||||
export interface CheckResponse {
|
||||
solution: [number, number];
|
||||
distance: number;
|
||||
score: number;
|
||||
}
|
||||
|
||||
type FetchType = typeof fetch;
|
||||
|
||||
const metroUrl =
|
||||
|
|
23
src/lib/types.ts
Normal file
23
src/lib/types.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
export interface GameOptions {
|
||||
mode: "easy" | "hard" | "extreme demon ultra miguel";
|
||||
metro: boolean;
|
||||
tram: boolean;
|
||||
}
|
||||
|
||||
export interface GameData {
|
||||
lines: [GeoJSON.Feature, string][];
|
||||
stops: [number, number][];
|
||||
stopName: string;
|
||||
gameId: string;
|
||||
}
|
||||
|
||||
export interface CheckData {
|
||||
gameId: string;
|
||||
latlng: [number, number];
|
||||
}
|
||||
|
||||
export interface CheckResponse {
|
||||
solution: [number, number];
|
||||
distance: number;
|
||||
score: number;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { stopGame, type CheckData, type CheckResponse } from "$lib";
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { stopGame } from "$lib";
|
||||
import type { RequestHandler } from "./$types";
|
||||
import type { CheckData, CheckResponse } from "$lib/types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, platform }) => {
|
||||
const kv = platform?.env?.TCL_GUESSR_KV;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
import type { PageServerLoad } from "./$types";
|
||||
import { error } from "@sveltejs/kit";
|
||||
import {
|
||||
createGame,
|
||||
getMergedStops,
|
||||
getMetro,
|
||||
getTram,
|
||||
type GameData,
|
||||
type GameOptions,
|
||||
} from "$lib";
|
||||
import { createGame, getMergedStops, getMetro, getTram } from "$lib";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
import type { GameData, GameOptions } from "$lib/types";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, url, platform }) => {
|
||||
const kv = platform?.env?.TCL_GUESSR_KV;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type { CheckData, CheckResponse } from "$lib";
|
||||
import type { CheckData, CheckResponse } from "$lib/types";
|
||||
import type { PageData } from "./$types";
|
||||
import L from "leaflet";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue