From ad2cfa1dbd55068509fa9b5511ecaed76186c4bb Mon Sep 17 00:00:00 2001 From: Alyona Shunevych Date: Mon, 23 Feb 2026 16:31:03 +0200 Subject: [PATCH] Solution --- src/createServer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 1fc5f4e..a2cbea3 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,9 +1,19 @@ /* 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) => { + const url = new URL(req.url, `http://${req.headers.host}`); + const parts = url.pathname.split('/').filter(Boolean); + const query = Object.fromEntries(url.searchParams.entries()); + + res.setHeader('Content-Type', 'application/json'); + res.statusCode = 200; + + res.end(JSON.stringify({ parts, query })); + }); } module.exports = {