Add Diagnostics tab to TV Welcome: view NetUP poll requests in UI
- Rename pull endpoint /travelline → /netup-pms (cleaner branding) - Add GET/DELETE /api/hotels/:slug/netup/log endpoints - TvWelcomePage: new 'Диагностика' tab shows incoming NetUP requests with method, URL, timestamp list + detail panel (headers, query, body) - Remove 'TravelLine' wording from UI, replace with 'Pull-интеграция' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { FastifyPluginAsync } from 'fastify'
|
||||
import { db } from '../db'
|
||||
import { captured } from './travelline'
|
||||
|
||||
type SlugParam = { Params: { slug: string } }
|
||||
type SlugIdParam = { Params: { slug: string; id: string } }
|
||||
@@ -237,8 +238,32 @@ const netup: FastifyPluginAsync = async (fastify) => {
|
||||
},
|
||||
)
|
||||
|
||||
// ── Внутренний хелпер: вызывается из bookings route при смене статуса ───
|
||||
// Экспортируем для использования в bookings.ts
|
||||
// ── GET /api/hotels/:slug/netup/log — просмотр запросов от NetUP ──────────
|
||||
fastify.get<SlugParam>(
|
||||
'/api/hotels/:slug/netup/log',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
async (request, reply) => {
|
||||
const { slug } = request.params
|
||||
if (!canAccess(request.user.hotelSlug, request.user.role, slug)) {
|
||||
return reply.code(403).send({ error: 'Forbidden' })
|
||||
}
|
||||
return { count: captured.length, requests: [...captured].reverse() }
|
||||
},
|
||||
)
|
||||
|
||||
// ── DELETE /api/hotels/:slug/netup/log — очистить лог ────────────────────
|
||||
fastify.delete<SlugParam>(
|
||||
'/api/hotels/:slug/netup/log',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
async (request, reply) => {
|
||||
const { slug } = request.params
|
||||
if (!canAccess(request.user.hotelSlug, request.user.role, slug)) {
|
||||
return reply.code(403).send({ error: 'Forbidden' })
|
||||
}
|
||||
captured.length = 0
|
||||
return { ok: true }
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// ── Отдельная функция для check-in/check-out из bookings.ts ──────────────
|
||||
|
||||
Reference in New Issue
Block a user