Skip to content

Commit e958dbf

Browse files
committed
Refresh server demos
- microjs demo removed - hapi.js demo does not work in latest version
1 parent 1d7aff4 commit e958dbf

File tree

5 files changed

+59
-109
lines changed

5 files changed

+59
-109
lines changed

demos/server/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.PHONY: init
22
init:
3-
if [ ! -e sheetjs.xlsx ]; then ln -s ../../sheetjs.xlsx; fi
43
mkdir -p node_modules
54
cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd -
65

@@ -12,10 +11,6 @@ request: init ## request demo
1211
express: init ## express demo
1312
node express.js
1413

15-
.PHONY: micro
16-
micro: init ## micro demo
17-
micro -p 7262 micro.js
18-
1914
.PHONY: koa
2015
koa: init ## koa demo
2116
node koa.js

demos/server/README.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@ demo shows a few different strategies applied to different server frameworks.
88
NOTE: these examples merely demonstrate the core concepts and do not include
99
appropriate error checking or other production-level features.
1010

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+
1143
### Node Buffer
1244

1345
The `read` and `write` functions can handle `Buffer` data with `type:"buffer"`.
@@ -64,12 +96,12 @@ expected to handle:
6496
Testing with cURL is straightforward:
6597

6698
```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/
69101
# download data in SYLK format
70102
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
73105
# write sheetjs.xlsb in the XLSB format
74106
curl -X GET http://localhost:7262/?f=sheetjs.xlsb
75107
```
@@ -108,17 +140,6 @@ The main server script is `koa.js` and the worker script is `koasub.js`. State
108140
is maintained in the worker script.
109141

110142

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-
122143

123144
## tiny-worker with hapi
124145

@@ -132,12 +153,12 @@ Note: due to an issue with hapi payload parsing, the route `POST /file` is used
132153
to handle the case of reading from file, so the cURL test is:
133154

134155
```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/
137158
# download data in SYLK format
138159
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
141162
# write sheetjs.xlsb in the XLSB format
142163
curl -X GET http://localhost:7262/?f=sheetjs.xlsb
143164
```

demos/server/micro.js

Lines changed: 0 additions & 85 deletions
This file was deleted.
File renamed without changes.

demos/server/sheetjs.csv

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Text,Number,Rich,Span
2+
This is Bold,123,This is Bold,This is Bold
3+
This is Italic,234,This is Italic,This is Italic
4+
This is Underline,345,This is Underline,This is Underline
5+
This is Stricken,456,This is Stricken,This is Stricken
6+
This is 18 px,567,This is 18 px,This is 18 px
7+
This is superscript,678,This is superscript,This is superscript
8+
This is subscript,789,This is subscript,This is subscript
9+
This is red,135,This is red,This is red
10+
This is green,246,This is green,This is green
11+
This is Times,357,This is Times,This is Times
12+
This is BIU,159,This is 01324576 yes,This is BIU
13+
BG Green,255,White on Blue,Green on Black
14+
Standard Newline,W S,"BR
15+
New line","Pre
16+
New line"
17+
Height,100,px (not pt),yeah
18+
Top Left,80,Middle Center,Bottom Right
19+
Top Right,60,Bottom Center,Bottom Left

0 commit comments

Comments
 (0)