From 9d3ce56e26840febdbda39a32473ba5d1cabddd3 Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Wed, 22 Jun 2016 22:40:18 -0700 Subject: [PATCH] Added storer interface Change-Id: I747bec339bdda26f0f68b24956912467ff67695d --- server.go | 4 ++-- storage.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 storage.go diff --git a/server.go b/server.go index b4139fb..e214be1 100644 --- a/server.go +++ b/server.go @@ -31,7 +31,7 @@ func init() { // Server serves up the http. type Server struct { - db *DB + db Storer static string emailTimeout time.Duration mail Mailer @@ -39,7 +39,7 @@ type Server struct { } // NewServer populates a server, adds the routes, and returns it for use. -func NewServer(sm *http.ServeMux, store *DB, m Mailer, static string, emailTimeout time.Duration, insecure bool) *Server { +func NewServer(sm *http.ServeMux, store Storer, m Mailer, static string, emailTimeout time.Duration, insecure bool) *Server { s := &Server{ db: store, static: static, diff --git a/storage.go b/storage.go new file mode 100644 index 0000000..2aa6b29 --- /dev/null +++ b/storage.go @@ -0,0 +1,16 @@ +package vain + +import "time" + +// Storer defines the db interface. +type Storer interface { + AddPackage(p Package) error + Confirm(token string) (string, error) + NSForToken(ns string, tok string) error + Package(path string) (Package, error) + PackageExists(path string) bool + Pkgs() []Package + Register(email string) (string, error) + RemovePackage(path string) error + forgot(email string, window time.Duration) (string, error) +}