Skip to content

Commit b421f2b

Browse files
committed
Turn on mock mode by default
1 parent a178499 commit b421f2b

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

DENO_README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ A [Deno](https://deno.land) client that can be used by a scraper to ease communi
1717
],
1818
"login_users": [
1919
{"username": "scraping-site-username", "password": "scraping-site-password"}
20-
]
20+
],
21+
// For production, set mock_mode to false
22+
// "mock_mode": false
2123
}
2224
```
2325

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Check file:///.../denoexample.ts
4747
```sh
4848
# Install latest version
4949
go install github.com/script-development/rtcv_scraper_client/v2@latest
50-
# Install a spesific version
50+
# Install a specific version
5151
go install github.com/script-development/rtcv_scraper_client/v2@v2.0.3
5252
```
5353
@@ -67,15 +67,16 @@ Create a `env.json` file with the following content **(this file can also be obt
6767
"login_users": [
6868
{"username": "scraping-site-username", "password": "scraping-site-password"}
6969
],
70-
"mock_mode": true
70+
// For production, set mock_mode to false
71+
// "mock_mode": false
7172
}
7273
```
7374
7475
### *3.* Develop / Deploy a scraper using `rtcv_scraper_client`
7576
7677
You can now prefix your scraper's run command with `rtcv_scraper_client` and the scraper client program will run a webserver as long as your scraper runs where via you can communicate with RT-CV.
7778
78-
Set `"mock_mode": true` in ur env.json for development
79+
By default the program will run in `mock_mode`, for production you'll have to explicitly turn it off by setting `"mock_mode": false` in your env.json
7980
8081
If you have for a NodeJS project you can run your program like this:
8182

main.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,24 @@ func main() {
9797
credentials = append(credentials, server.toCredArg(false))
9898
}
9999

100-
err = api.SetCredentials(credentials)
101-
if err != nil {
102-
log.Fatal(err)
103-
}
100+
// Turn on mock mode by default
101+
api.SetMockMode()
102+
103+
if !env.MockMode {
104+
err = api.SetCredentials(credentials)
105+
if err != nil {
106+
log.Fatal(err)
107+
}
104108

105-
if env.MockMode {
106-
api.SetMockMode()
109+
fmt.Println("credentials set")
110+
fmt.Println("testing connections..")
111+
testServerConnections(api)
112+
fmt.Println("connected to RTCV")
113+
} else {
114+
fmt.Println("In mock mode")
115+
fmt.Println("You can turn this off in by setting mock_mode to false in your env.json")
107116
}
108117

109-
fmt.Println("credentials set")
110-
fmt.Println("testing connections..")
111-
testServerConnections(api)
112-
fmt.Println("connected to RTCV")
113118
fmt.Println("running scraper..")
114119

115120
if len(os.Args) <= 1 {
@@ -136,9 +141,6 @@ func main() {
136141
}
137142

138143
func testServerConnections(api *API) {
139-
if api.MockMode {
140-
return
141-
}
142144
for _, conn := range api.connections {
143145
err := conn.Get("/api/v1/health", nil)
144146
if err != nil {

0 commit comments

Comments
 (0)