Source code to EasyMirror's backend
- This repo is containerized using Docker.
- All containers start with the name
easymirror-backend
- It follows advice from the following sources:
- To build this docker image, run the following command:
$ docker build -t easymirror-backend:TAG .
- To build a docker image with env variables:
$ docker-compose up
- As we will not be paying for an organization Dockerhub, all containers will be stored in a personal docker hub.
- In order to have a proper CI/CD workflow, updates will be done in stages.
- Create new branch with goal feature
- Do all necessary commits to make the feature work
- Make a pull request to merge into the
staging
branch - If all tests pass and nothing breaks, make a pull request into the
v*.*.*
branch.
Name | Description | Example |
---|---|---|
\*Feature name* |
Will be used as a development branch | add_user_endpoint branch |
staging |
Nearly exact replica of a production environment for testing. | staging |
v*.*.* |
Quality Assurance branch. | v1.0.2 |
main |
Production branch. Will be used by clients. | main |
- User makes a request to get a presigned URL to upload the files to AWS S3
- User makes a request telling server which hosts to mirror to
- Server mirrors to other hosts
- Using the mirror ID (UUID), lookup the folder in the S3 bucket
- For each file in folder:
- Create a private presigned URL
- Download the contents from the presigned URL and upload to other host
- Integrate postgresSQL
- Upload endpoints
- Accept multiple files
- For each file uploaded:
- Add file data to
files
table in database - Upload to AWS S3 bucket
- Create a new folder for uploads that are uploaded together
- Upload to other hosts
- After uploading to other hosts, delete from S3 bucket
- Add file data to
- Account endpoint
- Endpoint that returns account info
- Endpoint that allows updating account info
- History
- Endpoint that returns upload history
- Endpoint to allow renaming of history item
- Endpoint that gives list of files in history link
- Endpoint to delete history item
- Authentication
- When a new user joins, set a JWT
- JWT refresh every 12 hours
- When deleting mirror links, cascade delete all relevant files too
- When creating a new user, set the
member_since
column - Refactor getting JWT token
- 1. in the
user
package, create aFromEcho
function to convert JWT to user - 2. Refactor all code to get JWT token
- 1. in the
- own package for
mirrorlinks
? - Endpoint for shareable mirror link
Benchmark to see which downloading method will be most efficient. Benchmark(s) can be found here.
goos: darwin
goarch: arm64
pkg: github.com/easymirror/easymirror-backend/tests
BenchmarkDownloadPresigned
BenchmarkDownloadPresigned-14 1 1515022625 ns/op 301816 B/op 3332 allocs/op
BenchmarkDownloadS3Manager
BenchmarkDownloadS3Manager-14 1 13914433208 ns/op 84075549712 B/op 7245 allocs/op
PASS
ok github.com/easymirror/easymirror-backend/tests 15.567s
Benchmark to see which uploading method will be most efficient. Benchmark(s) can be found here.
goos: darwin
goarch: arm64
pkg: github.com/easymirror/easymirror-backend/tests
BenchmarkUploadWithPipe-14 1000000000 0.08321 ns/op 0 B/op 0 allocs/op
BenchmarkUploadWithBuf-14 1 1275108626 ns/op 28520 B/op 157 allocs/op
BenchmarkRealWorldPipe-14 1 2171659833 ns/op 373672 B/op 2127 allocs/op
PASS
ok github.com/easymirror/easymirror-backend/tests 4.652s