This repository contains the API server for the Fragments application. It provides endpoints for creating, reading, updating, and deleting fragments, as well as converting fragments between different formats.
- Fragments Metadata stored in Amazon DynamoDB
- Fragments Data stored in Amazon S3
- Configurable data model (
MemoryDB
or AWS S3/DynamoDB) via.env
- Support for creating text, image, and JSON fragments
- Update and delete functionality for authenticated users' fragments
- Fragment type conversion with support for various formats
- Automatic Docker image build and push to Amazon ECR
- Automatic deployment to Elastic Container Service (ECS)
- Node.js
- Express.js
- Amazon DynamoDB
- Amazon S3
- Docker
- GitHub Actions
- Amazon Elastic Container Registry (ECR)
- Amazon Elastic Container Service (ECS)
- Jest
- Hurl
- Markdown-it (for html conversions)
- Turndown (for markdown conversion)
- Papaparse (for json conversions)
- Sharp (for image conversions)
- Node.js and npm installed
- Docker installed
- AWS account with necessary permissions
- GitHub account
POST /fragments
: Create a new fragmentGET /fragments
: Get all fragments for the authenticated userGET /fragments/:id
: Get a specific fragmentPUT /fragments/:id
: Update an existing fragmentDELETE /fragments/:id
: Delete an existing fragmentGET /fragments/:id.ext
: Get a fragment converted to a specific format
This repository is set up with GitHub Actions for continuous deployment:
- On every new git tag, a Docker image is automatically built and pushed to Amazon ECR.
- The Docker container is then automatically deployed to ECS using the pre-built ECR image.
- ESLint
npm run lint
- Run server
npm run start
- Run server via nodemon
npm run dev
- Run server with debugger
npm run debug
- Curl with json handling
curl.exe -s http://localhost:8080 | jq
- Open VSCode in the current dir
code .
- Docker build
docker build -t fragments:latest .
- Docker run (test) from Docker Hub image
docker run --rm --name fragments --env-file env.jest -p 8080:8080 samtaitai/fragments:main
- scp file transfer
scp -i ~/.ssh/ccp555-key-pair.pem .env ec2-user@ec2-3-87-67-207.compute-1.amazonaws.com:
- npm version update (patch)
npm version patch
- Trigger CD
git push origin main --tags
- Entire test (jest)
npm test
- Single test (jest)
npm test post.test.js
- Unit Test (jest) coverage
npm run coverage
- Integration Test (Hurl)
npm run test:integration
- Create dev environment
docker compose up --build -d
- Set up local DB for dev environment
./scripts/local-aws-setup.sh