From c5bcdeca9bf4114b4cdce62ad91fa37341430e8b Mon Sep 17 00:00:00 2001 From: Alina Luchytska Date: Thu, 26 Feb 2026 13:44:53 +0200 Subject: [PATCH] solution --- src/createServer.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/createServer.js b/src/createServer.js index 1fc5f4e..fc62b98 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,9 +1,29 @@ /* eslint-disable no-console */ 'use strict'; +const http = require('http'); + function createServer() { /* Write your code here */ // Return instance of http.Server class + + return http.createServer((req, res) => { + res.writeHead(200, { 'Content-Type': 'application/json' }); + + const url = req.url; + const [path, query] = url.split('?'); + const pathParts = path.split('/').filter(Boolean); + const queryParts = query + ? Object.fromEntries(new URLSearchParams(query)) + : {}; + + res.end( + JSON.stringify({ + parts: pathParts, + query: queryParts, + }), + ); + }); } module.exports = {