joshnies / decentvcs-server

Server for DecentVCS, a simple version control system that utilizes decentralized storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DecentVCS

Core server for DecentVCS, the simple, affordable, and decentralized version control system.

Requirements

Dependency Version
go 1.19+

Environment

Dotenv

Create a new .env file in the root directory, using the .env.example file for reference.

Doppler

We recommend using Doppler in deployed environments for enhanced security.

Running (local development)

# With dotenv
go run main.go

# With doppler
./run
# or
doppler run -- go run main.go

Build

./install.sh

It should be added to your path automatically. You can then run the built executable by running:

dvcs-server

Using the REST API

Authentication

We use Stytch for session-based authentication. Once the user goes through one of Stytch's auth flows, you'll receive a session token that can be sent with any request to the VCS server as the X-Session-Token header.

Example request:

POST /projects/myteam/myproject
X-Session-Token: ****1234
Content-Type: application/json
Body:
{
    "hello": "world"
}

Access keys

You can also use access keys to authenticate with the VCS server. These are generated by the client application and are scoped to specific functionality.

Access keys expire after 24 hours, and should be deleted by the client application after use.

Example request:

PUT /teams/myteam
X-Access-Key: ****1234
Content-Type: application/json
Body:
{
    "storage_used_mb": 12.34
}

Routes

Method Path Description
POST /session Create or refresh session
DELETE /session Revoke session (remote logout)
POST /init Initialize all required resources for a user
POST /projects/:team_name/:project_name Create one project
GET /projects/:team_name/:project_name Get one project
PUT /projects/:team_name/:project_name Update one project by ID
GET /projects/:team_name/:project_name/branches Get many branches for a project
POST /projects/:team_name/:project_name/branches Create one branch for a project
GET /projects/:team_name/:project_name/branches/default Get the default branch of a project
GET /projects/:team_name/:project_name/branches/:branch_name Get one branch by ID or name for a project
DELETE /projects/:team_name/:project_name/branches/:branch_name Delete one branch by ID or name for a project
POST /projects/:team_name/:project_name/branches/:branch_name/commit Create one commit
GET /projects/:team_name/:project_name/branches/:branch_name/commits Get many commits for a branch
GET /projects/:team_name/:project_name/commits Get many commits for a project
GET /projects/:team_name/:project_name/commits/:commit_index Get one commit for a project
PUT /projects/:team_name/:project_name/commits/:commit_index Update one commit for a project
GET /projects/:team_name/:project_name/storage/presign/many Presign many objects (GET method only)
POST /projects/:team_name/:project_name/storage/presign/:method Presign one object
POST /projects/:team_name/:project_name/storage/multipart/complete Complete a multipart upload
DELETE /projects/:team_name/:project_name/storage/unused Delete all unused files in storage for a project
GET /teams Get many teams
POST /teams Create one team
GET /teams/:team_name Get one team
PUT /teams/:team_name Update one team
DELETE /teams/:team_name Delete one team
GET /teams/:team_name/projects Get many projects
POST /teams/:team_name/access_keys Create an access key
DELETE /teams/:team_name/access_keys Delete the request's access key
GET /users/me Get own user data
PUT /users/me Update own user data

About

Server for DecentVCS, a simple version control system that utilizes decentralized storage

License:GNU General Public License v3.0


Languages

Language:Go 99.6%Language:Dockerfile 0.4%Language:Shell 0.0%