fighting git conflicts
This commit is contained in:
parent
e36d41a7c4
commit
575464f65b
4 changed files with 142 additions and 51 deletions
65
src/pnpm-lock.yaml
generated
65
src/pnpm-lock.yaml
generated
|
|
@ -239,16 +239,56 @@ importers:
|
|||
|
||||
tic-tac-toe:
|
||||
dependencies:
|
||||
fastify-socket.io:
|
||||
'@fastify/autoload':
|
||||
specifier: ^6.3.1
|
||||
version: 6.3.1
|
||||
'@fastify/formbody':
|
||||
specifier: ^8.0.2
|
||||
version: 8.0.2
|
||||
'@fastify/multipart':
|
||||
specifier: ^9.3.0
|
||||
version: 9.3.0
|
||||
'@fastify/sensible':
|
||||
specifier: ^6.0.4
|
||||
version: 6.0.4
|
||||
'@fastify/static':
|
||||
specifier: ^8.3.0
|
||||
version: 8.3.0
|
||||
'@fastify/websocket':
|
||||
specifier: ^11.2.0
|
||||
version: 11.2.0
|
||||
fastify:
|
||||
specifier: ^5.6.2
|
||||
version: 5.6.2
|
||||
fastify-plugin:
|
||||
specifier: ^5.1.0
|
||||
version: 5.1.0(fastify@5.6.2)(socket.io@4.8.1)
|
||||
version: 5.1.0
|
||||
socket.io:
|
||||
specifier: ^4.8.1
|
||||
version: 4.8.1
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
typebox:
|
||||
specifier: ^1.0.63
|
||||
version: 1.0.63
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^22.19.3
|
||||
version: 22.19.3
|
||||
rollup-plugin-node-externals:
|
||||
specifier: ^8.1.2
|
||||
version: 8.1.2(rollup@4.53.5)
|
||||
vite:
|
||||
specifier: ^7.3.0
|
||||
version: 7.3.0(@types/node@22.19.3)(yaml@2.8.2)
|
||||
vite-tsconfig-paths:
|
||||
specifier: ^5.1.4
|
||||
version: 5.1.4(typescript@5.9.3)(vite@7.3.0(@types/node@22.19.3)(yaml@2.8.2))
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
|
||||
user:
|
||||
dependencies:
|
||||
|
|
@ -1771,18 +1811,9 @@ packages:
|
|||
resolution: {integrity: sha512-7Jsfj2uLuGWvnxjrGDrHWpSm65+OcVx0ZbTD2wwkz6Wt6KjGm6+ZYwwpdXdwAlzbJYq+LCEMNvDJc4485AQ1vQ==}
|
||||
hasBin: true
|
||||
|
||||
fastify-plugin@4.5.1:
|
||||
resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==}
|
||||
|
||||
fastify-plugin@5.1.0:
|
||||
resolution: {integrity: sha512-FAIDA8eovSt5qcDgcBvDuX/v0Cjz0ohGhENZ/wpc3y+oZCY2afZ9Baqql3g/lC+OHRnciQol4ww7tuthOb9idw==}
|
||||
|
||||
fastify-socket.io@5.1.0:
|
||||
resolution: {integrity: sha512-GC1gjrxBGeTbMWV779XHF4uw3AtgKwSQJ9MnjGiMp91ZBuPXEdBYa7NnAMDEl3oZPgK9JO4BlNncTV+UAN+1kg==}
|
||||
peerDependencies:
|
||||
fastify: 4.x.x
|
||||
socket.io: '>=4'
|
||||
|
||||
fastify@5.6.2:
|
||||
resolution: {integrity: sha512-dPugdGnsvYkBlENLhCgX8yhyGCsCPrpA8lFWbTNU428l+YOnLgYHR69hzV8HWPC79n536EqzqQtvhtdaCE0dKg==}
|
||||
|
||||
|
|
@ -4512,17 +4543,8 @@ snapshots:
|
|||
semver: 7.7.3
|
||||
yargs-parser: 22.0.0
|
||||
|
||||
fastify-plugin@4.5.1: {}
|
||||
|
||||
fastify-plugin@5.1.0: {}
|
||||
|
||||
fastify-socket.io@5.1.0(fastify@5.6.2)(socket.io@4.8.1):
|
||||
dependencies:
|
||||
fastify: 5.6.2
|
||||
fastify-plugin: 4.5.1
|
||||
socket.io: 4.8.1
|
||||
tslib: 2.8.1
|
||||
|
||||
fastify@5.6.2:
|
||||
dependencies:
|
||||
'@fastify/ajv-compiler': 4.0.5
|
||||
|
|
@ -5637,6 +5659,7 @@ snapshots:
|
|||
|
||||
tslib@2.6.2: {}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
|
@ -5645,6 +5668,8 @@ snapshots:
|
|||
tslib@2.8.1: {}
|
||||
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
tunnel-agent@0.6.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
"packageManager": "pnpm@10.24.0",
|
||||
"dependencies": {
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
"@fastify/autoload": "^6.3.1",
|
||||
"@fastify/formbody": "^8.0.2",
|
||||
"@fastify/multipart": "^9.3.0",
|
||||
|
|
@ -32,9 +35,12 @@
|
|||
"rollup-plugin-node-externals": "^8.1.2",
|
||||
"vite": "^7.3.0",
|
||||
"vite-tsconfig-paths": "^5.1.4"
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"fastify-socket.io": "^5.1.0",
|
||||
"socket.io": "^4.8.1"
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
import { TTC } from './game';
|
||||
import { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
||||
import fastifyFormBody from '@fastify/formbody';
|
||||
|
|
@ -100,58 +101,113 @@ async function onReady(fastify: FastifyInstance, game: TTC) {
|
|||
=======
|
||||
import { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
||||
import fastifySocketIO from 'fastify-socket.io';
|
||||
=======
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
import { TTC } from './game';
|
||||
import { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
||||
import fastifyFormBody from '@fastify/formbody';
|
||||
import fastifyMultipart from '@fastify/multipart';
|
||||
import * as db from '@shared/database';
|
||||
import * as auth from '@shared/auth';
|
||||
import * as swagger from '@shared/swagger';
|
||||
import * as utils from '@shared/utils';
|
||||
import { Server } from 'socket.io';
|
||||
|
||||
const app: FastifyPluginAsync = async (fastify: FastifyInstance, opts): Promise<void> => {
|
||||
declare const __SERVICE_NAME: string;
|
||||
|
||||
// @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this...
|
||||
const plugins = import.meta.glob('./plugins/**/*.ts', { eager: true });
|
||||
// @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this...
|
||||
const routes = import.meta.glob('./routes/**/*.ts', { eager: true });
|
||||
|
||||
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
|
||||
void opts;
|
||||
await fastify.register(fastifySocketIO, {
|
||||
cors: {
|
||||
origin: '*',
|
||||
methods: ['GET', 'POST'],
|
||||
},
|
||||
});
|
||||
|
||||
await fastify.register(utils.useMonitoring);
|
||||
await fastify.register(utils.useMakeResponse);
|
||||
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
|
||||
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
||||
await fastify.register(auth.jwtPlugin as FastifyPluginAsync, {});
|
||||
await fastify.register(auth.authPlugin as FastifyPluginAsync, {});
|
||||
|
||||
// Place here your custom code!
|
||||
for (const plugin of Object.values(plugins)) {
|
||||
void fastify.register(plugin as FastifyPluginAsync, {});
|
||||
}
|
||||
for (const route of Object.values(routes)) {
|
||||
void fastify.register(route as FastifyPluginAsync, {});
|
||||
}
|
||||
|
||||
void fastify.register(fastifyFormBody, {});
|
||||
void fastify.register(fastifyMultipart, {});
|
||||
|
||||
const game = new TTC();
|
||||
|
||||
fastify.ready().then(() => {
|
||||
fastify.io.on('connection', (socket) => {
|
||||
fastify.log.info(`Client connected: ${socket.id}`);
|
||||
fastify.ready((err) => {
|
||||
if (err) throw err;
|
||||
onReady(fastify, game);
|
||||
});
|
||||
};
|
||||
export default app;
|
||||
export { app };
|
||||
|
||||
socket.emit('gameState', {
|
||||
board: game.board,
|
||||
turn: game.currentPlayer,
|
||||
gameOver: game.isGameOver,
|
||||
});
|
||||
// When using .decorate you have to specify added properties for Typescript
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
io: Server<{
|
||||
hello: (message: string) => string;
|
||||
// idk you put something
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
gameState: any;
|
||||
makeMove: (idx: number) => void;
|
||||
resetGame: () => void;
|
||||
error: string,
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
socket.on('makeMove', (idx: number) => {
|
||||
const result = game.makeMove(idx);
|
||||
async function onReady(fastify: FastifyInstance, game: TTC) {
|
||||
fastify.io.on('connection', (socket) => {
|
||||
fastify.log.info(`Client connected: ${socket.id}`);
|
||||
|
||||
if (result === 'invalidMove') {
|
||||
socket.emit('error', 'Invalid Move');
|
||||
}
|
||||
else {
|
||||
fastify.io.emit('gameState', {
|
||||
board: game.board,
|
||||
turn: game.currentPlayer,
|
||||
lastResult: result,
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.emit('gameState', {
|
||||
board: game.board,
|
||||
turn: game.currentPlayer,
|
||||
gameOver: game.isGameOver,
|
||||
});
|
||||
|
||||
socket.on('resetGame', () => {
|
||||
game.reset();
|
||||
socket.on('makeMove', (idx: number) => {
|
||||
const result = game.makeMove(idx);
|
||||
|
||||
if (result === 'invalidMove') {
|
||||
socket.emit('error', 'Invalid Move');
|
||||
}
|
||||
else {
|
||||
fastify.io.emit('gameState', {
|
||||
board: game.board,
|
||||
turn: game.currentPlayer,
|
||||
reset: true,
|
||||
lastResult: result,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('resetGame', () => {
|
||||
game.reset();
|
||||
fastify.io.emit('gameState', {
|
||||
board: game.board,
|
||||
turn: game.currentPlayer,
|
||||
reset: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
};
|
||||
|
||||
export default app;
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
}
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
|
||||
// // TODO: Import the plugins defined for this microservice
|
||||
// // TODO: Import the routes defined for this microservice
|
||||
|
|
|
|||
|
|
@ -79,7 +79,11 @@ export class TTC {
|
|||
return result;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> 16e6ae0 ((schism): started separating backend from frontend)
|
||||
=======
|
||||
}
|
||||
>>>>>>> c741c20 (fixed things)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue