package files

import (
	"git.mmnx.de/mmnx/cdn/module"
)

// RegisterModule calls neccessary actions for this module to work
func RegisterModule(paramConf *module.Config) {
	conf = paramConf
	db = conf.DB
	storagePath = "/go/src/app/dev/files/"

	// (Auto-)Migrate all models
	db.AutoMigrate(&File{}, &Storage{})

	// register HTTP APIs
	module.NegroniRoute(conf.Router, conf.BasePath, "/files", "GET POST PUT", filesIndex)
	module.NegroniRoute(conf.Router, conf.BasePath, "/files/{fileID}", "GET PATCH DELETE", filesSingle)
	module.NegroniRoute(conf.Router, conf.BasePath, "/files/{fileID}/file", "GET", filesRaw)
	module.NegroniRoute(conf.Router, conf.BasePath, "/mock/files", "GET", mockFiles)
}