
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
github.com/0xOthmane/golang_projects/rss_aggregator
go mod init github.com/0xOthmane/golang_projects/rss_aggregator
go get github.com/joho/godotenv
go mod tidy
go mod vendor
go build && ./rss_aggregator
Use of chi lightweight, idiomatic and composable router for building Go HTTP services
go get github.com/go-chi/chi
go get github.com/go-chi/cors
go mod vendor
go mod tidy
go mod vendor
Create a Router and a Server (port:8080 defined in .env file).
Define helper functions that write an HTTP response with: status code, JSON body, content type: application/json
.
Test the helper function with sending a request (GET/POST/..) to http://localhost:8080/v1/healthz. Or Specify what type of request you allow by changing v1Router.HandleFunc()
to v1Router.Get()
sudo mkdir -p /var/lib/postgresql/data
docker pull postgres
docker run -itd -e POSTGRES_USER=USERNAME -e POSTGRES_PASSWORD=PASSWORD -p 5432:5432 -v /data:/var/lib/postgresql/data --name postgresql postgres
docker pull dpage/pgadmin4
docker run --name pgadmin -p 5051:80 -e "PGADMIN_DEFAULT_EMAIL=YOUR_EMAIL" -e "PGADMIN_DEFAULT_PASSWORD=YOUR_PASSWORD" -d dpage/pgadmin4
SQLC is just a command line tool, it's not a package that we need to import. I recommend installing it using go install
:
go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
Then run sqlc version
to make sure it's installed correctly.
Like SQLC, Goose is just a command line tool. I also recommend installing it using go install
:
go install github.com/pressly/goose/v3/cmd/goose@latest
Run goose -version
to make sure it's installed correctly.
cd in sql/schema folder and run:
goose postgres postgres://USERNAME:PASSWORD@HOST:5432/db up
At the root of the project, create a yaml file sqlc.yaml. Inside /sql folder, create another /queries folder and add a users.sql file.
cd $PROJECT_ROOT
sqlc generate
Using the sql package from the Go's standard library we open a connection with postgres db.
Endpoint: POST /v1/users Create a User model to adapt the User struct generated by sqlc.
Create a new migration sql file in sql/schema and run command: goose postgres postgres://USER:PASS@HOST:5432/db up
.
Update the query to create a user and regenerate database package with sqlc sqlc generate
.
Add a new query to get a user by API key.
Each time you update your queries or schema you'll need to regenerate your Go code with sqlc generate. If you update the schema you'll also need to migrate your database up (and maybe down). Create a new package in internal folder /internal/auth and create a function GetAPIKey wich will extracts the key from the HTTP request header.
Add a new migration and create a new table for feeds and appropriate columns. run goose command from /sql/schema folder Add a new query to create a feed, then use sqlc generate to generate the Go code. Create function to map a dbFeed to a Feed, and a slice of dbFeeds to a slice of Feed. Add a new query to get all the feeds in db (no auth).
Add a new migration and create a new table for feed follows (constraint unique(user_id, feed_id)).
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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.