goodidea

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: BSD-3-Clause Imports: 27 Imported by: 0

README

Good Idea

Good Idea is a slightly fancier TODO app where anonymous users may submit requests and vote on their importance. Users do not need to login or create an account to make a request or cast votes.

Requirements
  • Postgresql Database
  • environment variable DATABASE_URL to point the server at the database
Dev Requirements
  • go 1.21+
  • node.js 18+

Build

  1. Build and minify CSS and JS with: npm install && npm run build
  2. Build the server binary with go build ./app/main.go

To make it easy, use make to build

make build

which will populate the static directory and build a binary called server

Configure

By default, the server will attempt to user local storage for images under static/img. This can be changed by setting LOCAL_DIR within the environment.

If you prefer to use object storage instead, you can set the environment variables to provided the credentials needed to authenticate:

variable description
AWS_ACCESS_KEY_ID The access key provided by your object storage provider for the S3 compatible sdk
AWS_SECRET_ACCESS_KEY The secret key for authenticating to object storage
AWS_SESSION_TOKEN The token for the current session which can be used
AWS_DEFAULT_REGION The region the bucket is in

aws sdk env variables

In addition, the following variables may be used as well.

variable description
AWS_BUCKET The name of the bucket to use within the object store
AWS_IMAGE_CDN The URL (including the protocol, e.g. https) of the CDN which serves the images out of the bucket
AWS_ENDPOINT The URI for the object storage to try and connect to if not AWS S3

The system checks for the environment variables AWS_BUCKET to decide if it should be using object storage or not and thus, the rest are optional.

Status

warning This project is in beta

Deployment

For deployment information, please see the project wiki

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *pgxpool.Pool
)

Functions

func Connect

func Connect() error

func NewServer

func NewServer() *mux.Router

func SetupLogger

func SetupLogger()

func U20Validator added in v0.2.0

func U20Validator(fl validator.FieldLevel) bool

U20Validator checks if the string matches a userID which is an xid string with a u prefixed. i.e. starts with 'u' followed by 20 alphanumeric characters (a-v, 0-9)

Types

type Comment

type Comment struct {
	//Unique ID for this post
	ID uint64 `json:"id"`
	//The foreign key back to the tasks
	TaskID uint32 `json:"taskId"`
	//Optionally the person can leave a username
	User *string `json:"user"`
	//The comment box
	Content string `json:"comment"`
	//The time the comment was created
	CreatedAt time.Time `json:"createdAt"`
}

type ControllerError

type ControllerError struct {
	//Msg is a string field to capture a custom error message
	Msg string `json:"msg"`
	//Func is the name of the function the error occured in
	Func string `json:"func"`
	//Reason is a longer explication of what happened, could be a message from library
	Reason string `json:"reason"`
	//Cause is a pointer to why this error is being raised, e.g, error from sub functions
	Cause *ControllerError `json:"cause"`
}

ControllerError - An error with nested response

func (*ControllerError) Error

func (e *ControllerError) Error() string

type FileManager

type FileManager interface {
	StoreFile(b []byte, ext string) (string, error)
}

func NewFileManager

func NewFileManager() FileManager

type Task

type Task struct {
	ID          uint32     `json:"id"`
	Status      bool       `json:"status"`
	Title       string     `json:"title"`
	Body        *string    `json:"body"`
	Score       int32      `json:"score"`
	CompletedAt *time.Time `json:"completedAt"`
	CreatedAt   time.Time  `json:"createdAt"`
	DeletedAt   time.Time  `json:"deletedAt"`
	Comments    []Comment  `json:"comments"`
	Images      []string   `json:"images"` //paths to get all of the images associated with task
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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