pkg

package
v0.0.0-...-db1fa1f Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FUN_CREATE_NOTE FUNCTION_NAME = "create_note"
	FUN_READ_NOTE                 = "read_note"
	FUN_DELETE_NOTE               = "delete_note"
)

Variables

This section is empty.

Functions

func GetClientContext

func GetClientContext() (*mongo.Client, context.Context, context.CancelFunc)

func MakeResponse

func MakeResponse(obj interface{}, StatusCode int) (events.APIGatewayProxyResponse, error)

MakeResponse returns a response with the given body and status code.

func Marshal

func Marshal(entity interface{}) string

func ParseBody

func ParseBody[T any](body string) (*T, error)

func ParseResponseBody

func ParseResponseBody(resp events.APIGatewayProxyResponse) (map[string]interface{}, error)

Types

type COLLECTION_NAME

type COLLECTION_NAME string
const (
	// COL_NOTES is the name of the collection that stores notes.
	COL_NOTES COLLECTION_NAME = "notes"
)

type Datetime

type Datetime struct {
	primitive.DateTime
}

func GetDateTimeNow

func GetDateTimeNow() Datetime

GetDateTime returns the current date time in the format YYYY-MM-DD HH:MM:SS

func (*Datetime) UnmarshalJSON

func (t *Datetime) UnmarshalJSON(input []byte) error

UnmarshalJSON parse isoformat date

type FUNCTION_NAME

type FUNCTION_NAME string

type Note

type Note struct {
	Id        primitive.ObjectID `json:"id" bson:"_id"`
	URL       string             `json:"url"`
	Message   string             `json:"message" validate:"min=1,max=140"`
	Password  string             `json:"password"`
	ExpireAt  Datetime           `json:"expireAt" bson:"expireAt"`
	CreatedAt Datetime           `json:"createdAt"`
}

func (*Note) DecryptMessage

func (n *Note) DecryptMessage(key string) string

func (*Note) EncryptMessage

func (n *Note) EncryptMessage() string

EncryptMessage encrypts the message with random key and return the key

func (*Note) GenerateUrl

func (n *Note) GenerateUrl(usedKey string) string

generate and set note URL

func (*Note) GetCollectionName

func (n *Note) GetCollectionName() string

GetCollection returns the collection name for the given entity

type Queues

type Queues struct {
	QueueDeleteNote queue.Queue
}

type ResponseBodyType

type ResponseBodyType map[string]interface{}

Jump to

Keyboard shortcuts

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