separate profile model from account model

This commit is contained in:
dhax 2017-10-13 00:11:57 +02:00
parent f729160209
commit c3271d7dcf
15 changed files with 152 additions and 83 deletions

View file

@ -15,11 +15,13 @@ type ctxKey int
const (
ctxAccount ctxKey = iota
ctxProfile
)
// API provides application resources and handlers.
type API struct {
Account *AccountResource
Profile *ProfileResource
}
// NewAPI configures and returns application API.
@ -27,8 +29,12 @@ func NewAPI(db *pg.DB) (*API, error) {
accountStore := database.NewAccountStore(db)
account := NewAccountResource(accountStore)
profileStore := database.NewProfileStore(db)
profile := NewProfileResource(profileStore)
api := &API{
Account: account,
Profile: profile,
}
return api, nil
}
@ -38,6 +44,7 @@ func (a *API) Router() *chi.Mux {
r := chi.NewRouter()
r.Mount("/account", a.Account.router())
r.Mount("/profile", a.Profile.router())
return r
}