<feed xmlns='http://www.w3.org/2005/Atom'>
<title>water-consumption/api/internal/controllers, branch staging</title>
<subtitle>A simple website to track water consumption between me and my GF.</subtitle>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/'/>
<entry>
<title>fix bugs, redo layout, reorg.</title>
<updated>2024-03-21T15:23:42+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-21T15:23:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=fd6f6f169f9ff9a1247228fb34dc9654a9584915'/>
<id>fd6f6f169f9ff9a1247228fb34dc9654a9584915</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>remove unnessary logs.</title>
<updated>2024-03-19T01:29:11+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-19T01:29:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=655aeaac60c7dec09276f469904752c7dc58c8c5'/>
<id>655aeaac60c7dec09276f469904752c7dc58c8c5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>clean up, add better error handling</title>
<updated>2024-03-19T01:27:24+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-19T01:27:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=eb51bdbfef8c2aacf0fdfde279a40de7f74c8d86'/>
<id>eb51bdbfef8c2aacf0fdfde279a40de7f74c8d86</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add routes for preference, clean up and add types</title>
<updated>2024-03-15T22:49:43+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-15T22:49:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=9cae9c1d2a0b4f7fa72f3075541b9ffafe1a7275'/>
<id>9cae9c1d2a0b4f7fa72f3075541b9ffafe1a7275</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>feat: Update authentication route and add comments to exported members</title>
<updated>2024-03-08T04:16:22+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-08T04:16:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=8fab2d03bce82e4dee798ebffb1e93c557f62a4b'/>
<id>8fab2d03bce82e4dee798ebffb1e93c557f62a4b</id>
<content type='text'>
- The authentication route in the API has been updated to use a new router setup function.
- Comments have been added to all exported members of the `auth.go` module in the internal controllers package.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- The authentication route in the API has been updated to use a new router setup function.
- Comments have been added to all exported members of the `auth.go` module in the internal controllers package.
</pre>
</div>
</content>
</entry>
<entry>
<title>chore: Update paths in test and database configuration</title>
<updated>2024-03-08T00:56:34+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-08T00:56:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=29f83e05270d0012ad9f273ac3364106fcff5f50'/>
<id>29f83e05270d0012ad9f273ac3364106fcff5f50</id>
<content type='text'>
This commit updates the paths in the test suite and database configuration to reflect the new directory structure. In the `api/cmd/main_test.go` file, the path for the config file is changed from `viper.SetConfigName(".env")` to `viper.SetConfigFile("../.env")` and `viper.AddConfigPath(".")` is added for configuration purposes. Additionally, `viper.AutomaticEnv()` is added to enable automatic environment variable configuration. In the same file, error handling is improved by adding explicit checks and error messages. The `api/internal/database/database.go` file is also modified, updating the path for database initialization from `"../db/water.sqlite3"` to `"../../db/water.sqlite3"`. These changes ensure proper configuration and functioning of the application.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit updates the paths in the test suite and database configuration to reflect the new directory structure. In the `api/cmd/main_test.go` file, the path for the config file is changed from `viper.SetConfigName(".env")` to `viper.SetConfigFile("../.env")` and `viper.AddConfigPath(".")` is added for configuration purposes. Additionally, `viper.AutomaticEnv()` is added to enable automatic environment variable configuration. In the same file, error handling is improved by adding explicit checks and error messages. The `api/internal/database/database.go` file is also modified, updating the path for database initialization from `"../db/water.sqlite3"` to `"../../db/water.sqlite3"`. These changes ensure proper configuration and functioning of the application.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add CORS middleware and authentication middleware to the API server.</title>
<updated>2024-03-08T00:16:07+00:00</updated>
<author>
<name>Zach Berwaldt</name>
<email>zberwaldt@tutamail.com</email>
</author>
<published>2024-03-08T00:16:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.zachberwaldt.dev/water-consumption/commit/?id=6651daca670664f3de8af9c7bcb74b1e7c6c6be9'/>
<id>6651daca670664f3de8af9c7bcb74b1e7c6c6be9</id>
<content type='text'>
The `setupRouter` function in `main.go` now includes a CORS middleware and a token authentication middleware. The CORS middleware allows cross-origin resource sharing by setting the appropriate response headers. The token authentication middleware checks for the presence of an `Authorization` header with a valid bearer token. If the token is missing or invalid, an unauthorized response is returned.

In addition to these changes, a new test file `main_test.go` has been added to test the `/api/v1/auth` route. This test suite includes two test cases: one for successful authentication and one for failed authentication.

Update go.mod to include new dependencies.

The `go.mod` file has been modified to include two new dependencies: `github.com/spf13/viper` and `github.com/stretchr/testify`.

Ignore go.sum changes.

Ignore changes in the `go.sum` file, as they only include updates to existing dependencies.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The `setupRouter` function in `main.go` now includes a CORS middleware and a token authentication middleware. The CORS middleware allows cross-origin resource sharing by setting the appropriate response headers. The token authentication middleware checks for the presence of an `Authorization` header with a valid bearer token. If the token is missing or invalid, an unauthorized response is returned.

In addition to these changes, a new test file `main_test.go` has been added to test the `/api/v1/auth` route. This test suite includes two test cases: one for successful authentication and one for failed authentication.

Update go.mod to include new dependencies.

The `go.mod` file has been modified to include two new dependencies: `github.com/spf13/viper` and `github.com/stretchr/testify`.

Ignore go.sum changes.

Ignore changes in the `go.sum` file, as they only include updates to existing dependencies.
</pre>
</div>
</content>
</entry>
</feed>
