Skip to content

Commit c7e22a5

Browse files
committed
update docs for env args
1 parent 7f09650 commit c7e22a5

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,30 @@ npm install
2626

2727
### Step 2: add your configuration
2828

29-
Add your Postgres connection information to `config/index.json.txt` and rename it `index.json`. Information on the config options can be found [here](config/README.md).
29+
Dirt is configured via environmental variables. These variables can be placed in a `.env` file in the project's root folder, via the command line at run time, or however you set environmental variables on your operating system. The only environmental variable that must be set is `POSTGRES_CONNECTION`, which contains your postgres login information.
30+
31+
#### `.env` file
32+
```env
33+
POSTGRES_CONNECTION="postgres://user:password@server/database"
34+
```
35+
36+
#### command line, linux and mac
37+
```
38+
POSTGRES_CONNECTION="postgres://user:password@server/database" npm start
39+
```
40+
41+
This is the complete complete list of environmental variables that can be set.
42+
43+
| Variable | Required | Default | Description |
44+
| ----------- | ----------- | ----------- | ----------- |
45+
| POSTGRES_CONNECTION | Yes | N/A | Postgres connection string |
46+
| SERVER_LOGGER | No | false | Turn on Fastify's [error logger](https://www.fastify.io/docs/latest/Reference/Logging/) |
47+
| SERVER_HOST | No | 0.0.0.0 | IP to [listen](https://www.fastify.io/docs/latest/Reference/Server/#listen) on, default is all |
48+
| SERVER_PORT | No | 3000 | Port to [listen](https://www.fastify.io/docs/latest/Reference/Server/#listen) on |
49+
| CACHE_PRIVACY | No | private | [Cache response directive](https://github.com/fastify/fastify-caching) |
50+
| CACHE_EXPIRESIN | No | 3600 | [Max age in seconds](https://github.com/fastify/fastify-caching) |
51+
| CACHE_SERVERCACHE | No | undefined | Max age in seconds for [shared cache](https://github.com/fastify/fastify-caching) (i.e. CDN) |
52+
3053

3154
### Step 3: fire it up!
3255

@@ -56,11 +79,13 @@ Fastify is written by some of the core Node developers, and it's awesome. A numb
5679

5780
All routes are stored in the `routes` folder and are automatically loaded on start. Check out the [routes readme](routes/README.md) for more information.
5881

59-
## Tips and tricks
82+
## Tips and Tricks
6083

6184
### Database
6285

63-
Your Postgres login will need select rights to any tables or views it should be able to access. For security, it should _only_ have select rights unless you plan to specifically add a route that writes to a table.
86+
Your Postgres login will need select rights to any tables or views it should be able to access. That includes the `geometry_columns` view for the `list_layers` end point to work.
87+
88+
For security, it should _only_ have select rights unless you plan to specifically add a route that writes to a table.
6489

6590
Dirt uses connection pooling, minimizing database connections.
6691

@@ -70,7 +95,7 @@ If a query parameter looks like it should be able to handle SQL functions, it pr
7095

7196
### Mapbox vector tiles
7297

73-
The `mvt` route serves Mapbox Vector Tiles. The layer name in the returned protobuf will be the same as the table name passed as input. Here's an example of using both `geojson` and `mvt` routes with Mapbox GL JS.
98+
The `mvt` route serves Mapbox Vector Tiles. The layer name in the returned protobuf will be the same as the table name passed as input. Here's an example of using both `geojson` and `mvt` routes with MapLibre GL JS.
7499

75100
```javascript
76101
map.on('load', function() {
@@ -108,23 +133,18 @@ map.on('load', function() {
108133

109134
### Rate Limiting
110135

111-
You can add rate limiting users by using the [fastify-rate-limit](https://github.com/fastify/fastify-rate-limit) plugin. This can be handy not only for regular connections but also to keep a wayward bot from eating your lunch.
136+
You can add rate limiting users by using the [@fastify/rate-limit](https://github.com/fastify/fastify-rate-limit) plugin. This can be handy not only for regular connections but also to keep a wayward bot from eating your lunch.
112137

113138
```bash
114-
npm install --save fastify-rate-limit
139+
npm install --save @fastify/rate-limit
115140
```
116141

117142
```javascript index.js
118-
fastify.register(require('fastify-rate-limit'), {
119-
max: 100,
143+
fastify.register(require('@fastify/rate-limit'), {
144+
max: 250,
120145
timeWindow: '1 minute'
121146
})
122147
```
148+
### Changes require a Restart
123149

124-
### More Tips
125-
126-
- The master branch of Dirt is now optimized for PostGIS 3. Some functions will work on earlier versions, but some (geobuf, geojson, mvt in particular) will not. Use the `postgis2x` branch if you need to support PostGIS 2.
127-
- If you modify code or add a route, dirt will not see it until dirt is restarted.
128-
- The Dirt login needs read rights to the `geometry_columns` view for the `list_layers` service to work.
129-
- You can override the db connection string with the environmental variable `POSTGRES_CONNECTION`.
130-
- If you pass path parameters that have encoded slashes through an Apache proxy (i.e. `%2F`), Apache by default will reject those requests with a 404 (Docs: [AllowEncodedSlashes](https://httpd.apache.org/docs/2.4/mod/core.html#allowencodedslashes)). To fix that, add `AllowEncodedSlashes NoDecode` to the end of your httpd.conf.
150+
If you modify code or add a route, dirt will not see it until dirt is restarted.

0 commit comments

Comments
 (0)