Skip to content

Awesome handles a video library in Mongo Atlas; it also manages ingestion using mux.com.

License

Notifications You must be signed in to change notification settings

javiertlopez/awesome

Repository files navigation

awesome Go codecov

Overview

Awesome is a REST API that stores a Video Library in Mongo Atlas and Mux.com for video ingestion.

Getting started

Test and build

Test the app:

make test

Usage

Install dependencies:

go get github.com/javiertlopez/awesome

Example

package main

import (
	"net/http"
	"os"
	"time"

	"github.com/javiertlopez/awesome"

	"github.com/sirupsen/logrus"
)

const (
	writeTimeout = 15 * time.Second
	readTimeout  = 15 * time.Second
	idleTimeout  = 60 * time.Second
)

var (
	application awesome.App
	commit      string
	version     string
)

func main() {
	// Environment variables
	addr := os.Getenv("ADDR")
	mongoString := os.Getenv("MONGO_STRING")
	muxTokenID := os.Getenv("MUX_TOKEN_ID")
	muxTokenSecret := os.Getenv("MUX_TOKEN_SECRET")
	muxKeyID := os.Getenv("MUX_KEY_ID")
	muxKeySecret := os.Getenv("MUX_KEY_SECRET")

	// Create a logrus logger and set up the output format as JSON
	logger := logrus.New()
	logger.Formatter = &logrus.JSONFormatter{}

	application = awesome.New(
		awesome.AppConfig{
			Commit:         commit,
			Version:        version,
			MongoDB:        mongoDB,
			MongoURI:       mongoString,
			MuxTokenID:     muxTokenID,
			MuxTokenSecret: muxTokenSecret,
			MuxKeyID:       muxKeyID,
			MuxKeySecret:   muxKeySecret,
		},
		logger,
	)

	// Create a Gorilla Mux router
	router := application.Router()

	// Create a Server instance with the router
	srv := &http.Server{
		Addr:         addr,
		WriteTimeout: writeTimeout,
		ReadTimeout:  readTimeout,
		IdleTimeout:  idleTimeout,
		Handler:      router,
	}

	// Start the server
	logger.Fatal(srv.ListenAndServe())
}

License

Licensed under MIT License. © 2024 Hiram Torres Lopez.

About

Awesome handles a video library in Mongo Atlas; it also manages ingestion using mux.com.

Resources

License

Stars

Watchers

Forks

Packages

No packages published