| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/api.pda.the-word.com/tests/ |
Upload File : |
const assert = require('node:assert/strict');
const test = require('node:test');
const { buildEvent } = require('../server');
test('buildEvent maps Node requests to the existing Lambda event shape', () => {
const event = buildEvent({
method: 'GET',
url: '/students?pageSize=50&afterCursor=12',
headers: {
host: 'api.example.test',
'x-api-token': 'token'
},
socket: {
remoteAddress: '127.0.0.1'
}
}, '');
assert.equal(event.httpMethod, 'GET');
assert.equal(event.rawPath, '/students');
assert.equal(event.path, '/students');
assert.deepEqual(event.queryStringParameters, {
pageSize: '50',
afterCursor: '12'
});
assert.equal(event.headers['x-api-token'], 'token');
assert.equal(event.body, undefined);
assert.equal(event.requestContext.http.sourceIp, '127.0.0.1');
});
test('buildEvent preserves JSON request bodies', () => {
const body = JSON.stringify({ email: 'test@example.com' });
const event = buildEvent({
method: 'POST',
url: '/auth/login',
headers: {
host: 'api.example.test',
'content-type': 'application/json'
},
socket: {}
}, body);
assert.equal(event.httpMethod, 'POST');
assert.equal(event.rawPath, '/auth/login');
assert.equal(event.body, body);
});