From 6be6ae4e27336410c84a5de84ff48fc3f1b84c3c Mon Sep 17 00:00:00 2001 From: vexsmart Date: Wed, 18 Mar 2026 16:46:29 -0300 Subject: [PATCH] task solution --- src/createServer.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 1fc5f4e..82748e4 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,9 +1,25 @@ /* eslint-disable no-console */ 'use strict'; +const http = require('http'); + function createServer() { - /* Write your code here */ - // Return instance of http.Server class + const server = http.createServer((req, res) => { + res.writeHead(200, { + 'Content-Type': 'application/json', + }); + + const url = new URL(req.url, 'http://localhost'); + + res.end( + JSON.stringify({ + parts: url.pathname.split('/').filter(Boolean), + query: Object.fromEntries(url.searchParams.entries()), + }), + ); + }); + + return server; } module.exports = {