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 = {