Skip to content

Commit 544ab36

Browse files
committed
Add depedencies, json-server db data.
1 parent d6d29ff commit 544ab36

File tree

5 files changed

+1315
-74
lines changed

5 files changed

+1315
-74
lines changed

.gitignore

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,15 @@
11
# Logs
22
logs
33
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
84

95
# Diagnostic reports (https://nodejs.org/api/report.html)
106
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
117

12-
# Runtime data
13-
pids
14-
*.pid
15-
*.seed
16-
*.pid.lock
17-
18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
26-
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
378
# Compiled binary addons (https://nodejs.org/api/addons.html)
389
build/Release
3910

4011
# Dependency directories
4112
node_modules/
42-
jspm_packages/
4313

4414
# TypeScript v1 declaration files
4515
typings/
@@ -53,52 +23,9 @@ typings/
5323
# Optional eslint cache
5424
.eslintcache
5525

56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
6826
# Yarn Integrity file
6927
.yarn-integrity
7028

7129
# dotenv environment variables file
7230
.env
7331
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
102-
103-
# TernJS port file
104-
.tern-port

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# mock-websocket-json-server
2-
A combination of json and WebSocket capable server, ideal for frontend development.
2+
A json and WebSocket capable server, ideal for frontend development.
3+
4+
This is a base mock-server setup. Taking advantage of the fact that json-server is based on express,
5+
it is combined with the _ws_ package to provide realtime capabilities while mocking.
6+
7+
This implementation utilizes:
8+
1. [Express](https://github.com/expressjs/expressjs.com)
9+
2. [json-server](https://github.com/typicode/json-server)
10+
3. [ws](https://github.com/websockets/ws)
11+
12+
Start the simple json-server with `yarn serve`.
13+
Run `curl http://localhost:3000/transactions` on a separate terminal to retrieve all transaction records.

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "mock-websocket-json-server",
3+
"version": "1.0.0",
4+
"description": "Base mock server with REST and WebSocket support.",
5+
"main": "index.js",
6+
"repository": "https://github.com/Gr3at/mock-websocket-json-server.git",
7+
"author": "Gr3at <33185243+Gr3at@users.noreply.github.com>",
8+
"license": "MIT",
9+
"scripts": {
10+
"serve:json": "json-server --watch src/json-server-db.json"
11+
},
12+
"dependencies": {
13+
"json-server": "^0.17.0",
14+
"ws": "^8.8.0"
15+
}
16+
}

src/json-server-db.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"transactions": [
3+
{
4+
"uuid": "95e45059-cbad-4e6e-8613-df499b4bd217",
5+
"datetime": "2022-06-26T08:00:00Z",
6+
"itemBidPrice": 21.6,
7+
"requestedQuantity": 50,
8+
"boughtQuantity": 50,
9+
"itemAgreedPrice": 22.0,
10+
"priceUnit": ""
11+
},
12+
{
13+
"uuid": "235ac1d7-fbaa-4b3c-ac2b-c7c8f5402471",
14+
"datetime": "2022-06-26T09:00:00Z",
15+
"itemBidPrice": 3.5,
16+
"requestedQuantity": 200,
17+
"boughtQuantity": 190,
18+
"itemAgreedPrice": 3.5,
19+
"priceUnit": ""
20+
},
21+
{
22+
"uuid": "3a5735e1-9f25-44c5-bb2c-0374883ed586",
23+
"datetime": "2022-06-26T10:00:00Z",
24+
"itemBidPrice": 5.2,
25+
"requestedQuantity": 88,
26+
"boughtQuantity": 80,
27+
"itemAgreedPrice": 5.2,
28+
"priceUnit": ""
29+
}
30+
]
31+
}

0 commit comments

Comments
 (0)