Skip to content

Commit 3faacb5

Browse files
authored
Documentation updates (sqlpad#455)
* Split dev guide out of README * Fix INI keys
1 parent b1b0588 commit 3faacb5

4 files changed

Lines changed: 130 additions & 114 deletions

File tree

CONFIGURATION.md

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ These defaults have been removed in version 3.
2323
## Environment Variables
2424
```sh
2525
SQLPAD_CONFIG=
26+
SQLPAD_COOKIE_SECRET=secret-used-to-sign-cookies-please-set-and-make-strong
27+
SQLPAD_SESSION_MINUTES=60
2628
SQLPAD_IP=0.0.0.0
2729
SQLPAD_PORT=80
2830
SQLPAD_SYSTEMD_SOCKET=false
@@ -62,114 +64,122 @@ SAML_AUTH_CONTEXT=
6264
6365
## INI config
6466
```ini
67+
; Secret used to sign cookies
68+
cookieSecret="secret-used-to-sign-cookies-please-set-and-make-strong"
69+
70+
; Minutes to keep a session active. Will extended by this amount each request.
71+
sessionMinutes="60"
72+
6573
; IP address to bind to. By default SQLPad will listen from all available addresses (0.0.0.0).
66-
SQLPAD_IP="0.0.0.0"
74+
ip="0.0.0.0"
6775
6876
; Port for SQLPad to listen on.
69-
SQLPAD_PORT="80"
77+
port="80"
7078
7179
; Acquire socket from systemd if available
72-
SQLPAD_SYSTEMD_SOCKET="false"
80+
systemdSocket="false"
7381
7482
; Port for SQLPad to listen on.
75-
SQLPAD_HTTPS_PORT="443"
83+
httpsPort="443"
7684
7785
; Directory to store SQLPad embedded database content. This includes queries, users, query result cache files, etc.
78-
SQLPAD_DB_PATH=""
86+
dbPath=""
7987
8088
; Path to mount sqlpad app following domain. Example, if '/sqlpad' is provided queries page would be mydomain.com/sqlpad/queries
81-
SQLPAD_BASE_URL=""
89+
baseUrl=""
8290
8391
; A string of text used to encrypt sensitive values when stored on disk.
84-
SQLPAD_PASSPHRASE="At least the sensitive bits won't be plain text?"
92+
passphrase="At least the sensitive bits won't be plain text?"
8593
8694
; Passphrase for your SSL certification file
87-
CERT_PASSPHRASE=""
95+
certPassphrase=""
8896
8997
; Absolute path to where SSL certificate key is stored
90-
KEY_PATH=""
98+
keyPath=""
9199
92100
; Absolute path to where SSL certificate is stored
93-
CERT_PATH=""
101+
certPath=""
94102
95103
; Email address to whitelist/give admin permissions to
96-
SQLPAD_ADMIN=""
104+
admin=""
97105
98106
; Add a variety of logging to console while running SQLPad
99-
SQLPAD_DEBUG="false"
107+
debug="false"
100108
101109
; Google Client ID used for OAuth setup. Authorized redirect URI for sqlpad is '[baseurl]/auth/google/callback'
102-
GOOGLE_CLIENT_ID=""
110+
googleClientId=""
103111
104112
; Google Client Secret used for OAuth setup. Authorized redirect URI for sqlpad is '[baseurl]/auth/google/callback'
105-
GOOGLE_CLIENT_SECRET=""
113+
googleClientSecret=""
106114
107115
; Public URL used for OAuth setup and email links. Protocol expected. Example: https://mysqlpad.com
108-
PUBLIC_URL=""
116+
publicUrl=""
109117
110118
; Set to TRUE to disable built-in user authentication. Use to restrict auth to OAuth only.
111-
DISABLE_USERPASS_AUTH="false"
119+
disableUserpassAuth="false"
112120
113121
; Enable csv and xlsx downloads.
114-
SQLPAD_ALLOW_CSV_DOWNLOAD="true"
122+
allowCsvDownload="true"
115123
116124
; Enable word wrapping in SQL editor.
117-
SQLPAD_EDITOR_WORD_WRAP="false"
125+
editorWordWrap="false"
118126
119127
; By default query results are limited to 50,000 records.
120-
SQLPAD_QUERY_RESULT_MAX_ROWS="50000"
128+
queryResultMaxRows="50000"
121129
122130
; Supply incoming Slack webhook URL to post query when saved.
123-
SQLPAD_SLACK_WEBHOOK=""
131+
slackWebhook=""
124132
125133
; When false, table and chart result links will be operational without login.
126-
SQLPAD_TABLE_CHART_LINKS_REQUIRE_AUTH="true"
134+
tableChartLinksRequireAuth="true"
127135
128136
; From email address for SMTP. Required in order to send invitation emails.
129-
SQLPAD_SMTP_FROM=""
137+
smtpFrom=""
130138
131139
; Host address for SMTP. Required in order to send invitation emails.
132-
SQLPAD_SMTP_HOST=""
140+
smtpHost=""
133141
134142
; Port for SMTP. Required in order to send invitation emails.
135-
SQLPAD_SMTP_PORT=""
143+
smtpPort=""
136144
137145
; Toggle to use secure connection when using SMTP.
138-
SQLPAD_SMTP_SECURE="true"
146+
smtpSecure="true"
139147
140148
; Username for SMTP. Required in order to send invitation emails.
141-
SQLPAD_SMTP_USER=""
149+
smtpUser=""
142150
143151
; Password for SMTP.
144-
SQLPAD_SMTP_PASSWORD=""
152+
smtpPassword=""
145153
146154
; Allows pre-approval of email domains. Delimit multiple domains by empty space.
147-
WHITELISTED_DOMAINS=""
155+
whitelistedDomains=""
148156
149157
; If disabled, SQLPad will no longer poll npmjs.com to see if an update is available.
150-
SQLPAD_DISABLE_UPDATE_CHECK="false"
158+
disableUpdateCheck="false"
151159
152160
; SAML Entry point URL
153-
SAML_ENTRY_POINT=""
161+
samlEntryPoint=""
154162
155163
; SAML Issuer
156-
SAML_ISSUER=""
164+
samlIssuer=""
157165
158166
; SAML callback URL
159-
SAML_CALLBACK_URL=""
167+
samlCallbackUrl=""
160168
161169
; SAML certificate in Base64
162-
SAML_CERT=""
170+
samlCert=""
163171
164172
; SAML authentication context URL
165-
SAML_AUTH_CONTEXT=""
173+
samlAuthContext=""
166174
167175
168176
```
169177
170178
## JSON config
171179
```json
172180
{
181+
"cookieSecret": "secret-used-to-sign-cookies-please-set-and-make-strong",
182+
"sessionMinutes": 60,
173183
"ip": "0.0.0.0",
174184
"port": 80,
175185
"systemdSocket": false,

DEVELOPER-GUIDE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Developer Guide
2+
3+
Follow build guide in README to install dependencies and build an initial build. Once complete, Open 2 terminal sessions in the root of this repo.
4+
5+
In one session run the back end in development mode
6+
7+
```sh
8+
npm start --prefix server
9+
```
10+
11+
In the other start the development server for the front end.
12+
13+
```sh
14+
npm start --prefix client
15+
```
16+
17+
At this point you should have both back end and front end development servers running.
18+
19+
http://localhost:3000 serves React-based frontend in dev-mode
20+
http://localhost:3010 serves frontend compiled for production
21+
22+
When viewing the front end in development mode, the page will automatically refresh on client file changes. The back end server will auto-restart on back end file changes as well.
23+
24+
When viewing SQLPad in dev-mode in port 3000, some features may not work correctly (like csv/xlsx downloads, google auth). This is likely due to the port difference in configuration (google auth can only redirect to 1 url/port) or the dev-mode proxy setup (React dev mode is served by a secondary web server that will proxy requests it doesn't understand to the SQLPad server running on 3010 during development.)
25+
26+
ESLint and Prettier are used to enforce code patterns and formatting in this project. A precommit hook should enforce and warn about these checks. If that is not set up however you may find these terminal commands useful.
27+
28+
```sh
29+
# To check lint
30+
npm run lint
31+
32+
# To fix (some) errors and formatting automatically
33+
npm run fixlint
34+
```
35+
36+
### Mock driver
37+
38+
When SQLPad server is run in debug mode, a mock driver implementation is available to generate data. The data returned by the query run is determined by information parsed from the comment block. The rest of the query may be anything.
39+
40+
Measure fields will contain random data.
41+
42+
```sql
43+
-- At least one dimension field is required. MUST include number of unique values
44+
-- orderdate and orderdatetime should not be used at same time
45+
-- dimensions = department 10, color 10, product 10, orderdate|orderdatetime 500
46+
47+
-- Optional measures
48+
-- measures = cost, revenue, profit
49+
50+
-- Optional order by. MUST be a dimension or measure returned and MUST include direction
51+
-- orderby = department asc, product desc
52+
53+
-- Optional limit
54+
-- limit = 100
55+
56+
SELECT * FROM the_actual_query_doesnt_matter
57+
```

README.md

Lines changed: 27 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,53 @@
44

55
A web app for writing and running SQL queries and visualizing the results. Supports Postgres, MySQL, SQL Server, Crate, Vertica, Presto, and SAP HANA. Other databases potentially supported via [unix odbc support](https://github.com/rickbergfalk/sqlpad/wiki/ODBC).
66

7-
## Installation, Usage, Screenshots
8-
97
![SQLPad Query Editor](https://rickbergfalk.github.io/sqlpad/images/screenshots/v3-beta.png)
108

11-
## Using Docker Image
9+
## Docker Image
1210

1311
The docker image runs on port 3000 and uses `/var/lib/sqlpad` for the embedded database directory.
1412

15-
Some configuration is exposed via environment variables. See [configItems.js](https://github.com/rickbergfalk/sqlpad/blob/master/server/lib/config/configItems.js) for details on environment variables considered (`envVar` field).
13+
For configuration exposed via environment variables reference [CONFIGURATION.md](https://github.com/rickbergfalk/sqlpad/blob/master/CONFIGURATION.md).
1614

17-
See [docker-validation](https://github.com/rickbergfalk/sqlpad/tree/master/docker-validation) folder for example docker-compose setup with SQL Server.
15+
See [docker-validation](https://github.com/rickbergfalk/sqlpad/tree/master/docker-validation) directory for example docker-compose setup with SQL Server.
1816

1917
## Building
2018

19+
- Install node 10 or later
2120
- Clone/download this repo
22-
- Install node 10 or later ([nvm recommended](https://github.com/creationix/nvm))
23-
- Ensure you have the latest npm
21+
- Install dependencies and build the UI
2422

2523
```sh
26-
npm install npm -g
24+
scripts/build.sh
2725
```
2826

29-
- Install dependencies and build the UI
27+
The gist of this script is:
3028

3129
```sh
32-
scripts/build.sh
30+
# install root level dependencies using package-lock.json as reference
31+
npm ci
32+
# install front-end dependencies using package-lock.json
33+
cd client
34+
npm ci
35+
# build front-end
36+
npm run build
37+
# install back-end dependencies
38+
cd ../server
39+
npm ci
40+
cd ..
41+
# copy client build to server directory
42+
mkdir server/public
43+
cp -r client/build/* server/public
3344
```
3445

35-
At this point you can run the SQLPad server with the frontend built for production use:
46+
At this point you can run the SQLPad server with the front-end built for production use:
3647

3748
```sh
3849
cd server
3950
node server.js --dir ../db --port 3010 --base-url '/sqlpad'
4051
```
4152

42-
If prefered, SQLPad can be installed as a global module using the local files in this repo. This allows running SQLPad via the cli in any directory, just as if you had installed it with `npm install sqlpad -g`
53+
If prefered, SQLPad can be installed as a global module using the local files in this repo. This allows running SQLPad via the cli in any directory, just as if you had installed it with `npm install sqlpad -g`. Note that you must build and copy the client prior to this step.
4354

4455
```sh
4556
cd server
@@ -52,75 +63,13 @@ sqlpad --dir ../db --port 3010 --base-url '/sqlpad'
5263

5364
A docker image may be built using the Dockerfile located in `server` directory. See `docker-publish.sh` for example docker build command.
5465

55-
## Development
56-
57-
- Clone/download this repo
58-
- Install node 8 or later ([nvm recommended](https://github.com/creationix/nvm))
59-
- Ensure you have the latest npm
60-
61-
```sh
62-
npm install npm -g
63-
```
66+
## Configuration
6467

65-
- Install dependencies and build the UI
66-
67-
```sh
68-
scripts/build.sh
69-
```
70-
71-
- Open 2 terminal sessions in the root of this repo.
72-
73-
In one install the backend dependencies and start the development server
74-
75-
```sh
76-
npm start --prefix server
77-
```
68+
[CONFIGURATION.md](CONFIGURATION.md)
7869

79-
In the other install frontend dependencies and start the development server
80-
81-
```sh
82-
npm start --prefix client
83-
```
84-
85-
At this point you should have both backend and frontend development servers running.
86-
87-
http://localhost:3000 serves React-based frontend in dev-mode
88-
http://localhost:3010 serves frontend compiled for production
89-
90-
When viewing the frontend in development mode, the page will automatically refresh on frontend file change. The backend server will auto-restart on backend file change.
91-
92-
ESLint and Prettier are used to enforce code patterns and formatting in this project. A precommit hook should enforce and warn about these checks. If that is not set up however you may find these terminal commands useful.
93-
94-
```sh
95-
# To check lint
96-
npm run lint
97-
98-
# To fix (some) errors and formatting automatically
99-
npm run fixlint
100-
```
101-
102-
### Mock driver
103-
104-
When SQLPad server is run in debug mode, a mock driver implementation is available to generate data. The data returned by the query run is determined by information parsed from the comment block. The rest of the query may be anything.
105-
106-
Measure fields will contain random data.
107-
108-
```sql
109-
-- At least one dimension field is required. MUST include number of unique values
110-
-- orderdate and orderdatetime should not be used at same time
111-
-- dimensions = department 10, color 10, product 10, orderdate|orderdatetime 500
112-
113-
-- Optional measures
114-
-- measures = cost, revenue, profit
115-
116-
-- Optional order by. MUST be a dimension or measure returned and MUST include direction
117-
-- orderby = department asc, product desc
118-
119-
-- Optional limit
120-
-- limit = 100
70+
## Development
12171

122-
SELECT * FROM the_actual_query_doesnt_matter
123-
```
72+
[Developer guide](DEVELOPER-GUIDE.md)
12473

12574
## License
12675

scripts/generate-configs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ configItems.forEach(item => {
1313
json[item.key] = item.default;
1414

1515
if (item.description) {
16-
ini += `; ${item.description}\n${item.envVar}="${item.default}"\n\n`
16+
ini += `; ${item.description}\n${item.key}="${item.default}"\n\n`
1717
} else {
18-
ini += `${item.envVar}="${item.default}"\n`
18+
ini += `${item.key}="${item.default}"\n`
1919
}
2020
}
2121
})

0 commit comments

Comments
 (0)