Write a Golang microservice for CRUD operations with news.
Approximate structure of the API:
POST /posts
GET /posts
PUT /posts/{id}
GET /posts/{id}
DELETE /posts/{id}
Post minimum contains: id, title, content, created_at,
updated_at.
Tests are required. (using testcontainers-go for spinning postgres docker containers)
It will be an advantage:
Use PostgreSQL
Makefile
Data validation (using reflection)
Migration (using Goose)
OpenAPI specification (using go-swagger)
REST microservice
Upload the code to Github.
There should be startup instructions. Ideally, this is a Makefile for assembly and a docker-compose file that should raise the DB instance
The following will be assessed:
Organization of the API
Tests (successful and failed cases)
Tech stack
Postgres for DB
Docker compose for local development
Air for hot reload
How to run
You should create .env.local in root folder and paste these secrets:
DB_USER=postgres
DB_PASSWORD=admin
DB_NAME=news
DB_PORT=5432
DB_HOST=db #changed during deployment, from docker-compose if local development
POSTGRES_USER=postgres
POSTGRES_PASSWORD=admin
POSTGRES_DB=news
Once you have up and running both your containers: You can start making requests to app on port 3000. See postman collection attached in /postman folder.
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.
TC39 advances 9 JavaScript proposals, including Array.fromAsync, Error.isError, and Explicit Resource Management, which are now headed into the ECMAScript spec.