-
Notifications
You must be signed in to change notification settings - Fork 0
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 #6 from whaaaley/next
Next
- Loading branch information
Showing
48 changed files
with
522 additions
and
294 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
|
||
pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
nodejs_20 | ||
]; | ||
|
||
shellHook = '' | ||
echo "🚀 Starting whaleybar client..." | ||
npm run dev | ||
''; | ||
} |
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
File renamed without changes.
File renamed without changes.
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,4 +1,2 @@ | ||
export { emojiQueries } from './emojiQueries' | ||
export { weatherQueries } from './weatherQueries' | ||
export * as logStreamQueries from './logStreamQueries' | ||
export * from './weatherQueries' | ||
export * as logStreamQueries from './logStream.queries' | ||
export * as weatherQueries from './weather.queries' |
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,51 @@ | ||
import { type LogRequestSchema, logResponseSchema, messageSchema } from '$models/logStream.model' | ||
import { makeRequest } from '~/io/streams/fetch.streams' | ||
import { connect, disconnect } from '~/io/streams/sse.streams' | ||
|
||
export type LogResponseSchema = z.infer<typeof logResponseSchema> | ||
export type MessageSchema = z.infer<typeof messageSchema> | ||
|
||
type NextFn = (data: unknown) => void | ||
|
||
let lastNext: NextFn | undefined | ||
|
||
export const connectLogs = async (next: NextFn) => { | ||
lastNext = next | ||
|
||
const data = await connect({ | ||
url: '/stream/logs', | ||
messageSchema, | ||
next, | ||
error: (err) => { throw err }, | ||
}) | ||
|
||
return [data] as Promise<MessageSchema>[] | ||
} | ||
|
||
export const disconnectLogs = () => { | ||
disconnect({ url: '/stream/logs' }) | ||
} | ||
|
||
export const reconnectLogs = async (next?: NextFn) => { | ||
disconnectLogs() | ||
|
||
if (!next && !lastNext) { | ||
throw new Error('Next function is not defined') | ||
} | ||
|
||
return connectLogs(next ?? lastNext!) | ||
} | ||
|
||
export const sendLog = async (params: LogRequestSchema) => { | ||
const data = await makeRequest({ | ||
method: 'POST', | ||
url: '/api/log', | ||
responseSchema: logResponseSchema, | ||
body: JSON.stringify(params), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
|
||
return data as Promise<LogResponseSchema> | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type WeatherRequest, type WeatherResponse, weatherResponseSchema } from '$models/weather.model' | ||
import { makeRequest } from '~/io/streams/fetch.streams' | ||
|
||
// Type casting with 'as Promise<WeatherResponse>' is safe here because: | ||
// 1. The Zod schema (WeatherResponseSchema) validates the data at runtime | ||
// 2. If the API returns invalid data, Zod's parse() will throw regardless of the type cast | ||
// 3. The cast just helps TypeScript understand the shape of the data after Zod validates it | ||
export const getWeather = async (params: WeatherRequest) => { | ||
const data = await makeRequest({ | ||
method: 'GET', | ||
url: '/api/weather', | ||
queryString: params, | ||
responseSchema: weatherResponseSchema, | ||
headers: { | ||
'Cache-Control': 'public, max-age=3600, immutable', | ||
}, | ||
}) | ||
|
||
return data as Promise<WeatherResponse> | ||
} |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
client/src/io/streams/ajaxStreams.ts → client/src/io/streams/fetch.streams.ts
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
4 changes: 2 additions & 2 deletions
4
client/src/io/streams/sseStreams.ts → client/src/io/streams/sse.streams.ts
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
File renamed without changes.
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
Oops, something went wrong.