Archived
1
0
Fork 0

Add PostgreSQL support (#23)

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-04-06 10:33:24 +02:00
commit 47c8a8ace9
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
10 changed files with 216 additions and 9 deletions

View file

@ -8,6 +8,7 @@ import (
// Config to store JSON configuration
type Config struct {
DatabaseConfig `json:"database"`
TwitterConfig `json:"twitter"`
TelegramConfig `json:"telegram"`
APIConfig `json:"api"`
@ -18,6 +19,12 @@ type Config struct {
BrowserAddress string `json:"browser_address"`
}
// DatabaseConfig to store database configuration
type DatabaseConfig struct {
Type string `json:"type"`
DSN string `json:"dsn"`
}
// TwitterConfig to store Twitter API secrets
type TwitterConfig struct {
ConsumerKey string `json:"consumer_key"`
@ -96,6 +103,11 @@ func (c *Config) HasURLs() bool {
return len(c.URLs) > 0
}
// HasDatabase returns true when database has been configured
func (c *Config) HasDatabase() bool {
return c.DatabaseConfig.Type != "" && c.DatabaseConfig.DSN != ""
}
// HasAmazon returns true when Amazon has been configured
func (c *Config) HasAmazon() bool {
var hasKeys, hasSearches, hasMarketplaces bool