From 08b9d153da61a02d4a1b45ed117d0a8abeb2b517 Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 27 May 2019 17:10:02 +0530 Subject: [PATCH 1/3] fix: update echo framewor to fix commit hash mismatch --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f670719..2a2fc27 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/jordan-wright/email v0.0.0-20181027021455-480bedc4908b github.com/knadh/goyesql v1.1.1 github.com/knadh/stuffbin v0.0.0-20190103171338-6379e949be48 - github.com/labstack/echo v3.3.5+incompatible + github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.2.7 // indirect github.com/lib/pq v1.0.0 github.com/mattn/go-colorable v0.0.9 // indirect diff --git a/go.sum b/go.sum index 5cf8504..1860a28 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ github.com/knadh/stuffbin v0.0.0-20190103171338-6379e949be48 h1:lRb28d0+iiVwqF7L github.com/knadh/stuffbin v0.0.0-20190103171338-6379e949be48/go.mod h1:afUOPBWr6bZ09aS3wbSOqXVGaO6rKcyvXYTcuG9LYpI= github.com/labstack/echo v3.3.5+incompatible h1:9PfxPUmasKzeJor9uQTaXLT6WUG/r+vSTmvXxvv3JO4= github.com/labstack/echo v3.3.5+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= +github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.2.7 h1:2qOPq/twXDrQ6ooBGrn3mrmVOC+biLlatwgIu8lbzRM= github.com/labstack/gommon v0.2.7/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= From 09117426ee7762ef12dc73f194c00edb7ea84eac Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 27 May 2019 17:16:46 +0530 Subject: [PATCH 2/3] feat: add config to enable/disable postgres ssl mode --- config.toml.sample | 3 ++- main.go | 3 ++- queries.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.toml.sample b/config.toml.sample index 12472f7..1b9f12b 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -35,7 +35,7 @@ upload_uri = "/uploads" # Maximum concurrent workers that will attempt to send messages # simultaneously. This should depend on the number of CPUs the # machine has and also the number of simultaenous e-mails the -# mail server will +# mail server will concurrency = 100 # The number of errors (eg: SMTP timeouts while e-mailing) a running @@ -51,6 +51,7 @@ port = 5432 user = "listmonk" password = "" database = "listmonk" +ssl_mode = "disable" # TQekh4quVgGc3HQ diff --git a/main.go b/main.go index 9b2c525..9ea0778 100644 --- a/main.go +++ b/main.go @@ -148,7 +148,8 @@ func main() { viper.GetInt("db.port"), viper.GetString("db.user"), viper.GetString("db.password"), - viper.GetString("db.database")) + viper.GetString("db.database"), + viper.GetString("db.ssl_mode")) if err != nil { logger.Fatalf("error connecting to DB: %v", err) } diff --git a/queries.go b/queries.go index fa1de54..b14a508 100644 --- a/queries.go +++ b/queries.go @@ -79,9 +79,9 @@ type Queries struct { } // connectDB initializes a database connection. -func connectDB(host string, port int, user, pwd, dbName string) (*sqlx.DB, error) { +func connectDB(host string, port int, user, pwd, dbName string, sslMode string) (*sqlx.DB, error) { db, err := sqlx.Connect("postgres", - fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s", host, port, user, pwd, dbName)) + fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", host, port, user, pwd, dbName, sslMode)) if err != nil { return nil, err } From 11ca4beddb528f51257af0f920182b812e90750e Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 27 May 2019 17:17:26 +0530 Subject: [PATCH 3/3] chore: fix frontend directory structure --- .gitignore | 4 +-- Makefile | 14 ++++---- README.dev.md | 2 +- frontend/.babelrc | 1 + frontend/{my => }/.gitignore | 0 frontend/{my => }/README.md | 0 frontend/{my => }/config-overrides.js | 0 frontend/my/package.json | 34 ------------------ frontend/package.json | 32 +++++++++++++++-- frontend/{my => }/public/favicon.png | Bin frontend/{my => }/public/gallery.svg | 0 frontend/{my => }/public/index.html | 0 frontend/{my => }/public/manifest.json | 0 frontend/{my => }/src/App.js | 0 frontend/{my => }/src/Campaign.js | 0 frontend/{my => }/src/Campaigns.js | 0 frontend/{my => }/src/Dashboard.css | 0 frontend/{my => }/src/Dashboard.js | 0 frontend/{my => }/src/Import.js | 0 frontend/{my => }/src/Layout.js | 0 frontend/{my => }/src/Lists.js | 0 frontend/{my => }/src/Media.js | 0 frontend/{my => }/src/ModalPreview.js | 0 frontend/{my => }/src/Subscriber.js | 0 frontend/{my => }/src/Subscribers.js | 0 frontend/{my => }/src/Templates.js | 0 frontend/{my => }/src/constants.js | 0 frontend/{my => }/src/index.css | 0 frontend/{my => }/src/index.js | 0 frontend/{my => }/src/logo.svg | 0 .../{my => }/src/registerServiceWorker.js | 0 frontend/{my => }/src/static/gallery.svg | 0 frontend/{my => }/src/static/listmonk.svg | 0 frontend/{my => }/src/utils.js | 0 main.go | 2 +- 35 files changed, 41 insertions(+), 48 deletions(-) rename frontend/{my => }/.gitignore (100%) rename frontend/{my => }/README.md (100%) rename frontend/{my => }/config-overrides.js (100%) delete mode 100644 frontend/my/package.json rename frontend/{my => }/public/favicon.png (100%) rename frontend/{my => }/public/gallery.svg (100%) rename frontend/{my => }/public/index.html (100%) rename frontend/{my => }/public/manifest.json (100%) rename frontend/{my => }/src/App.js (100%) rename frontend/{my => }/src/Campaign.js (100%) rename frontend/{my => }/src/Campaigns.js (100%) rename frontend/{my => }/src/Dashboard.css (100%) rename frontend/{my => }/src/Dashboard.js (100%) rename frontend/{my => }/src/Import.js (100%) rename frontend/{my => }/src/Layout.js (100%) rename frontend/{my => }/src/Lists.js (100%) rename frontend/{my => }/src/Media.js (100%) rename frontend/{my => }/src/ModalPreview.js (100%) rename frontend/{my => }/src/Subscriber.js (100%) rename frontend/{my => }/src/Subscribers.js (100%) rename frontend/{my => }/src/Templates.js (100%) rename frontend/{my => }/src/constants.js (100%) rename frontend/{my => }/src/index.css (100%) rename frontend/{my => }/src/index.js (100%) rename frontend/{my => }/src/logo.svg (100%) rename frontend/{my => }/src/registerServiceWorker.js (100%) rename frontend/{my => }/src/static/gallery.svg (100%) rename frontend/{my => }/src/static/listmonk.svg (100%) rename frontend/{my => }/src/utils.js (100%) diff --git a/.gitignore b/.gitignore index d43e047..4edb754 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ frontend/node_modules/ -frontend/my/node_modules/ frontend/.cache/ frontend/yarn.lock -frontend/my/yarn.lock .vscode/ -config.toml \ No newline at end of file +config.toml diff --git a/Makefile b/Makefile index 67ed766..61fbffe 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BIN := listmonk -STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/my/build:/frontend +STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/build:/frontend HASH := $(shell git rev-parse --short HEAD) COMMIT_DATE := $(shell git show -s --format=%ci ${HASH}) @@ -8,20 +8,20 @@ VERSION := ${HASH} (${COMMIT_DATE}) .PHONY: build-frontend build-frontend: - cd frontend/my && yarn install && yarn build + cd frontend && yarn install && yarn build .PHONY: quickdev quickdev: - @ if [ ! -d "frontend/my/node_modules" ]; then \ + @ if [ ! -d "frontend/node_modules" ]; then \ echo "Installing frontend deps"; \ - cd frontend/my && yarn install; \ + cd frontend && yarn install; \ fi - @ if [ ! -d "frontend/my/build" ]; then \ + @ if [ ! -d "frontend/build" ]; then \ echo "Creating build directory"; \ - mkdir -p frontend/my/build; \ + mkdir -p frontend/build; \ echo "Building frontend assets"; \ - cd frontend/my && yarn build; \ + cd frontend && yarn build; \ fi @ echo -e "\nBuilding go binary\n" diff --git a/README.dev.md b/README.dev.md index c95da9b..31d7072 100644 --- a/README.dev.md +++ b/README.dev.md @@ -15,7 +15,7 @@ There are two independent components, the Go backend and the React frontend. In ### 2. Run the frontend -`cd frontend/my` and `yarn start` +`cd frontend` and `yarn start` ### 3. Setup an Nginx proxy endpoint diff --git a/frontend/.babelrc b/frontend/.babelrc index 235b076..c7c5e2f 100644 --- a/frontend/.babelrc +++ b/frontend/.babelrc @@ -2,3 +2,4 @@ "presets": ["env", "react"], "plugins": [["transform-react-jsx", { "pragma": "h" }]] } + diff --git a/frontend/my/.gitignore b/frontend/.gitignore similarity index 100% rename from frontend/my/.gitignore rename to frontend/.gitignore diff --git a/frontend/my/README.md b/frontend/README.md similarity index 100% rename from frontend/my/README.md rename to frontend/README.md diff --git a/frontend/my/config-overrides.js b/frontend/config-overrides.js similarity index 100% rename from frontend/my/config-overrides.js rename to frontend/config-overrides.js diff --git a/frontend/my/package.json b/frontend/my/package.json deleted file mode 100644 index ff1f721..0000000 --- a/frontend/my/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "my", - "version": "0.1.0", - "private": true, - "dependencies": { - "antd": "^3.6.5", - "axios": "^0.18.0", - "bizcharts": "^3.2.5-beta.4", - "dayjs": "^1.7.5", - "react": "^16.4.1", - "react-app-rewire-less": "^2.1.3", - "react-app-rewired": "^1.6.2", - "react-dom": "^16.4.1", - "react-quill": "^1.3.1", - "react-router": "^4.3.1", - "react-router-dom": "^4.3.1", - "react-scripts": "1.1.4" - }, - "scripts": { - "start": "react-app-rewired start", - "build": "GENERATE_SOURCEMAP=false PUBLIC_URL=/frontend/ react-app-rewired build", - "test": "react-app-rewired test --env=jsdom", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": "react-app" - }, - "devDependencies": { - "babel-plugin-import": "^1.11.0", - "eslint-plugin-prettier": "^3.0.1", - "less-plugin-npm-import": "^2.1.0", - "prettier": "1.15.3" - } -} diff --git a/frontend/package.json b/frontend/package.json index f907840..ff1f721 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,34 @@ { + "name": "my", + "version": "0.1.0", + "private": true, "dependencies": { - "create-react-app": "^1.5.2", - "react": "^16.4.1" + "antd": "^3.6.5", + "axios": "^0.18.0", + "bizcharts": "^3.2.5-beta.4", + "dayjs": "^1.7.5", + "react": "^16.4.1", + "react-app-rewire-less": "^2.1.3", + "react-app-rewired": "^1.6.2", + "react-dom": "^16.4.1", + "react-quill": "^1.3.1", + "react-router": "^4.3.1", + "react-router-dom": "^4.3.1", + "react-scripts": "1.1.4" + }, + "scripts": { + "start": "react-app-rewired start", + "build": "GENERATE_SOURCEMAP=false PUBLIC_URL=/frontend/ react-app-rewired build", + "test": "react-app-rewired test --env=jsdom", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": "react-app" + }, + "devDependencies": { + "babel-plugin-import": "^1.11.0", + "eslint-plugin-prettier": "^3.0.1", + "less-plugin-npm-import": "^2.1.0", + "prettier": "1.15.3" } } diff --git a/frontend/my/public/favicon.png b/frontend/public/favicon.png similarity index 100% rename from frontend/my/public/favicon.png rename to frontend/public/favicon.png diff --git a/frontend/my/public/gallery.svg b/frontend/public/gallery.svg similarity index 100% rename from frontend/my/public/gallery.svg rename to frontend/public/gallery.svg diff --git a/frontend/my/public/index.html b/frontend/public/index.html similarity index 100% rename from frontend/my/public/index.html rename to frontend/public/index.html diff --git a/frontend/my/public/manifest.json b/frontend/public/manifest.json similarity index 100% rename from frontend/my/public/manifest.json rename to frontend/public/manifest.json diff --git a/frontend/my/src/App.js b/frontend/src/App.js similarity index 100% rename from frontend/my/src/App.js rename to frontend/src/App.js diff --git a/frontend/my/src/Campaign.js b/frontend/src/Campaign.js similarity index 100% rename from frontend/my/src/Campaign.js rename to frontend/src/Campaign.js diff --git a/frontend/my/src/Campaigns.js b/frontend/src/Campaigns.js similarity index 100% rename from frontend/my/src/Campaigns.js rename to frontend/src/Campaigns.js diff --git a/frontend/my/src/Dashboard.css b/frontend/src/Dashboard.css similarity index 100% rename from frontend/my/src/Dashboard.css rename to frontend/src/Dashboard.css diff --git a/frontend/my/src/Dashboard.js b/frontend/src/Dashboard.js similarity index 100% rename from frontend/my/src/Dashboard.js rename to frontend/src/Dashboard.js diff --git a/frontend/my/src/Import.js b/frontend/src/Import.js similarity index 100% rename from frontend/my/src/Import.js rename to frontend/src/Import.js diff --git a/frontend/my/src/Layout.js b/frontend/src/Layout.js similarity index 100% rename from frontend/my/src/Layout.js rename to frontend/src/Layout.js diff --git a/frontend/my/src/Lists.js b/frontend/src/Lists.js similarity index 100% rename from frontend/my/src/Lists.js rename to frontend/src/Lists.js diff --git a/frontend/my/src/Media.js b/frontend/src/Media.js similarity index 100% rename from frontend/my/src/Media.js rename to frontend/src/Media.js diff --git a/frontend/my/src/ModalPreview.js b/frontend/src/ModalPreview.js similarity index 100% rename from frontend/my/src/ModalPreview.js rename to frontend/src/ModalPreview.js diff --git a/frontend/my/src/Subscriber.js b/frontend/src/Subscriber.js similarity index 100% rename from frontend/my/src/Subscriber.js rename to frontend/src/Subscriber.js diff --git a/frontend/my/src/Subscribers.js b/frontend/src/Subscribers.js similarity index 100% rename from frontend/my/src/Subscribers.js rename to frontend/src/Subscribers.js diff --git a/frontend/my/src/Templates.js b/frontend/src/Templates.js similarity index 100% rename from frontend/my/src/Templates.js rename to frontend/src/Templates.js diff --git a/frontend/my/src/constants.js b/frontend/src/constants.js similarity index 100% rename from frontend/my/src/constants.js rename to frontend/src/constants.js diff --git a/frontend/my/src/index.css b/frontend/src/index.css similarity index 100% rename from frontend/my/src/index.css rename to frontend/src/index.css diff --git a/frontend/my/src/index.js b/frontend/src/index.js similarity index 100% rename from frontend/my/src/index.js rename to frontend/src/index.js diff --git a/frontend/my/src/logo.svg b/frontend/src/logo.svg similarity index 100% rename from frontend/my/src/logo.svg rename to frontend/src/logo.svg diff --git a/frontend/my/src/registerServiceWorker.js b/frontend/src/registerServiceWorker.js similarity index 100% rename from frontend/my/src/registerServiceWorker.js rename to frontend/src/registerServiceWorker.js diff --git a/frontend/my/src/static/gallery.svg b/frontend/src/static/gallery.svg similarity index 100% rename from frontend/my/src/static/gallery.svg rename to frontend/src/static/gallery.svg diff --git a/frontend/my/src/static/listmonk.svg b/frontend/src/static/listmonk.svg similarity index 100% rename from frontend/my/src/static/listmonk.svg rename to frontend/src/static/listmonk.svg diff --git a/frontend/my/src/utils.js b/frontend/src/utils.js similarity index 100% rename from frontend/my/src/utils.js rename to frontend/src/utils.js diff --git a/main.go b/main.go index 9ea0778..c3be7e3 100644 --- a/main.go +++ b/main.go @@ -101,7 +101,7 @@ func initFileSystem(binPath string) (stuffbin.FileSystem, error) { // The frontend app's static assets are aliased to /frontend // so that they are accessible at localhost:port/frontend/static/ ... - "frontend/my/build:/frontend", + "frontend/build:/frontend", } fs, err = stuffbin.NewLocalFS("/", files...)