
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
github.com/kirildevops/weather-api
Advanced tools
Project structure have been influenced by following along with the course backend-master-class-golang-postgresql-kubernetes Some parts were replicated (NOT copied) from the course video.
SQL database. Postgres 12 in this case. Potentially can be replaced with more recent version. Runs inside Docker
sqlc to interact with Postgres. And the lib/pq as the driver. Can be replaced with pgx later. SQLC docs
golang-migrate to facilitate DB migrations. Currently as a standalone CLI. Can be moved to the container version.
viper to load configs.
dotenv to load the API_KEY for the 3rd party service.
testify to run asserts, mocks etc.
uuid from Google to generate random unique string that we use as a token
gin-gonic as a web-framework to serve our API
net/http standard package to query external API
protoc compiler to work with protobufs (not finished yet)
Makefile to make some aliasing simpler.
app.env file. It contains the config of our app.
This information is sensitive and commited to the repo just for the development purposes.Viper will read this file and populate some configs..env file in the root of the repository. Precede it with WEATHER_API_KEY=Run the next set of commands to check the work
make postgres to create the postgres container in the docker network. (TBD use Docker Compose to spin up the DB)
make migrateup to run the migrations.
make sqlc to generate sqlc idiomatic Go code to interact with Postgresql
make test to run DB tests (only weather-api/db/sqlc is covered at this time)
make server to run the server
Postman can be used if necessary. But curl is used for the simplicity sake.
Test Subscribe Endpoint: Open the new terminal window and run curl -X POST -H "Content-Type: application/json" -d @req1.json http://localhost:8080/api/subscribe | jq
Connect to the db via DBeaver or alike tool to check the result. There are some remnants of testing with garbage data. It could be cleaned up later.
Test Confirm Endpoint: Open the new terminal window and run curl -X GET http://localhost:8080/api/confirm/2d77cd87-161f-4efb-a9f0-8831aa52cd44
Test Weather Endpoint: Open the new terminal window and run curl -X GET http://localhost:8080/api/weather?city=Kyiv
Test UnSubscribe Endpoint: Open the new terminal window and run curl -X GET http://localhost:8080/api/unsubscribe/3d64fede-e088-4b15-9b4c-94cf1 where the last part is the token which can be copied from the DB column.
Use make proto to build the pb.go files from proto into the pb directory (UNDER CONSTRUCTION)
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.