-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: configure http mode development
- Loading branch information
Showing
5 changed files
with
67 additions
and
10 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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
import { getInitialSession, sessionStore } from '../view/stores/session.ts' | ||
import { Driver } from '../src/Domain/Contracts.ts' | ||
import { Driver, DriverType } from '../src/Domain/Contracts.ts' | ||
|
||
export const getInheritDriver = (): Driver => getInitialSession().driver | ||
|
||
export const getSessionDriver = (): Driver => sessionStore.state.driver | ||
|
||
export const isDevelopmentMode = (): boolean => import.meta.env.VITE_DEVELOPMENT_MODE === 'true' | ||
export const getDevelopmentMode = (): DriverType | undefined => { | ||
const type = import.meta.env.VITE_DEVELOPMENT_DRIVER_TYPE | ||
switch (type) { | ||
case 'http': | ||
return DriverType.http | ||
case 'memory': | ||
return DriverType.memory | ||
default: | ||
return undefined | ||
} | ||
} |
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 @@ | ||
services: | ||
quiz-node: | ||
container_name: quiz-node | ||
image: node:20-alpine | ||
working_dir: /var/www | ||
volumes: | ||
- .:/var/www | ||
command: > | ||
sh -c "npm install && npm run dev -- --host" | ||
ports: | ||
- "5173:5173" |
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,33 @@ | ||
import GameRepository from '../../Domain/Game/GameRepository.ts' | ||
import Game from '../../Domain/Game/Game.ts' | ||
import { HttpClientDriverContract } from '../Driver/Http/Contracts.ts' | ||
import HttpClientFactory from '../Driver/Http/HttpClientFactory.ts' | ||
import { Status } from '../../Domain/Contracts.ts' | ||
|
||
export default class HttpGameRepository implements GameRepository { | ||
private http: HttpClientDriverContract | ||
|
||
constructor (factory: HttpClientFactory) { | ||
this.http = factory.make() | ||
} | ||
|
||
static build () { | ||
return new this(new HttpClientFactory()) | ||
} | ||
|
||
async findById (id: number | string): Promise<Game> { | ||
const response = await this.http.get(`/api/v1/games/${id}`) | ||
if (response.status !== Status.success) { | ||
throw new Error(response.message) | ||
} | ||
return response.data as unknown as Game | ||
} | ||
|
||
async paginate (page: number, limit: number): Promise<Game[]> { | ||
const response = await this.http.get(`/api/v1/games?page=${page}&limit=${limit}`) | ||
if (response.status !== Status.success) { | ||
throw new Error(response.message) | ||
} | ||
return response.data as unknown as Game[] | ||
} | ||
} |
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,6 +1,6 @@ | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
import { isDevelopmentMode } from '../../../../config/env.ts' | ||
import { getDevelopmentMode } from '../../../../config/env.ts' | ||
import { Session } from '../../../../src/Domain/Auth/Auth.ts' | ||
import { DriverType } from '../../../../src/Domain/Contracts.ts' | ||
|
||
|
@@ -20,9 +20,10 @@ export function SignInPage () { | |
const { loading } = useLoading() | ||
|
||
const type = session.driver.type === DriverType.supabase ? 'otp' : 'password' | ||
const initial = { | ||
username: isDevelopmentMode() ? '[email protected]' : '', | ||
password: isDevelopmentMode() ? '***************' : '' | ||
const isDevelopment = !!getDevelopmentMode() | ||
const initial: SignInData = { | ||
username: isDevelopment ? '[email protected]' : '', | ||
password: isDevelopment ? '***************' : '' | ||
} | ||
const { | ||
value, | ||
|