Compare commits

...

3 Commits

Author SHA1 Message Date
08f5b0789f fix: NPC controller — charger character depuis req.user (pas req.character)
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 38s
2026-04-28 18:58:45 +02:00
bab73ae341 fix: CI pm2 start-or-reload — crée le process s'il n'existe pas
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 39s
2026-04-28 18:41:27 +02:00
a3ee7e7bc1 fix: CI pm2 reload sous root au lieu de tetardtek-brain
Some checks failed
CI/CD — Build & Deploy / Build & Deploy (push) Failing after 22s
2026-04-28 18:34:20 +02:00
3 changed files with 25 additions and 9 deletions

View File

@@ -31,7 +31,9 @@ jobs:
- name: Restart pm2
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
su - tetardtek-brain -c 'pm2 reload tetardpg-backend --update-env'
pm2 describe tetardpg-backend >/dev/null 2>&1 \
&& pm2 reload tetardpg-backend --update-env \
|| (cd /var/www/tetardpg/backend && pm2 start dist/main.js --name tetardpg-backend && pm2 save)
# ── Frontend ─────────────────────────────────────────────────────────────
- name: Install & build frontend

View File

@@ -1,23 +1,36 @@
import { Controller, Get, Query, Req, UseGuards } from '@nestjs/common';
import { Controller, Get, Query, Req, UseGuards, BadRequestException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { NpcService } from './npc.service';
import { AuthGuard } from '../auth/guards/auth.guard';
import { Character } from '../character/entities/character.entity';
@Controller('npcs')
@UseGuards(AuthGuard)
export class NpcController {
constructor(private readonly npcService: NpcService) {}
constructor(
private readonly npcService: NpcService,
@InjectRepository(Character)
private readonly characterRepo: Repository<Character>,
) {}
private async getCharacter(req: any) {
const character = await this.characterRepo.findOne({ where: { userId: req.user.id } });
if (!character) throw new BadRequestException('Aucun personnage trouvé');
return character;
}
/** GET /api/npcs — tous les PNJ visibles pour le joueur */
@Get()
async getAll(@Req() req: any) {
const { characterId, level } = req.character;
return this.npcService.getVisibleNpcs(characterId, level);
const char = await this.getCharacter(req);
return this.npcService.getVisibleNpcs(char.id, char.level);
}
/** GET /api/npcs?location=village_plaza — PNJ d'un emplacement */
/** GET /api/npcs/location?location=village_plaza — PNJ d'un emplacement */
@Get('location')
async getByLocation(@Req() req: any, @Query('location') location: string) {
const { characterId, level } = req.character;
return this.npcService.getNpcsByLocation(characterId, level, location);
const char = await this.getCharacter(req);
return this.npcService.getNpcsByLocation(char.id, char.level, location);
}
}

View File

@@ -4,10 +4,11 @@ import { Npc } from './npc.entity';
import { NpcController } from './npc.controller';
import { NpcService } from './npc.service';
import { PlayerQuestArc } from '../quest/player-quest-arc.entity';
import { Character } from '../character/entities/character.entity';
import { AuthModule } from '../auth/auth.module';
@Module({
imports: [TypeOrmModule.forFeature([Npc, PlayerQuestArc]), AuthModule],
imports: [TypeOrmModule.forFeature([Npc, PlayerQuestArc, Character]), AuthModule],
controllers: [NpcController],
providers: [NpcService],
exports: [NpcService],