diff --git a/Makefile b/Makefile index 60ca4fc..294a31c 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ reset: .PHONY: run run: clear - go run main.go + go run cmd/web/main.go # Run all tests .PHONY: test @@ -60,7 +60,7 @@ test: .PHONY: worker worker: clear - go run worker/worker.go + go run cmd/worker/worker.go # Check for direct dependency updates .PHONY: check-updates diff --git a/README.md b/README.md index 0e4d163..5d5e24d 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ The following _make_ commands are available to make it easy to connect to the da ## Service container -The container is located at `services/container.go` and is meant to house all of your application's services and/or dependencies. It is easily extensible and can be created and initialized in a single call. The services currently included in the container are: +The container is located at `pkg/services/container.go` and is meant to house all of your application's services and/or dependencies. It is easily extensible and can be created and initialized in a single call. The services currently included in the container are: - Configuration - Cache @@ -306,7 +306,7 @@ This executes a database query to return the _password token_ entity with a give ## Sessions -Sessions are provided and handled via [Gorilla sessions](https://github.com/gorilla/sessions) and configured as middleware in the router located at `routes/router.go`. Session data is currently stored in cookies but there are many [options](https://github.com/gorilla/sessions#store-implementations) available if you wish to use something else. +Sessions are provided and handled via [Gorilla sessions](https://github.com/gorilla/sessions) and configured as middleware in the router located at `pkg/routes/router.go`. Session data is currently stored in cookies but there are many [options](https://github.com/gorilla/sessions#store-implementations) available if you wish to use something else. Here's a simple example of loading data from a session and saving new values: @@ -384,7 +384,7 @@ To generate a new verification token, the `AuthClient` has a method `GenerateEma ## Routes -The router functionality is provided by [Echo](https://echo.labstack.com/guide/routing/) and constructed within via the `BuildRouter()` function inside `routes/router.go`. Since the _Echo_ instance is a _Service_ on the `Container` which is passed in to `BuildRouter()`, middleware and routes can be added directly to it. +The router functionality is provided by [Echo](https://echo.labstack.com/guide/routing/) and constructed within via the `BuildRouter()` function inside `pkg/routes/router.go`. Since the _Echo_ instance is a _Service_ on the `Container` which is passed in to `BuildRouter()`, middleware and routes can be added directly to it. ### Custom middleware @@ -435,13 +435,13 @@ Your route will now have all methods available on the `Controller` as well as ac Routes can return errors to indicate that something wrong happened. Ideally, the error is of type `*echo.HTTPError` to indicate the intended HTTP response code. You can use `return echo.NewHTTPError(http.StatusInternalServerError)`, for example. If an error of a different type is returned, an _Internal Server Error_ is assumed. -The [error handler](https://echo.labstack.com/guide/error-handling/) is set to a provided route `routes/error.go` in the `BuildRouter()` function. That means that if any middleware or route return an error, the request gets routed there. This route conveniently constructs and renders a `Page` which uses the template `templates/pages/error.go`. The status code is passed to the template so you can easily alter the markup depending on the error type. +The [error handler](https://echo.labstack.com/guide/error-handling/) is set to a provided route `pkg/routes/error.go` in the `BuildRouter()` function. That means that if any middleware or route return an error, the request gets routed there. This route conveniently constructs and renders a `Page` which uses the template `templates/pages/error.go`. The status code is passed to the template so you can easily alter the markup depending on the error type. ### Testing Since most of your web application logic will live in your routes, being able to easily test them is important. The following aims to help facilitate that. -The test setup and helpers reside in `routes/router_test.go`. +The test setup and helpers reside in `pkg/routes/router_test.go`. Only a brief example of route tests were provided in order to highlight what is available. Adding full tests did not seem logical since these routes will most likely be changed or removed in your project. @@ -451,7 +451,7 @@ When the route tests initialize, a new `Container` is created which provides ful #### Request / Response helpers -With the test HTTP server setup, test helpers for making HTTP requests and evaluating responses are made available to reduce the amount of code you need to write. See `httpRequest` and `httpResponse` within `routes/router_test.go`. +With the test HTTP server setup, test helpers for making HTTP requests and evaluating responses are made available to reduce the amount of code you need to write. See `httpRequest` and `httpResponse` within `pkg/routes/router_test.go`. Here is an example how to easily make a request and evaluate the response: @@ -485,7 +485,7 @@ As previously mentioned, the `Controller` acts as a base for your routes, though ### Page -The `Page` is the major building block of your `Controller` responses. It is a _struct_ type located at `controller/page.go`. The concept of the `Page` is that it provides a consistent structure for building responses and transmitting data and functionality to the templates. +The `Page` is the major building block of your `Controller` responses. It is a _struct_ type located at `pkg/controller/page.go`. The concept of the `Page` is that it provides a consistent structure for building responses and transmitting data and functionality to the templates. All example routes provided construct and _render_ a `Page`. It's recommended that you review both the `Page` and the example routes as they try to illustrate all included functionality. @@ -540,7 +540,7 @@ To make things easier, a template _component_ is already provided, located at `t ### Pager -A very basic mechanism is provided to handle and facilitate paging located in `controller/pager.go`. When a `Page` is initialized, so is a `Pager` at `Page.Pager`. If the requested URL contains a `page` query parameter with a numeric value, that will be set as the page number in the pager. +A very basic mechanism is provided to handle and facilitate paging located in `pkg/controller/pager.go`. When a `Page` is initialized, so is a `Pager` at `Page.Pager`. If the requested URL contains a `page` query parameter with a numeric value, that will be set as the page number in the pager. During initialization, the _items per page_ amount will be set to the default, controlled via constant, which has a value of 20. It can be overridden by changing `Pager.ItemsPerPage` but should be done before other values are set in order to not provide incorrect calculations. @@ -634,7 +634,7 @@ How the _form_ gets populated with values so that your template can render them #### Submission processing -Form submission processing is made extremely simple by leveraging functionality provided by [Echo binding](https://echo.labstack.com/guide/binding/), [validator](https://github.com/go-playground/validator) and the `FormSubmission` struct located in `controller/form.go`. +Form submission processing is made extremely simple by leveraging functionality provided by [Echo binding](https://echo.labstack.com/guide/binding/), [validator](https://github.com/go-playground/validator) and the `FormSubmission` struct located in `pkg/controller/form.go`. Using the example form above, these are the steps you would take within the _POST_ callback for your route: @@ -833,7 +833,7 @@ func (c *home) Get(ctx echo.Context) error { ## Template renderer -The _template renderer_ is a _Service_ on the `Container` that aims to make template parsing and rendering easy and flexible. It is the mechanism that allows the `Page` to do [automatic template parsing](#automatic-template-parsing). The standard `html/template` is still the engine used behind the scenes. The code can be found in `services/template_renderer.go`. +The _template renderer_ is a _Service_ on the `Container` that aims to make template parsing and rendering easy and flexible. It is the mechanism that allows the `Page` to do [automatic template parsing](#automatic-template-parsing). The standard `html/template` is still the engine used behind the scenes. The code can be found in `pkg/services/template_renderer.go`. Here is an example of a complex rendering that uses multiple template files as well as an entire directory of template files: @@ -1083,7 +1083,7 @@ err := c.Tasks. #### Scheduler -A service needs to run in order to add periodic tasks to the queue at the specified intervals. When the application is started, this _scheduler_ service will also be started. In `main.go`, this is done with the following code: +A service needs to run in order to add periodic tasks to the queue at the specified intervals. When the application is started, this _scheduler_ service will also be started. In `cmd/web/main.go`, this is done with the following code: ```go go func() { @@ -1107,7 +1107,7 @@ A make target was added to allow you to start the worker service easily. From th #### Understanding the service -The worker service is located in [worker/worker.go](/worker/worker.go) and starts with the creation of a new `*asynq.Server` provided by `asynq.NewServer()`. There are various configuration options available, so be sure to review them all. +The worker service is located in [cmd/worker/main.go](/cmd/worker/main.go) and starts with the creation of a new `*asynq.Server` provided by `asynq.NewServer()`. There are various configuration options available, so be sure to review them all. Prior to starting the service, we need to route tasks according to their _type_ to their handlers which will process the tasks. This is done by using `async.ServeMux` much like you would use an HTTP router: @@ -1116,7 +1116,7 @@ mux := asynq.NewServeMux() mux.Handle(tasks.TypeExample, new(tasks.ExampleProcessor)) ``` -In this example, all tasks of _type_ `tasks.TypeExample` will be routed to `ExampleProcessor` which is a struct that implements `ProcessTask()`. See the included [basic example](/worker/tasks/example.go). +In this example, all tasks of _type_ `tasks.TypeExample` will be routed to `ExampleProcessor` which is a struct that implements `ProcessTask()`. See the included [basic example](/pkg/tasks/example.go). Finally, the service is started with `async.Server.Run(mux)`. @@ -1126,7 +1126,7 @@ Finally, the service is started with `async.Server.Run(mux)`. ## Static files -Static files are currently configured in the router (`routes/router.go`) to be served from the `static` directory. If you wish to change the directory, alter the constant `config.StaticDir`. The URL prefix for static files is `/files` which is controlled via the `config.StaticPrefix` constant. +Static files are currently configured in the router (`pkg/routes/router.go`) to be served from the `static` directory. If you wish to change the directory, alter the constant `config.StaticDir`. The URL prefix for static files is `/files` which is controlled via the `config.StaticPrefix` constant. ### Cache control headers diff --git a/main.go b/cmd/web/main.go similarity index 94% rename from main.go rename to cmd/web/main.go index fe8f575..d47aab9 100644 --- a/main.go +++ b/cmd/web/main.go @@ -9,8 +9,8 @@ import ( "os/signal" "time" - "github.com/mikestefanello/pagoda/routes" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/routes" + "github.com/mikestefanello/pagoda/pkg/services" ) func main() { diff --git a/worker/worker.go b/cmd/worker/main.go similarity index 94% rename from worker/worker.go rename to cmd/worker/main.go index df890ac..072e5b5 100644 --- a/worker/worker.go +++ b/cmd/worker/main.go @@ -6,7 +6,7 @@ import ( "github.com/hibiken/asynq" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/worker/tasks" + "github.com/mikestefanello/pagoda/pkg/tasks" ) func main() { diff --git a/config/config.go b/config/config.go index 956e65a..6427e5e 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( const ( // TemplateDir stores the name of the directory that contains templates - TemplateDir = "templates" + TemplateDir = "../templates" // TemplateExt stores the extension used for the template files TemplateExt = ".gohtml" diff --git a/context/context.go b/pkg/context/context.go similarity index 100% rename from context/context.go rename to pkg/context/context.go diff --git a/context/context_test.go b/pkg/context/context_test.go similarity index 100% rename from context/context_test.go rename to pkg/context/context_test.go diff --git a/controller/controller.go b/pkg/controller/controller.go similarity index 96% rename from controller/controller.go rename to pkg/controller/controller.go index 1035bce..8bcca7c 100644 --- a/controller/controller.go +++ b/pkg/controller/controller.go @@ -5,10 +5,10 @@ import ( "fmt" "net/http" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/htmx" - "github.com/mikestefanello/pagoda/middleware" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/htmx" + "github.com/mikestefanello/pagoda/pkg/middleware" + "github.com/mikestefanello/pagoda/pkg/services" "github.com/labstack/echo/v4" ) diff --git a/controller/controller_test.go b/pkg/controller/controller_test.go similarity index 96% rename from controller/controller_test.go rename to pkg/controller/controller_test.go index 0ec1727..6422d81 100644 --- a/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -9,10 +9,10 @@ import ( "testing" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/htmx" - "github.com/mikestefanello/pagoda/middleware" - "github.com/mikestefanello/pagoda/services" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/htmx" + "github.com/mikestefanello/pagoda/pkg/middleware" + "github.com/mikestefanello/pagoda/pkg/services" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/controller/form.go b/pkg/controller/form.go similarity index 100% rename from controller/form.go rename to pkg/controller/form.go diff --git a/controller/form_test.go b/pkg/controller/form_test.go similarity index 95% rename from controller/form_test.go rename to pkg/controller/form_test.go index c289043..e2fd880 100644 --- a/controller/form_test.go +++ b/pkg/controller/form_test.go @@ -3,7 +3,7 @@ package controller import ( "testing" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/controller/page.go b/pkg/controller/page.go similarity index 97% rename from controller/page.go rename to pkg/controller/page.go index cca16fe..367c3a9 100644 --- a/controller/page.go +++ b/pkg/controller/page.go @@ -5,10 +5,10 @@ import ( "net/http" "time" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/htmx" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/htmx" + "github.com/mikestefanello/pagoda/pkg/msg" echomw "github.com/labstack/echo/v4/middleware" diff --git a/controller/page_test.go b/pkg/controller/page_test.go similarity index 92% rename from controller/page_test.go rename to pkg/controller/page_test.go index df1c7e6..996985c 100644 --- a/controller/page_test.go +++ b/pkg/controller/page_test.go @@ -4,9 +4,9 @@ import ( "net/http" "testing" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/msg" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/msg" + "github.com/mikestefanello/pagoda/pkg/tests" echomw "github.com/labstack/echo/v4/middleware" "github.com/stretchr/testify/assert" diff --git a/controller/pager.go b/pkg/controller/pager.go similarity index 100% rename from controller/pager.go rename to pkg/controller/pager.go diff --git a/controller/pager_test.go b/pkg/controller/pager_test.go similarity index 97% rename from controller/pager_test.go rename to pkg/controller/pager_test.go index cdc06b7..694fbc3 100644 --- a/controller/pager_test.go +++ b/pkg/controller/pager_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" ) diff --git a/funcmap/funcmap.go b/pkg/funcmap/funcmap.go similarity index 100% rename from funcmap/funcmap.go rename to pkg/funcmap/funcmap.go diff --git a/funcmap/funcmap_test.go b/pkg/funcmap/funcmap_test.go similarity index 100% rename from funcmap/funcmap_test.go rename to pkg/funcmap/funcmap_test.go diff --git a/htmx/htmx.go b/pkg/htmx/htmx.go similarity index 100% rename from htmx/htmx.go rename to pkg/htmx/htmx.go diff --git a/htmx/htmx_test.go b/pkg/htmx/htmx_test.go similarity index 97% rename from htmx/htmx_test.go rename to pkg/htmx/htmx_test.go index b210a60..84ef4cb 100644 --- a/htmx/htmx_test.go +++ b/pkg/htmx/htmx_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" diff --git a/middleware/auth.go b/pkg/middleware/auth.go similarity index 95% rename from middleware/auth.go rename to pkg/middleware/auth.go index 3246d55..cfbdd46 100644 --- a/middleware/auth.go +++ b/pkg/middleware/auth.go @@ -5,10 +5,10 @@ import ( "net/http" "strconv" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/msg" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/msg" + "github.com/mikestefanello/pagoda/pkg/services" "github.com/labstack/echo/v4" ) diff --git a/middleware/auth_test.go b/pkg/middleware/auth_test.go similarity index 97% rename from middleware/auth_test.go rename to pkg/middleware/auth_test.go index 47b767d..eebd910 100644 --- a/middleware/auth_test.go +++ b/pkg/middleware/auth_test.go @@ -5,9 +5,9 @@ import ( "net/http" "testing" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/require" diff --git a/middleware/cache.go b/pkg/middleware/cache.go similarity index 96% rename from middleware/cache.go rename to pkg/middleware/cache.go index c33d123..57e0c95 100644 --- a/middleware/cache.go +++ b/pkg/middleware/cache.go @@ -5,8 +5,8 @@ import ( "net/http" "time" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/services" "github.com/go-redis/redis/v8" "github.com/labstack/echo/v4" diff --git a/middleware/cache_test.go b/pkg/middleware/cache_test.go similarity index 97% rename from middleware/cache_test.go rename to pkg/middleware/cache_test.go index f9c6e01..948c924 100644 --- a/middleware/cache_test.go +++ b/pkg/middleware/cache_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/require" diff --git a/middleware/entity.go b/pkg/middleware/entity.go similarity index 95% rename from middleware/entity.go rename to pkg/middleware/entity.go index 3d433ee..c13bee7 100644 --- a/middleware/entity.go +++ b/pkg/middleware/entity.go @@ -5,9 +5,9 @@ import ( "net/http" "strconv" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/ent/user" + "github.com/mikestefanello/pagoda/pkg/context" "github.com/labstack/echo/v4" ) diff --git a/middleware/entity_test.go b/pkg/middleware/entity_test.go similarity index 83% rename from middleware/entity_test.go rename to pkg/middleware/entity_test.go index 6a83b27..42f4f33 100644 --- a/middleware/entity_test.go +++ b/pkg/middleware/entity_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/middleware/log.go b/pkg/middleware/log.go similarity index 100% rename from middleware/log.go rename to pkg/middleware/log.go diff --git a/middleware/log_test.go b/pkg/middleware/log_test.go similarity index 92% rename from middleware/log_test.go rename to pkg/middleware/log_test.go index d0c28ef..a6b294a 100644 --- a/middleware/log_test.go +++ b/pkg/middleware/log_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/labstack/echo/v4" diff --git a/middleware/middleware_test.go b/pkg/middleware/middleware_test.go similarity index 85% rename from middleware/middleware_test.go rename to pkg/middleware/middleware_test.go index dc07986..6c5d5c3 100644 --- a/middleware/middleware_test.go +++ b/pkg/middleware/middleware_test.go @@ -6,8 +6,8 @@ import ( "github.com/mikestefanello/pagoda/config" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/services" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/services" + "github.com/mikestefanello/pagoda/pkg/tests" ) var ( diff --git a/msg/msg.go b/pkg/msg/msg.go similarity index 100% rename from msg/msg.go rename to pkg/msg/msg.go diff --git a/msg/msg_test.go b/pkg/msg/msg_test.go similarity index 94% rename from msg/msg_test.go rename to pkg/msg/msg_test.go index fd8b8b1..38da0ce 100644 --- a/msg/msg_test.go +++ b/pkg/msg/msg_test.go @@ -3,7 +3,7 @@ package msg import ( "testing" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/routes/about.go b/pkg/routes/about.go similarity index 97% rename from routes/about.go rename to pkg/routes/about.go index f9665ae..35f80e8 100644 --- a/routes/about.go +++ b/pkg/routes/about.go @@ -3,7 +3,7 @@ package routes import ( "html/template" - "github.com/mikestefanello/pagoda/controller" + "github.com/mikestefanello/pagoda/pkg/controller" "github.com/labstack/echo/v4" ) diff --git a/routes/about_test.go b/pkg/routes/about_test.go similarity index 100% rename from routes/about_test.go rename to pkg/routes/about_test.go diff --git a/routes/contact.go b/pkg/routes/contact.go similarity index 92% rename from routes/contact.go rename to pkg/routes/contact.go index 305720b..c61fda0 100644 --- a/routes/contact.go +++ b/pkg/routes/contact.go @@ -3,8 +3,8 @@ package routes import ( "fmt" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" "github.com/labstack/echo/v4" ) diff --git a/routes/error.go b/pkg/routes/error.go similarity index 87% rename from routes/error.go rename to pkg/routes/error.go index d6f2270..0fe9792 100644 --- a/routes/error.go +++ b/pkg/routes/error.go @@ -3,8 +3,8 @@ package routes import ( "net/http" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" "github.com/labstack/echo/v4" ) diff --git a/routes/forgot_password.go b/pkg/routes/forgot_password.go similarity index 94% rename from routes/forgot_password.go rename to pkg/routes/forgot_password.go index daa9b88..2d28545 100644 --- a/routes/forgot_password.go +++ b/pkg/routes/forgot_password.go @@ -4,11 +4,11 @@ import ( "fmt" "strings" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/ent/user" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" "github.com/labstack/echo/v4" ) diff --git a/routes/home.go b/pkg/routes/home.go similarity index 95% rename from routes/home.go rename to pkg/routes/home.go index 721d97b..7017414 100644 --- a/routes/home.go +++ b/pkg/routes/home.go @@ -3,7 +3,7 @@ package routes import ( "fmt" - "github.com/mikestefanello/pagoda/controller" + "github.com/mikestefanello/pagoda/pkg/controller" "github.com/labstack/echo/v4" ) diff --git a/routes/login.go b/pkg/routes/login.go similarity index 93% rename from routes/login.go rename to pkg/routes/login.go index 9c37d90..50ba15d 100644 --- a/routes/login.go +++ b/pkg/routes/login.go @@ -4,11 +4,11 @@ import ( "fmt" "strings" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/ent/user" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" "github.com/labstack/echo/v4" ) diff --git a/routes/logout.go b/pkg/routes/logout.go similarity index 79% rename from routes/logout.go rename to pkg/routes/logout.go index 70a9cb8..18ccdbc 100644 --- a/routes/logout.go +++ b/pkg/routes/logout.go @@ -1,8 +1,8 @@ package routes import ( - "github.com/mikestefanello/pagoda/controller" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" "github.com/labstack/echo/v4" ) diff --git a/routes/register.go b/pkg/routes/register.go similarity index 95% rename from routes/register.go rename to pkg/routes/register.go index 0f83622..85f4b66 100644 --- a/routes/register.go +++ b/pkg/routes/register.go @@ -3,10 +3,10 @@ package routes import ( "fmt" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" "github.com/labstack/echo/v4" ) diff --git a/routes/reset_password.go b/pkg/routes/reset_password.go similarity index 92% rename from routes/reset_password.go rename to pkg/routes/reset_password.go index af69775..ddaf981 100644 --- a/routes/reset_password.go +++ b/pkg/routes/reset_password.go @@ -1,10 +1,10 @@ package routes import ( - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" "github.com/labstack/echo/v4" ) diff --git a/routes/router.go b/pkg/routes/router.go similarity index 95% rename from routes/router.go rename to pkg/routes/router.go index ca5c0b1..384e760 100644 --- a/routes/router.go +++ b/pkg/routes/router.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/controller" - "github.com/mikestefanello/pagoda/middleware" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/middleware" + "github.com/mikestefanello/pagoda/pkg/services" "github.com/gorilla/sessions" "github.com/labstack/echo-contrib/session" diff --git a/routes/routes_test.go b/pkg/routes/routes_test.go similarity index 98% rename from routes/routes_test.go rename to pkg/routes/routes_test.go index f7409f2..cc180bf 100644 --- a/routes/routes_test.go +++ b/pkg/routes/routes_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/services" + "github.com/mikestefanello/pagoda/pkg/services" "github.com/PuerkitoBio/goquery" "github.com/stretchr/testify/assert" diff --git a/routes/search.go b/pkg/routes/search.go similarity index 93% rename from routes/search.go rename to pkg/routes/search.go index ca99b3b..887baa9 100644 --- a/routes/search.go +++ b/pkg/routes/search.go @@ -4,7 +4,7 @@ import ( "fmt" "math/rand" - "github.com/mikestefanello/pagoda/controller" + "github.com/mikestefanello/pagoda/pkg/controller" "github.com/labstack/echo/v4" ) diff --git a/routes/verify_email.go b/pkg/routes/verify_email.go similarity index 90% rename from routes/verify_email.go rename to pkg/routes/verify_email.go index 740c1ea..a744108 100644 --- a/routes/verify_email.go +++ b/pkg/routes/verify_email.go @@ -2,11 +2,11 @@ package routes import ( "github.com/labstack/echo/v4" - "github.com/mikestefanello/pagoda/context" - "github.com/mikestefanello/pagoda/controller" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/ent/user" - "github.com/mikestefanello/pagoda/msg" + "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/msg" ) type verifyEmail struct { diff --git a/services/auth.go b/pkg/services/auth.go similarity index 99% rename from services/auth.go rename to pkg/services/auth.go index a10f26b..c2b06ce 100644 --- a/services/auth.go +++ b/pkg/services/auth.go @@ -9,10 +9,10 @@ import ( "github.com/golang-jwt/jwt" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/context" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/ent/passwordtoken" "github.com/mikestefanello/pagoda/ent/user" + "github.com/mikestefanello/pagoda/pkg/context" "github.com/labstack/echo-contrib/session" "github.com/labstack/echo/v4" diff --git a/services/auth_test.go b/pkg/services/auth_test.go similarity index 100% rename from services/auth_test.go rename to pkg/services/auth_test.go diff --git a/services/cache.go b/pkg/services/cache.go similarity index 100% rename from services/cache.go rename to pkg/services/cache.go diff --git a/services/cache_test.go b/pkg/services/cache_test.go similarity index 100% rename from services/cache_test.go rename to pkg/services/cache_test.go diff --git a/services/container.go b/pkg/services/container.go similarity index 100% rename from services/container.go rename to pkg/services/container.go diff --git a/services/container_test.go b/pkg/services/container_test.go similarity index 100% rename from services/container_test.go rename to pkg/services/container_test.go diff --git a/services/mail.go b/pkg/services/mail.go similarity index 100% rename from services/mail.go rename to pkg/services/mail.go diff --git a/services/mail_test.go b/pkg/services/mail_test.go similarity index 100% rename from services/mail_test.go rename to pkg/services/mail_test.go diff --git a/services/services_test.go b/pkg/services/services_test.go similarity index 93% rename from services/services_test.go rename to pkg/services/services_test.go index 9347f29..50b39fe 100644 --- a/services/services_test.go +++ b/pkg/services/services_test.go @@ -6,7 +6,7 @@ import ( "github.com/mikestefanello/pagoda/config" "github.com/mikestefanello/pagoda/ent" - "github.com/mikestefanello/pagoda/tests" + "github.com/mikestefanello/pagoda/pkg/tests" "github.com/labstack/echo/v4" ) diff --git a/services/tasks.go b/pkg/services/tasks.go similarity index 100% rename from services/tasks.go rename to pkg/services/tasks.go diff --git a/services/tasks_test.go b/pkg/services/tasks_test.go similarity index 100% rename from services/tasks_test.go rename to pkg/services/tasks_test.go diff --git a/services/template_renderer.go b/pkg/services/template_renderer.go similarity index 99% rename from services/template_renderer.go rename to pkg/services/template_renderer.go index a878cfd..5cdff50 100644 --- a/services/template_renderer.go +++ b/pkg/services/template_renderer.go @@ -11,7 +11,7 @@ import ( "sync" "github.com/mikestefanello/pagoda/config" - "github.com/mikestefanello/pagoda/funcmap" + "github.com/mikestefanello/pagoda/pkg/funcmap" ) type ( diff --git a/services/template_renderer_test.go b/pkg/services/template_renderer_test.go similarity index 100% rename from services/template_renderer_test.go rename to pkg/services/template_renderer_test.go diff --git a/services/validator.go b/pkg/services/validator.go similarity index 100% rename from services/validator.go rename to pkg/services/validator.go diff --git a/services/validator_test.go b/pkg/services/validator_test.go similarity index 100% rename from services/validator_test.go rename to pkg/services/validator_test.go diff --git a/worker/tasks/example.go b/pkg/tasks/example.go similarity index 100% rename from worker/tasks/example.go rename to pkg/tasks/example.go diff --git a/tests/tests.go b/pkg/tests/tests.go similarity index 100% rename from tests/tests.go rename to pkg/tests/tests.go