refactor: migrate from Next.js to SolidJS and GraphQL

- Converted web application from Next.js to SolidJS with Vite
- Replaced React components with SolidJS components
- Implemented GraphQL client using URQL
- Added authentication, room, and chat components
- Updated project structure and configuration files
- Removed unnecessary Next.js and docs-related files
- Added Docker support for web and API applications
This commit is contained in:
Juan Sebastián Montoya 2025-03-04 01:08:52 -05:00
parent 8f3aa2fc26
commit 16731409df
81 changed files with 13585 additions and 1163 deletions

View file

@ -0,0 +1,50 @@
import { createClient, fetchExchange, subscriptionExchange } from '@urql/core';
import { createClient as createWSClient } from 'graphql-ws';
// Get API URLs from environment variables
const API_URL =
import.meta.env.VITE_API_URL || 'https://chat-api.jusemon.com/graphql';
const WS_URL =
import.meta.env.VITE_WS_URL || 'wss://chat-api.jusemon.com/graphql';
console.log('Current API_URL', API_URL);
console.log('Current WS_URL', WS_URL);
// Create a WebSocket client for GraphQL subscriptions
const wsClient = createWSClient({
url: WS_URL,
});
// Create the URQL client
export const client = createClient({
url: API_URL,
exchanges: [
fetchExchange,
subscriptionExchange({
forwardSubscription: (operation) => ({
subscribe: (sink) => {
const dispose = wsClient.subscribe(
{
...operation,
query: operation.query || '',
},
sink as any
);
return {
unsubscribe: dispose,
};
},
}),
}),
],
// For development, we'll add a simple header-based authentication
fetchOptions: () => {
const token = localStorage.getItem('token');
const userId = localStorage.getItem('userId');
return {
headers: {
'user-id': userId || '',
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
};
},
});