Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions .adonisjs/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
// @ts-nocheck
import type { MakeTuyauRequest, MakeTuyauResponse } from '@tuyau/utils/types'
import type { InferInput } from '@vinejs/vine/types'

type LoginGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/pages/controllers/login_controller.ts').default['render']>
}
type ChatPost = {
request: unknown
response: MakeTuyauResponse<import('../src/features/chat/controllers/chat_controller.ts').default['store']>
}
type GameGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/pages/controllers/home_controller.ts').default['render']>
}
type GameSearchGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/pages/controllers/matchmaking_controller.ts').default['render']>
}
type GameSearchPost = {
request: unknown
response: MakeTuyauResponse<import('../src/features/matchmaking/controllers/search_matchmaking_controller.ts').default['handle']>
}
type GameSearchDelete = {
request: unknown
response: MakeTuyauResponse<import('../src/features/matchmaking/controllers/cancel_matchmaking_controller.ts').default['handle']>
}
type GameSessionIdAcceptGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/matchmaking/controllers/accept_matchmaking_controller.ts').default['handle']>
}
type GameSessionIdReadyGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/game_session/controllers/game_ready_controller.ts').default['handle']>
}
type GameSessionIdGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/pages/controllers/game_session_controller.ts').default['render']>
}
type GameSessionIdAnswerPost = {
request: unknown
response: MakeTuyauResponse<import('../src/features/game_session/controllers/game_answer_controller.ts').default['handle']>
}
type ProfileGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/pages/controllers/profile_controller.ts').default['render']>
}
type AuthIdRedirectGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/auth/controllers/auth_redirect_controller.ts').default['handle']>
}
type AuthIdCallbackGetHead = {
request: unknown
response: MakeTuyauResponse<import('../src/features/auth/controllers/auth_callback_controller.ts').default['handle']>
}
export interface ApiDefinition {
'login': {
'$url': {
};
'$get': LoginGetHead;
'$head': LoginGetHead;
};
'chat': {
'$url': {
};
'$post': ChatPost;
};
'game': {
'$url': {
};
'$get': GameGetHead;
'$head': GameGetHead;
'search': {
'$url': {
};
'$get': GameSearchGetHead;
'$head': GameSearchGetHead;
'$post': GameSearchPost;
'$delete': GameSearchDelete;
};
'session': {
':sessionId': {
'accept': {
'$url': {
};
'$get': GameSessionIdAcceptGetHead;
'$head': GameSessionIdAcceptGetHead;
};
'ready': {
'$url': {
};
'$get': GameSessionIdReadyGetHead;
'$head': GameSessionIdReadyGetHead;
};
'$url': {
};
'$get': GameSessionIdGetHead;
'$head': GameSessionIdGetHead;
'answer': {
'$url': {
};
'$post': GameSessionIdAnswerPost;
};
};
};
};
'profile': {
'$url': {
};
'$get': ProfileGetHead;
'$head': ProfileGetHead;
};
'auth': {
':provider': {
'redirect': {
'$url': {
};
'$get': AuthIdRedirectGetHead;
'$head': AuthIdRedirectGetHead;
};
'callback': {
'$url': {
};
'$get': AuthIdCallbackGetHead;
'$head': AuthIdCallbackGetHead;
};
};
};
}
const routes = [
{
params: [],
name: 'home',
path: '/',
method: ["GET","HEAD"],
types: {} as unknown,
},
{
params: [],
name: 'login',
path: '/login',
method: ["GET","HEAD"],
types: {} as LoginGetHead,
},
{
params: [],
name: 'chat.store',
path: '/chat',
method: ["POST"],
types: {} as ChatPost,
},
{
params: [],
name: 'game',
path: '/game',
method: ["GET","HEAD"],
types: {} as GameGetHead,
},
{
params: [],
name: 'matchmaking',
path: '/game/search',
method: ["GET","HEAD"],
types: {} as GameSearchGetHead,
},
{
params: [],
name: 'game.searchingQueue',
path: '/game/search',
method: ["POST"],
types: {} as GameSearchPost,
},
{
params: [],
name: 'game.cancelQueue',
path: '/game/search',
method: ["DELETE"],
types: {} as GameSearchDelete,
},
{
params: ["sessionId"],
name: 'game.handleAccept',
path: '/game/session/:sessionId/accept',
method: ["GET","HEAD"],
types: {} as GameSessionIdAcceptGetHead,
},
{
params: ["sessionId"],
name: 'game.handleReady',
path: '/game/session/:sessionId/ready',
method: ["GET","HEAD"],
types: {} as GameSessionIdReadyGetHead,
},
{
params: ["sessionId"],
name: 'game.session',
path: '/game/session/:sessionId',
method: ["GET","HEAD"],
types: {} as GameSessionIdGetHead,
},
{
params: ["sessionId"],
name: 'game.handleAnswer',
path: '/game/session/:sessionId/answer',
method: ["POST"],
types: {} as GameSessionIdAnswerPost,
},
{
params: [],
name: 'profile',
path: '/profile',
method: ["GET","HEAD"],
types: {} as ProfileGetHead,
},
{
params: ["provider"],
name: 'auth.redirect',
path: '/auth/:provider/redirect',
method: ["GET","HEAD"],
types: {} as AuthIdRedirectGetHead,
},
{
params: ["provider"],
name: 'auth.callback',
path: '/auth/:provider/callback',
method: ["GET","HEAD"],
types: {} as AuthIdCallbackGetHead,
},
] as const;
export const api = {
routes,
definition: {} as ApiDefinition
}
declare module '@tuyau/inertia/types' {
type InertiaApi = typeof api
export interface Api extends InertiaApi {}
}
Empty file added .adonisjs/index.ts
Empty file.
2 changes: 2 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ TWITCH_CALLBACK_URL=http://localhost:3333/auth/twitch/callback

# Game length in seconds
GAME_LENGTH=90

VITE_API_URL=http://localhost:3333
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ TWITCH_CALLBACK_URL=
# Game length in seconds
GAME_LENGTH=90

VITE_API_URL=http://localhost:3333



1 change: 0 additions & 1 deletion .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ jobs:
docker compose -f ${{ env.COMPOSE_FILE }} up -d redis
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm install-node-deps
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} up -d postgres-test
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm biome-check
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm test
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ FROM node:23.0 AS base
FROM base AS deps
WORKDIR /app
ADD package.json pnpm-lock.yaml ./
RUN npm install -g corepack@latest
RUN corepack enable
RUN pnpm install

# Production only deps stage
FROM base AS production-deps
WORKDIR /app
ADD package.json pnpm-lock.yaml ./
RUN npm install -g corepack@latest
RUN corepack enable
RUN pnpm install --frozen-lockfile --prod

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ init-prod: install docker-prod migrate

.PHONY: reset-db
reset-db: rollback migrate seed

.PHONY: generate-tuyau
generate-tuyau:
node ace tuyau:generate && node --loader ts-node/esm scripts/tuyau_api_tsignore.ts
2 changes: 2 additions & 0 deletions adonisrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig({
() => import('@adonisjs/core/commands'),
() => import('@adonisjs/lucid/commands'),
() => import('adonisjs-scheduler/commands'),
() => import('@tuyau/core/commands'),
],

/*
Expand Down Expand Up @@ -51,6 +52,7 @@ export default defineConfig({
environment: ['console'],
},
() => import('#core/providers/port_provider'),
() => import('@tuyau/core/tuyau_provider'),
],

/*
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": {
"ignoreUnknown": false,
"ignore": ["node_modules", "dist", "build", "public", "resources", ".pnpm-store"]
"ignore": ["node_modules", "dist", "build", "public", "resources", ".pnpm-store", ".adonisjs"]
},
"formatter": {
"enabled": true,
Expand Down
3 changes: 2 additions & 1 deletion config/cors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from '@adonisjs/cors'
import env from '#start/env'

/**
* Configuration options to tweak the CORS policy. The following
Expand All @@ -8,7 +9,7 @@ import { defineConfig } from '@adonisjs/cors'
*/
const corsConfig = defineConfig({
enabled: true,
origin: [],
origin: [env.get('HOST')],
methods: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'],
headers: true,
exposeHeaders: [],
Expand Down
17 changes: 17 additions & 0 deletions config/tuyau.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from '@tuyau/core'

const tuyauConfig = defineConfig({
codegen: {
/**
* Filters the definitions and named routes to be generated
*/
// definitions: {
// only: [],
// }
// routes: {
// only: [],
// }
},
})

export default tuyauConfig
13 changes: 7 additions & 6 deletions docker-compose.tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- .:/app
- node_modules:/app/node_modules
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && pnpm install"]
command: ["npm install -g corepack@latest && corepack enable && pnpm install"]
working_dir: /app

tsc:
Expand All @@ -15,7 +15,7 @@ services:
- node_modules:/app/node_modules
working_dir: /app
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && FORCE_COLOR=1 pnpm typecheck"]
command: ["npm install -g corepack@latest && corepack enable && FORCE_COLOR=1 pnpm typecheck"]

biome-check:
image: node:23.0
Expand All @@ -24,7 +24,7 @@ services:
- node_modules:/app/node_modules
working_dir: /app
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && FORCE_COLOR=1 pnpm lint"]
command: ["npm install -g corepack@latest && corepack enable && FORCE_COLOR=1 pnpm lint"]

biome-check-fix:
image: node:23.0
Expand All @@ -33,7 +33,7 @@ services:
- node_modules:/app/node_modules
working_dir: /app
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && FORCE_COLOR=1 pnpm lint --write"]
command: ["npm install -g corepack@latest && corepack enable && FORCE_COLOR=1 pnpm lint --write"]

build:
image: node:23.0
Expand All @@ -43,7 +43,7 @@ services:
- build:/app/build
working_dir: /app
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && FORCE_COLOR=1 pnpm build"]
command: ["npm install -g corepack@latest && corepack enable && FORCE_COLOR=1 pnpm build"]

test:
image: node:23.0
Expand All @@ -60,7 +60,8 @@ services:
- DB_PORT=7357
entrypoint: [ "sh", "-c" ]
command: ["
corepack enable
npm install -g corepack@latest
&& corepack enable
&& pnpm install
&& npx playwright install chromium
&& npx playwright install-deps
Expand Down
Loading