diff --git a/src/adoption-code/route/adoption-code.ts b/src/adoption-code/route/adoption-code.ts index cb53a517..d99066a8 100644 --- a/src/adoption-code/route/adoption-code.ts +++ b/src/adoption-code/route/adoption-code.ts @@ -9,10 +9,18 @@ import { codeSender } from '../sender.js'; const handle = async (ctx: Context): Promise => { const request = ctx.request.body as AdoptionCodeRequest; - const result = await codeSender.sendCode(request); + const socket = await codeSender.sendCode(request); ctx.body = { - result, + uuid: socket.data.probe.uuid, + version: socket.data.probe.version, + status: socket.data.probe.status, + city: socket.data.probe.location.city, + country: socket.data.probe.location.country, + latitude: socket.data.probe.location.latitude, + longitude: socket.data.probe.location.longitude, + asn: socket.data.probe.location.asn, + network: socket.data.probe.location.network, }; }; diff --git a/src/adoption-code/sender.ts b/src/adoption-code/sender.ts index f8e37954..b19c485e 100644 --- a/src/adoption-code/sender.ts +++ b/src/adoption-code/sender.ts @@ -7,7 +7,7 @@ import type { AdoptionCodeRequest } from './types.js'; export class CodeSender { constructor (private readonly fetchWsSockets: typeof fetchSockets) {} - async sendCode (request: AdoptionCodeRequest): Promise { + async sendCode (request: AdoptionCodeRequest): Promise { const socket = await this.findSocketByIp(request.ip); if (!socket) { @@ -16,7 +16,7 @@ export class CodeSender { this.sendToSocket(socket, request.code); - return 'Code was sent to the probe.'; + return socket; } private async findSocketByIp (ip: string) { diff --git a/test/tests/integration/adoption-code/adoption-code.test.ts b/test/tests/integration/adoption-code/adoption-code.test.ts index 822981c7..b0283e9c 100644 --- a/test/tests/integration/adoption-code/adoption-code.test.ts +++ b/test/tests/integration/adoption-code/adoption-code.test.ts @@ -37,7 +37,15 @@ describe('Adoption code', () => { }) .expect(200).expect((response) => { expect(response.body).to.deep.equal({ - result: 'Code was sent to the probe.', + uuid: '1-1-1-1-1', + version: '0.14.0', + status: 'initializing', + city: 'Dallas', + country: 'US', + latitude: 32.7831, + longitude: -96.8067, + asn: 20004, + network: 'The Constant Company LLC', }); });