command module
Version: v0.0.0-...-cf413bb Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0


Thinking of You API server

Build Status

The goal of the api server is to provide basic device state delivery for client apps and a simple message interface for publishing and retreiving media to one or more target inboxes.

API Documentation

For now, refer to the OpenAPI spec file in the api directory for endpoint and response documentation.


An embedded sqlite3 database is used for persistent storage in this project. SQLite is a reliable and comprehensive embedded database used in many industries and applications. For this project, it gives a well understood and reliable basis for data persistence that should allow for minimal maintainance to keep the server running once deployed. Use the database/init_dev.sqlite.sql file for initalizing a testing instance of the database.

Create Test Database
# install sqlite3 cli tool
sudo apt install sqlite3
# pipe in database file
sqlite3 ./tofu.db < ./database/init_dev.sqlite.sql
Compiling with sqlite3

One caviate of using the sqlite3 database engine is that the C stdlib must be present on the target deployment platform and the compiling environment must have a C compiler toolchain to build the binary. See the library docs for more info.

For windows, see build.ps1

Run the Application

After creating the database file, use go run to compile and run the server.

go run ./cmd/server/
Run in Docker

If you don't want to compile and run from source, or you want to quickly switch between tagged releases, you can run the app in docker using the published container images.

docker run --rm \
	-p "8080:8080" \
	-v $(pwd):/data \
	-e TOFU_DATA=/data \
	-e GIN_MODE=debug \


The server accepts the following configuration via environment variables

# http listen address and port

# filepath and name of main database file 

# s3 style storage endpoint id and secret

# s3 bucket to store uploaded files
# both AWS_ACCESS_KEY_ID and TOFU_STORAGE_BUCKET must be defined for 
# s3 external storage to become active. Otherwise, local filesystem is used.

# region and endpoint settings for s3 api

# file prefix for files uploaded to message storage

# use the digitaloceans cdn download url instead of the regular spaces download url

Testing the Application

Start with the main client entrypoint

curl --user alice:alice http://localhost:8080/manifest

you should get the following response

	"id": "alice",
	"name": "Alice",
	"icon": "",
	"targets": [{
		"id": "bob",
		"name": "Bob",
		"icon": ""
	}, {
		"id": "carol",
		"name": "Carol",
		"icon": ""
	}, {
		"id": "dave",
		"name": "Dave",
		"icon": ""
	}, {
		"id": "erin",
		"name": "Erin",
		"icon": ""
	}, {
		"id": "testgroup",
		"name": "Test Group"
Test User credentials

All test users have a user name and password set. The password is the same as their id, so in curl use

curl --user alice:alice http://...
curl --user bob:bob http://...



Copyright (C) 2021 Sysreturn Community Contributors SPDX-License-Identifier: AGPL-3.0-or-later

Source Files


Path Synopsis
scheduled and async jobs.
scheduled and async jobs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL