We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2cff1fc commit 39f6de9Copy full SHA for 39f6de9
server.js
@@ -0,0 +1,42 @@
1
+'use strict'
2
+
3
+const http = require('http')
4
5
+const stringify = require('.')({
6
+ type: 'object',
7
+ properties: {
8
+ hello: {
9
+ type: 'string'
10
+ },
11
+ data: {
12
+ type: 'number'
13
14
+ nested: {
15
16
17
+ more: {
18
19
+ }
20
21
22
23
+})
24
25
+const server = http.createServer(handle)
26
27
+function handle (req, res) {
28
+ const data = {
29
+ hello: 'world',
30
+ data: 42,
31
32
+ more: 'data'
33
34
35
+ if (req.url === '/JSON') {
36
+ res.end(JSON.stringify(data))
37
+ } else {
38
+ res.end(stringify(data))
39
40
+}
41
42
+server.listen(3000)
0 commit comments