Add database query status (and improved response), photos, likes, comments, bans

This commit is contained in:
Marco Realacci 2022-11-20 19:21:26 +01:00
parent 519ae22197
commit abbd5bc494
22 changed files with 1118 additions and 72 deletions

View file

@ -3,11 +3,12 @@ package main
import (
"errors"
"fmt"
"github.com/ardanlabs/conf"
"gopkg.in/yaml.v2"
"io"
"os"
"time"
"github.com/ardanlabs/conf"
"gopkg.in/yaml.v2"
)
// WebAPIConfiguration describes the web API configuration. This structure is automatically parsed by
@ -27,6 +28,9 @@ type WebAPIConfiguration struct {
DB struct {
Filename string `conf:"default:/tmp/decaf.db"`
}
Data struct {
Path string `conf:"default:/tmp/wasaphoto"`
}
}
// loadConfiguration creates a WebAPIConfiguration starting from flags, environment variables and configuration file.

View file

@ -28,17 +28,18 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/notherealmarco/WASAPhoto/service/api"
"github.com/notherealmarco/WASAPhoto/service/database"
"github.com/notherealmarco/WASAPhoto/service/globaltime"
"github.com/ardanlabs/conf"
_ "github.com/mattn/go-sqlite3"
"github.com/sirupsen/logrus"
"math/rand"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/ardanlabs/conf"
_ "github.com/mattn/go-sqlite3"
"github.com/notherealmarco/WASAPhoto/service/api"
"github.com/notherealmarco/WASAPhoto/service/database"
"github.com/notherealmarco/WASAPhoto/service/globaltime"
"github.com/sirupsen/logrus"
)
// main is the program entry point. The only purpose of this function is to call run() and set the exit code if there is
@ -113,6 +114,7 @@ func run() error {
apirouter, err := api.New(api.Config{
Logger: logger,
Database: db,
DataPath: cfg.Data.Path,
})
if err != nil {
logger.WithError(err).Error("error creating the API server instance")