/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/fast-json-stringify/examples/server.js
42 строки
634 B
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
'use strict' const http = require('http') const stringify = require('fast-json-stringify')({ type: 'object', properties: { hello: { type: 'string' }, data: { type: 'number' }, nested: { type: 'object', properties: { more: { type: 'string' } } } } }) const server = http.createServer(handle) function handle (req, res) { const data = { hello: 'world', data: 42, nested: { more: 'data' } } if (req.url === '/JSON') { res.end(JSON.stringify(data)) } else { res.end(stringify(data)) } } server.listen(3000)