Skip to content

Commit 0b52f4a

Browse files
authored
Adds gateway option to init (#544)
1 parent 661f6ec commit 0b52f4a

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY package-lock.json /fablo/package-lock.json
1010

1111
# copy files for init network
1212
COPY samples/chaincodes/chaincode-kv-node /fablo/generators/init/templates/chaincodes/chaincode-kv-node
13+
COPY samples/gateway/node /fablo/generators/init/templates/gateway/node
1314

1415
WORKDIR /fablo
1516
RUN npm install --silent --only=prod

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ In this case, however, you should use generated `fablo-docker.sh` instead of `fa
7272
### init
7373

7474
```bash
75-
fablo init [node] [rest] [dev]
75+
fablo init [node] [rest] [dev] [gateway]
7676
```
7777

7878
Creates simple network config file in current dir.
@@ -82,6 +82,7 @@ Fablo `init` command takes three parameters (the order does not matter):
8282
* Option `node` makes Fablo to generate a sample Node.js chaincode as well.
8383
* Option `rest` enables simple REST API with [Fablo REST](https://github.com/fablo-io/fablo-rest) as standalone Docker container.
8484
* Option `dev` enables running peers in dev mode (so the hot reload for chaincode is possible).
85+
* Option `gateway` makes Fablo generate a sample Node.js server that connects to the gateway.
8586

8687
Sample command:
8788

fablo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ printSplash() {
6262
printHelp() {
6363
printSplash
6464
echo "Usage:
65-
fablo init [node] [rest] [dev]
65+
fablo init [node] [rest] [dev] [gateway]
6666
Creates simple Fablo config in current directory with optional Node.js, chaincode and REST API and dev mode.
6767
6868
fablo generate [/path/to/fablo-config.json|yaml [/path/to/fablo/target]]

src/init/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ export default class InitGenerator extends Generator {
9191
fabloConfigJson = { ...fabloConfigJson, chaincodes: [] };
9292
}
9393

94+
const shouldInitWithNodeSampleGateway = this.args.length && this.args.find((v) => v === "gateway");
95+
if (shouldInitWithNodeSampleGateway) {
96+
console.log("Creating sample Node.js gateway");
97+
this.fs.copy(this.templatePath("gateway"), this.destinationPath("gateway"));
98+
}
99+
94100
const shouldAddFabloRest = this.args.length && this.args.find((v) => v === "rest");
95101
if (shouldAddFabloRest) {
96102
const orgs = fabloConfigJson.orgs.map((org) => ({ ...org, tools: { fabloRest: true } }));

0 commit comments

Comments
 (0)