Compare commits

...

2 Commits

Author SHA1 Message Date
Felipe M 0aff2259d9
docs: updated readme file 2022-08-15 20:45:36 +02:00
Felipe M 508d0204a0
chore: configuration attributes sorting 2022-08-15 20:45:01 +02:00
2 changed files with 59 additions and 2 deletions

View File

@ -1 +1,58 @@
# notion2ical
Simple web service to expose Notion database as iCalendar compatible URLs.
## Contributing
**Requirements:**
- [go](https://go.dev)
- [make](https://www.gnu.org/software/make/) (quality of life)
- [docker](https://docker.com)/[podman](https://podman.io) (for containers)
- [goreleaser](https://goreleaser.com) (to build the code)
We provide a useful `Makefile` to execute common tasks:
- Run the server locally: `make quick-run`
- Run the test & coverage suite: `make test`
- Lint the code: `make lint`
- Format the code `make format`
- Build the code: `make build`
- Clean all created files: `make clean`
## Notion integrations
Currently only the private integration is supported, so only the workspaces which the user api key is an admin for will be supported.
The **public** integration type is [currently in the works](https://github.com/fmartingr/notion2ical/pull/1).
## Configuration
Service configuration is done using environment variables. All variables should be prefixed by `NOTION2ICAL_` when using kubernetes deployments.
From [internal/config/config.go](./internal/config/config.go)
| Name | Type | Description |
| -------------------------------------- | ------------ | ---------------------------------------------------------------------------- |
| `HOSTNAME` | string | Should be automatically filled |
| `LOG_LEVEL` | string | [Log level](https://github.com/uber-go/zap/blob/master/zapcore/level.go#L34) |
| `HTTP_ENABLED` | bool | Enable/Disable the HTTP Server |
| `HTTP_PORT` | int | Port for the HTTP server to listen |
| `HTTP_PUBLIC_HOSTNAME` | string | Hostname used publicly when the service is released |
| `HTTP_BODY_LIMIT` | int | Body limit in length |
| `HTTP_READ_TIMEOUT` | duration[^1] | Request read timeout |
| `HTTP_WRITE_TIMEOUT` | duration[^1] | Request write timeout |
| `HTTP_IDLE_TIMEOUT` | duration[^1] | Request IDLE timeout |
| `HTTP_DISABLE_KEEP_ALIVE` | bool | Enable/Disable keep alive support |
| `HTTP_DISABLE_PARSE_MULTIPART_FORM` | bool | Enable/Disable parsing multipart form early |
| `BRANDING_THANKS_MESSAGE` | string | Message shown on the final configuration step |
| `BRANDING_FOOTER_EXTRA` | string | Extra footer content |
| `NOTION_INTEGRATION_TOKEN` | string | The Notion integration token |
| `NOTION_MAX_PAGINATION` | int | The maximum number of pages to retrieve from a database |
| `ROUTES_CACHE_EXPIRATION` | duration[^1] | Cache TTL for the generated calendars |
| `ROUTES_CACHE_CONTROL` | bool | Enable cache-control header |
| `ROUTES_CALENDAR_LIMITER_MAX_REQUESTS` | int | Maximum requests number for the calendar endpoints |
| `ROUTES_CALENDAR_LIMITER_DURATION` | duration[^1] | Maximum requests interval for the calendar endpoints |
| `ROUTES_STATIC_PATH` | string | Path prefix for the static files |
| `ROUTES_STATIC_MAX_AGE` | duration[^1] | Max age for the served static files |
| `ROUTES_SYSTEM_PATH` | string | Path prefix for the system endpoints |
[^1]: **`*duration`** = A string containing a number and the time unit: `10s` = 10 seconds, `1h` = 1 hour, ...

View File

@ -43,6 +43,7 @@ func readDotEnv(logger *zap.Logger) map[string]string {
type Config struct {
Hostname string `env:"HOSTNAME,required"`
LogLevel string `env:"LOG_LEVEL,default=info"`
Http struct {
Enabled bool `env:"HTTP_ENABLED,default=True"`
Port int `env:"HTTP_PORT,default=8080"`
@ -59,8 +60,7 @@ type Config struct {
ThanksMessage string `env:"BRANDING_THANKS_MESSAGE"`
FooterExtraMessage string `env:"BRANDING_FOOTER_EXTRA"`
}
LogLevel string `env:"LOG_LEVEL,default=info"`
Notion struct {
Notion struct {
IntegrationToken string `env:"NOTION_INTEGRATION_TOKEN,required"`
MaxPagination int `env:"NOTION_MAX_PAGINATION,default=2"`
Client *notion.NotionClient // Must be manually set up