-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from marcodejongh/adopt_drizzle_orm
Adopt drizzle orm
- Loading branch information
Showing
34 changed files
with
9,818 additions
and
2,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// POST https://kilterboardapp.com/follows/save HTTP/2 | ||
// host: kilterboardapp.com | ||
// accept: application/json | ||
// content-type: application/x-www-form-urlencoded | ||
// user-agent: Kilter%20Board/300 CFNetwork/1568.200.51 Darwin/24.1.0 | ||
// accept-language: en-AU,en;q=0.9 | ||
// content-length: 50 | ||
// accept-encoding: gzip, deflate, br | ||
// cookie: token=XXXX | ||
|
||
// followee_id=44710&follower_id=118684&state=pending |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BoardName } from '../../../types'; | ||
import { API_HOSTS } from '../types'; | ||
import { auroraGetApi } from '../util'; | ||
|
||
export interface Followee { | ||
id: number; // Unique ID for the followee | ||
username: string; // Username of the followee | ||
name?: string; // Optional name of the followee | ||
avatar_image?: string; // Optional avatar image path | ||
followee_state: string; // State of the followee relationship (e.g., "accepted") | ||
} | ||
|
||
export interface FolloweesResponse { | ||
users: Followee[]; // Array of followees | ||
} | ||
|
||
export async function getFollowees(board: BoardName, userId: number, token: string): Promise<FolloweesResponse> { | ||
// Replace `any` with the specific type for followees if available | ||
const url = `${API_HOSTS[board]}/users/${userId}/followees`; // Adjust the endpoint as needed | ||
const data = await auroraGetApi<FolloweesResponse>(url, token); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// GET https://kilterboardapp.com/users/44710/logbook?types=ascent,bid HTTP/2 | ||
// host: kilterboardapp.com | ||
// accept: application/json | ||
// user-agent: Kilter%20Board/300 CFNetwork/1568.200.51 Darwin/24.1.0 | ||
// accept-language: en-AU,en;q=0.9 | ||
// accept-encoding: gzip, deflate, br | ||
// cookie: token=XXXX | ||
|
||
|
||
|
||
// Common fields for all logbook entries | ||
interface BaseLogbookEntry { | ||
_type: 'bid' | 'ascent'; // Discriminator type, e.g., "bid" or "ascent" | ||
uuid: string; // Unique identifier for the logbook entry | ||
user_id: number; // ID of the user who made the entry | ||
climb_uuid: string; // Unique identifier for the climb | ||
angle: number; // Angle of the climb | ||
is_mirror: boolean; // Indicates if the climb was mirrored | ||
bid_count: number; // Number of bids/attempts | ||
comment: string; // Comment for the entry (empty string if none) | ||
climbed_at: string; // ISO 8601 date string for when the climb occurred | ||
} | ||
|
||
// Logbook entry type for "bid" | ||
export interface BidLogbookEntry extends BaseLogbookEntry { | ||
_type: 'bid'; // Specific type for bid entries | ||
} | ||
|
||
// Logbook entry type for "ascent" | ||
export interface AscentLogbookEntry extends BaseLogbookEntry { | ||
_type: 'ascent'; // Specific type for ascent entries | ||
attempt_id: number; // ID of the attempt (specific to ascents) | ||
quality: number; // Quality rating of the climb (1-5) | ||
difficulty: number; // Difficulty rating of the climb | ||
is_benchmark: boolean; // Indicates if the climb is a benchmark climb | ||
} | ||
|
||
// Union type for all logbook entries | ||
export type LogbookEntry = BidLogbookEntry | AscentLogbookEntry; | ||
|
||
// Response type for the logbook endpoint | ||
export interface LogbookResponse { | ||
logbook: LogbookEntry[]; // Array of logbook entries (union type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { BoardName } from '../../../types'; | ||
import { API_HOSTS } from '../types'; | ||
import { auroraGetApi } from '../util'; | ||
|
||
export interface SocialStats { | ||
followees_accepted: number; | ||
followers_accepted: number; | ||
followers_pending: number; | ||
} | ||
|
||
export interface Logbook { | ||
count: number; // Number of logbook entries | ||
} | ||
|
||
export interface CircuitUser { | ||
id: number; | ||
username: string; | ||
is_verified: boolean; | ||
avatar_image: string | null; | ||
created_at: string; // ISO 8601 date string | ||
} | ||
|
||
export interface Circuit { | ||
uuid: string; | ||
name: string; | ||
description: string; | ||
color: string; | ||
user_id: number; | ||
is_public: boolean; | ||
is_listed: boolean; | ||
created_at: string; | ||
updated_at: string; | ||
user: CircuitUser; | ||
count: number; | ||
} | ||
|
||
export interface User { | ||
id: number; | ||
username: string; | ||
email_address: string; | ||
name: string; | ||
avatar_image: string | null; // Nullable avatar image | ||
instagram_username?: string; // Optional Instagram username | ||
is_public: boolean; // Indicates if the profile is public | ||
is_verified: boolean; // Indicates if the user is verified | ||
created_at: string; // ISO 8601 date string for creation | ||
updated_at: string; // ISO 8601 date string for last update | ||
social: SocialStats; // Social stats (followees, followers, etc.) | ||
logbook: Logbook; // Logbook stats | ||
circuits: Circuit[]; // Array of circuits created by the user | ||
} | ||
|
||
// Avatar url: https://api.kilterboardapp.com/img/avatars/74336-20220729204756.jpg | ||
|
||
export interface UsersResponse { | ||
users: User[]; // List of users | ||
} | ||
|
||
export async function getUser(board: BoardName, userId: number, token: string): Promise<UsersResponse> { | ||
const url = `${API_HOSTS[board]}/users/${userId}`; | ||
const data = await auroraGetApi<UsersResponse>(url, token); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { promisify } from 'util'; | ||
import { unzip } from 'zlib'; | ||
|
||
const unzipAsync = promisify(unzip); | ||
|
||
export function generateUuid(): string { | ||
return uuidv4().replace(/-/g, '').toUpperCase(); | ||
} | ||
|
||
export async function auroraGetApi<T>( | ||
url: string, | ||
token: string, | ||
): Promise<T> { | ||
// Default headers | ||
const headers: Record<string, string> = { | ||
Accept: '*/*', // Accept any content type | ||
'Accept-Encoding': 'gzip, deflate, br', | ||
Host: 'kilterboardapp.com', // Explicitly set the host | ||
'User-Agent': 'Kilter%20Board/300 CFNetwork/1568.200.51 Darwin/24.1.0', // Simulate the specific user-agent | ||
'Accept-Language': 'en-AU,en;q=0.9', // Accept preferred languages | ||
}; | ||
|
||
// Add Authorization header if token is provided | ||
if (token) { | ||
headers['Cookie'] = `token=${token}`; | ||
} | ||
|
||
const fetchOptions: RequestInit = { | ||
method: 'GET', | ||
headers, | ||
}; | ||
|
||
const response = await fetch(url, fetchOptions); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
// Handle compressed responses | ||
const contentEncoding = response.headers.get('content-encoding'); | ||
if (contentEncoding === 'gzip' || contentEncoding === 'br' || contentEncoding === 'deflate') { | ||
const buffer = Buffer.from(await response.arrayBuffer()); | ||
const decompressed = await unzipAsync(buffer); // Decompress asynchronously | ||
return JSON.parse(decompressed.toString()) as T; // Parse JSON from decompressed data | ||
} | ||
|
||
// Handle plain JSON response | ||
return response.json() as Promise<T>; | ||
} |
Oops, something went wrong.
eb9ad78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
boardsesh – ./
kilter-nextjs.vercel.app
boardsesh-marcodejonghs-projects.vercel.app
boardsesh-git-main-marcodejonghs-projects.vercel.app
www.boardsesh.com
boardsesh.com