@@ -8,6 +8,38 @@ demo shows a few different strategies applied to different server frameworks.
8
8
NOTE: these examples merely demonstrate the core concepts and do not include
9
9
appropriate error checking or other production-level features.
10
10
11
+
12
+ ### Express Setup
13
+
14
+ The following commands are required in order to test the [ Express] ( https://github.com/expressjs/express ) demo:
15
+
16
+ ``` bash
17
+ npm install express printj xlsx express-formidable
18
+ node express.js
19
+ ```
20
+
21
+ ### Koa Setup
22
+
23
+ The following commands are required in order to test the [ Koa] ( https://github.com/koajs/koa ) demo:
24
+
25
+ ``` bash
26
+ npm install koa printj formidable xlsx
27
+ node koa.js
28
+ ```
29
+
30
+ ### Hapi Setup
31
+
32
+ ** Note: Hapi demo as written only works with Hapi version 16 and below.**
33
+
34
+ The following commands are required in order to test the [ Hapi] ( https://github.com/hapijs/hapi ) demo:
35
+
36
+ ``` bash
37
+ npm install
[email protected] printj tiny-worker xlsx
38
+ node hapi.js
39
+ ```
40
+
41
+
42
+
11
43
### Node Buffer
12
44
13
45
The ` read ` and ` write ` functions can handle ` Buffer ` data with ` type:"buffer" ` .
@@ -64,12 +96,12 @@ expected to handle:
64
96
Testing with cURL is straightforward:
65
97
66
98
``` bash
67
- # upload test.xls and update data
68
- curl -X POST -F " data=@test.xls " http://localhost:7262/
99
+ # upload sheetjs.csv and update data
100
+ curl -X POST -F " data=@sheetjs.csv " http://localhost:7262/
69
101
# download data in SYLK format
70
102
curl -X GET http://localhost:7262/? t=slk
71
- # read sheetjs.xlsx from the server directory
72
- curl -X POST http://localhost:7262/? f=sheetjs.xlsx
103
+ # read sheetjs.csv from the server directory
104
+ curl -X POST http://localhost:7262/? f=sheetjs.csv
73
105
# write sheetjs.xlsb in the XLSB format
74
106
curl -X GET http://localhost:7262/? f=sheetjs.xlsb
75
107
```
@@ -108,17 +140,6 @@ The main server script is `koa.js` and the worker script is `koasub.js`. State
108
140
is maintained in the worker script.
109
141
110
142
111
- ## command-line utility with micro
112
-
113
- The npm module ships with the ` xlsx ` command line tool. For global installs, the
114
- script ` bin/xlsx.njs ` is added to a directory in ` PATH ` . For local installs, the
115
- appropriate script or symbolic link is set up in ` node_modules/.bin/ ` .
116
-
117
- The ` --arrays ` option directs ` xlsx ` to generate an array of arrays that can be
118
- parsed by the server. To generate files, the ` json2csv ` module exports the JS
119
- array of arrays to a CSV, the server writes the file, and the ` xlsx ` command is
120
- used to generate files of different formats.
121
-
122
143
123
144
## tiny-worker with hapi
124
145
@@ -132,12 +153,12 @@ Note: due to an issue with hapi payload parsing, the route `POST /file` is used
132
153
to handle the case of reading from file, so the cURL test is:
133
154
134
155
``` bash
135
- # upload test.xls and update data
136
- curl -X POST -F " data=@test.xls " http://localhost:7262/
156
+ # upload sheetjs.csv and update data
157
+ curl -X POST -F " data=@sheetjs.csv " http://localhost:7262/
137
158
# download data in SYLK format
138
159
curl -X GET http://localhost:7262/? t=slk
139
- # read sheetjs.xlsx from the server directory
140
- curl -X POST http://localhost:7262/file? f=sheetjs.xlsx
160
+ # read sheetjs.csv from the server directory
161
+ curl -X POST http://localhost:7262/file? f=sheetjs.csv
141
162
# write sheetjs.xlsb in the XLSB format
142
163
curl -X GET http://localhost:7262/? f=sheetjs.xlsb
143
164
```
0 commit comments