This service provides a REST API for managing blueprints, along with a Go CLI tool for easy interaction.
A NestJS service for managing Bluebricks Blueprints. This service provides a RESTful API for storing, retrieving, updating, and deleting Blueprints in a PostgreSQL database.
- CRUD operations for Blueprints
- PostgreSQL database storage
- Input validation
- Swagger API documentation
- TypeScript support
- Node.js (v22+)
- Docker and Docker Compose
- npm
- Start the PostgreSQL database using Docker:
docker-compose up -dThis will start a PostgreSQL instance with the following configuration:
- Host: localhost
- Port: 5432
- Database: bluebricks
- Username: postgres
- Password: postgres
To stop the database:
docker-compose downTo stop the database and remove all data:
docker-compose down -vA Go CLI tool is provided in the cli directory for interacting with the Blueprint service.
- Install Go (1.20 or later)
- Visit https://golang.org/dl/
- Download and install Go for your operating system
- Verify installation:
go version
cd cli
go build -o blueprint-cliThe CLI supports the following commands:
- Create a Blueprint:
./blueprint-cli create --file blueprint.json- Get a Blueprint by ID:
./blueprint-cli get --id <blueprint-id>- List all Blueprints:
./blueprint-cli list- Update a Blueprint:
./blueprint-cli update --id <blueprint-id> --file updated-blueprint.json- Delete a Blueprint:
./blueprint-cli delete --id <blueprint-id>When creating or updating a blueprint, use a JSON file with the following structure:
{
"name": "Sample Blueprint",
"description": "A sample blueprint",
"content": "Blueprint content goes here",
"version": "1.0.0"
}An example file is provided at cli/example.json.
- Install dependencies:
npm ci- Configure environment variables:
# Create .env file
cat > .env << EOL
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE=bluebricks
PORT=3000
EOL# Development mode
npm run start:dev
# Production mode
npm run build
npm run start:prodThe service will be available at http://localhost:3000 Swagger documentation will be available at http://localhost:3000/api
POST /blueprints
curl -X POST http://localhost:3000/blueprints \
-H "Content-Type: application/json" \
-d @bricks.jsonGET /blueprints/:id
curl http://localhost:3000/blueprints/123e4567-e89b-12d3-a456-426614174000GET /blueprints
# List all
curl http://localhost:3000/blueprints
# Filter by version
curl http://localhost:3000/blueprints?version=1.1.0
# Filter by author
curl http://localhost:3000/blueprints?author=pini@bluebricks.coPUT /blueprints/:id
curl -X PUT http://localhost:3000/blueprints/123e4567-e89b-12d3-a456-426614174000 \
-H "Content-Type: application/json" \
-d @bricks.jsonDELETE /blueprints/:id
curl -X DELETE http://localhost:3000/blueprints/123e4567-e89b-12d3-a456-426614174000# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:covMIT