diff --git a/core/api/account.go b/core/api/account.go index 7ecdd00..0957ca9 100644 --- a/core/api/account.go +++ b/core/api/account.go @@ -13,12 +13,12 @@ import ( /** * @api {get} /orgs/:orgId/accounts Get Accounts by Org id - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetOrgAccounts * @apiGroup Account * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Account. * @apiSuccess {String} orgId Id of the Org. @@ -85,12 +85,12 @@ func GetOrgAccounts(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /orgs/:orgId/accounts Create a new Account - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostAccount * @apiGroup Account * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id Id 32 character hex string * @apiParam {String} name Name of the Account. @@ -198,12 +198,12 @@ func PostAccounts(w rest.ResponseWriter, r *rest.Request, content []byte) { /** * @api {put} /orgs/:orgId/accounts/:accountId Modify an Account - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutAccount * @apiGroup Account * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id Id 32 character hex string * @apiParam {String} name Name of the Account. @@ -273,12 +273,12 @@ func PutAccount(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /orgs/:orgId/accounts/:accountId Delete an Account - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeleteAccount * @apiGroup Account * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/api.go b/core/api/api.go index 8e57123..e409c2e 100644 --- a/core/api/api.go +++ b/core/api/api.go @@ -7,6 +7,9 @@ import ( /** * Changelog * + * 1.1.0 + * - add `GET /health-check` + * * 1.0.1 * - add user.signupSource * diff --git a/core/api/apikey.go b/core/api/apikey.go index 47a7cd9..6570f01 100644 --- a/core/api/apikey.go +++ b/core/api/apikey.go @@ -9,12 +9,12 @@ import ( /** * @api {get} /apikeys Get API keys - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetApiKeys * @apiGroup ApiKey * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the ApiKey. * @apiSuccess {Date} inserted Date ApiKey was created @@ -52,11 +52,11 @@ func GetApiKeys(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /apikeys Create a new API key - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostApiKey * @apiGroup ApiKey * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * @apiHeader {String} Authorization HTTP Basic Auth * * @apiParam {String} id 32 character hex string @@ -105,11 +105,11 @@ func PostApiKey(w rest.ResponseWriter, r *rest.Request) { /** * @api {put} /apikeys Modify an API key - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutApiKey * @apiGroup ApiKey * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * @apiHeader {String} Authorization HTTP Basic Auth * * @apiParam {String} id 32 character hex string @@ -160,12 +160,12 @@ func PutApiKey(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /apikeys/:apiKeyId Delete an API key - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeleteApiKey * @apiGroup ApiKey * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/org.go b/core/api/org.go index c1ceb26..48904c2 100644 --- a/core/api/org.go +++ b/core/api/org.go @@ -9,12 +9,12 @@ import ( /** * @api {get} /org/:orgId Get Org by id - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetOrg * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Org. * @apiSuccess {Date} inserted Date Org was created @@ -53,12 +53,12 @@ func GetOrg(w rest.ResponseWriter, r *rest.Request) { /** * @api {get} /orgs Get a User's Orgs - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetOrgs * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Org. * @apiSuccess {Date} inserted Date Org was created @@ -98,12 +98,12 @@ func GetOrgs(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /orgs Create a new Org - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostOrg * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id Id 32 character hex string * @apiParam {String} name Name of the Org. @@ -152,12 +152,12 @@ func PostOrg(w rest.ResponseWriter, r *rest.Request) { /** * @api {put} /orgs/:orgId Modify an Org - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutOrg * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} name Name of the Org. * @@ -207,12 +207,12 @@ func PutOrg(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /orgs/:orgId/invites Invite a user to an Org - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostInvite * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} email Email address of user * @@ -263,12 +263,12 @@ func PostInvite(w rest.ResponseWriter, r *rest.Request) { /** * @api {put} /orgs/:orgId/invites/:inviteId Accept an invitation - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutInvite * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} accepted true * @@ -320,12 +320,12 @@ func PutInvite(w rest.ResponseWriter, r *rest.Request) { /** * @api {get} /orgs/:orgId/invites Get Org invites - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetInvites * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Invite * @apiSuccess {orgId} id Id of the Org @@ -366,12 +366,12 @@ func GetInvites(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /orgs/:orgId/invites/:inviteId Delete Invite - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeleteInvite * @apiGroup Org * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/price.go b/core/api/price.go index 4bf3a31..33e1c90 100644 --- a/core/api/price.go +++ b/core/api/price.go @@ -11,12 +11,12 @@ import ( /** * @api {get} /org/:orgId/prices Get prices nearest in time or by currency - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetPrices * @apiGroup Price * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {Number} nearestDate Milliseconds since epoch * @apiParam {String} currency Currency code @@ -93,12 +93,12 @@ func GetPrices(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /orgs/:orgId/prices Create a new Price - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostPrice * @apiGroup Price * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id Id 32 character hex string. * @apiParam {String} orgId Id of the Org. @@ -155,12 +155,12 @@ func PostPrice(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /orgs/:orgId/prices/:priceId Delete a Price - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeletePrice * @apiGroup Price * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/routes.go b/core/api/routes.go index 9bc257b..71171af 100644 --- a/core/api/routes.go +++ b/core/api/routes.go @@ -7,42 +7,43 @@ import ( func GetRouter(auth *AuthMiddleware, prefix string) (rest.App, error) { return rest.MakeRouter( - rest.Get(prefix + "/user", auth.RequireAuth(GetUser)), - rest.Put(prefix + "/user", PutUser), - rest.Post(prefix + "/user/verify", VerifyUser), - rest.Post(prefix + "/user/reset-password", ResetPassword), - rest.Post(prefix + "/users", PostUser), - rest.Post(prefix + "/orgs", auth.RequireAuth(PostOrg)), - rest.Get(prefix + "/orgs", auth.RequireAuth(GetOrgs)), - rest.Get(prefix + "/orgs/:orgId", auth.RequireAuth(GetOrg)), - rest.Put(prefix + "/orgs/:orgId", auth.RequireAuth(PutOrg)), - rest.Get(prefix + "/orgs/:orgId/ledgers", auth.RequireAuth(GetOrgAccounts)), - rest.Post(prefix + "/orgs/:orgId/ledgers", auth.RequireAuth(PostAccount)), - rest.Put(prefix + "/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(PutAccount)), - rest.Delete(prefix + "/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(DeleteAccount)), - rest.Get(prefix + "/orgs/:orgId/ledgers/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)), - rest.Get(prefix + "/orgs/:orgId/accounts", auth.RequireAuth(GetOrgAccounts)), - rest.Post(prefix + "/orgs/:orgId/accounts", auth.RequireAuth(PostAccount)), - rest.Put(prefix + "/orgs/:orgId/accounts/:accountId", auth.RequireAuth(PutAccount)), - rest.Delete(prefix + "/orgs/:orgId/accounts/:accountId", auth.RequireAuth(DeleteAccount)), - rest.Get(prefix + "/orgs/:orgId/accounts/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)), - rest.Get(prefix + "/orgs/:orgId/transactions", auth.RequireAuth(GetTransactionsByOrg)), - rest.Post(prefix + "/orgs/:orgId/transactions", auth.RequireAuth(PostTransaction)), - rest.Put(prefix + "/orgs/:orgId/transactions/:transactionId", auth.RequireAuth(PutTransaction)), - rest.Delete(prefix + "/orgs/:orgId/transactions/:transactionId", auth.RequireAuth(DeleteTransaction)), - rest.Get(prefix + "/orgs/:orgId/prices", auth.RequireAuth(GetPrices)), - rest.Post(prefix + "/orgs/:orgId/prices", auth.RequireAuth(PostPrice)), - rest.Delete(prefix + "/orgs/:orgId/prices/:priceId", auth.RequireAuth(DeletePrice)), + rest.Get(prefix+"/user", auth.RequireAuth(GetUser)), + rest.Put(prefix+"/user", PutUser), + rest.Post(prefix+"/user/verify", VerifyUser), + rest.Post(prefix+"/user/reset-password", ResetPassword), + rest.Post(prefix+"/users", PostUser), + rest.Post(prefix+"/orgs", auth.RequireAuth(PostOrg)), + rest.Get(prefix+"/orgs", auth.RequireAuth(GetOrgs)), + rest.Get(prefix+"/orgs/:orgId", auth.RequireAuth(GetOrg)), + rest.Put(prefix+"/orgs/:orgId", auth.RequireAuth(PutOrg)), + rest.Get(prefix+"/orgs/:orgId/ledgers", auth.RequireAuth(GetOrgAccounts)), + rest.Post(prefix+"/orgs/:orgId/ledgers", auth.RequireAuth(PostAccount)), + rest.Put(prefix+"/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(PutAccount)), + rest.Delete(prefix+"/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(DeleteAccount)), + rest.Get(prefix+"/orgs/:orgId/ledgers/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)), + rest.Get(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(GetOrgAccounts)), + rest.Post(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(PostAccount)), + rest.Put(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(PutAccount)), + rest.Delete(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(DeleteAccount)), + rest.Get(prefix+"/orgs/:orgId/accounts/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)), + rest.Get(prefix+"/orgs/:orgId/transactions", auth.RequireAuth(GetTransactionsByOrg)), + rest.Post(prefix+"/orgs/:orgId/transactions", auth.RequireAuth(PostTransaction)), + rest.Put(prefix+"/orgs/:orgId/transactions/:transactionId", auth.RequireAuth(PutTransaction)), + rest.Delete(prefix+"/orgs/:orgId/transactions/:transactionId", auth.RequireAuth(DeleteTransaction)), + rest.Get(prefix+"/orgs/:orgId/prices", auth.RequireAuth(GetPrices)), + rest.Post(prefix+"/orgs/:orgId/prices", auth.RequireAuth(PostPrice)), + rest.Delete(prefix+"/orgs/:orgId/prices/:priceId", auth.RequireAuth(DeletePrice)), rest.Get("/ws", ws.Handler), - rest.Post(prefix + "/sessions", auth.RequireAuth(PostSession)), - rest.Delete(prefix + "/sessions/:sessionId", auth.RequireAuth(DeleteSession)), - rest.Get(prefix + "/apikeys", auth.RequireAuth(GetApiKeys)), - rest.Post(prefix + "/apikeys", auth.RequireAuth(PostApiKey)), - rest.Put(prefix + "/apikeys/:apiKeyId", auth.RequireAuth(PutApiKey)), - rest.Delete(prefix + "/apikeys/:apiKeyId", auth.RequireAuth(DeleteApiKey)), - rest.Get(prefix + "/orgs/:orgId/invites", auth.RequireAuth(GetInvites)), - rest.Post(prefix + "/orgs/:orgId/invites", auth.RequireAuth(PostInvite)), - rest.Put(prefix + "/orgs/:orgId/invites/:inviteId", auth.RequireAuth(PutInvite)), - rest.Delete(prefix + "/orgs/:orgId/invites/:inviteId", auth.RequireAuth(DeleteInvite)), + rest.Post(prefix+"/sessions", auth.RequireAuth(PostSession)), + rest.Delete(prefix+"/sessions/:sessionId", auth.RequireAuth(DeleteSession)), + rest.Get(prefix+"/apikeys", auth.RequireAuth(GetApiKeys)), + rest.Post(prefix+"/apikeys", auth.RequireAuth(PostApiKey)), + rest.Put(prefix+"/apikeys/:apiKeyId", auth.RequireAuth(PutApiKey)), + rest.Delete(prefix+"/apikeys/:apiKeyId", auth.RequireAuth(DeleteApiKey)), + rest.Get(prefix+"/orgs/:orgId/invites", auth.RequireAuth(GetInvites)), + rest.Post(prefix+"/orgs/:orgId/invites", auth.RequireAuth(PostInvite)), + rest.Put(prefix+"/orgs/:orgId/invites/:inviteId", auth.RequireAuth(PutInvite)), + rest.Delete(prefix+"/orgs/:orgId/invites/:inviteId", auth.RequireAuth(DeleteInvite)), + rest.Get(prefix+"/health-check", GetSystemHealthStatus), ) } diff --git a/core/api/session.go b/core/api/session.go index 10ac1a5..fe87413 100644 --- a/core/api/session.go +++ b/core/api/session.go @@ -9,11 +9,11 @@ import ( /** * @api {post} /sessions Create a new Session - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostSession * @apiGroup Session * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * @apiHeader {String} Authorization HTTP Basic Auth * * @apiParam {String} id 32 character hex string @@ -59,12 +59,12 @@ func PostSession(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /sessions/:sessionId Log out of a Session - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeleteSession * @apiGroup Session * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/syshealth.go b/core/api/syshealth.go new file mode 100644 index 0000000..c31cc23 --- /dev/null +++ b/core/api/syshealth.go @@ -0,0 +1,38 @@ +package api + +import ( + "github.com/ant0ine/go-json-rest/rest" + "github.com/openaccounting/oa-server/core/model" +) + +/** + * @api {get} /health-check Get system health status + * @apiVersion 1.1.0 + * @apiName GetSystemHealthStatus + * @apiGroup SystemHealth + * + * + * @apiHeader {String} Accept-Version: 1.1.0 semver versioning + * + * @apiSuccess {String} database Database status: "ok"; "fail" + * @apiSuccess {String} api API status: "ok" + * + * @apiSuccessExample Success-Response: + * HTTP/1.1 200 OK + * { + * "database": "ok", + * "api": "ok", + * } + * + * @apiUse InternalServerError + */ +func GetSystemHealthStatus(w rest.ResponseWriter, r *rest.Request) { + status := map[string]string{ + "database": "ok", + "api": "ok", + } + if err := model.Instance.PingDatabase(); err != nil { + status["database"] = "fail" + } + w.WriteJson(status) +} diff --git a/core/api/transaction.go b/core/api/transaction.go index 1317538..6a6dd56 100644 --- a/core/api/transaction.go +++ b/core/api/transaction.go @@ -9,12 +9,12 @@ import ( /** * @api {get} /orgs/:orgId/accounts/:accountId/transactions Get Transactions by Account Id - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetAccountTransactions * @apiGroup Transaction * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Transaction. * @apiSuccess {String} orgId Id of the Org. @@ -85,12 +85,12 @@ func GetTransactionsByAccount(w rest.ResponseWriter, r *rest.Request) { /** * @api {get} /orgs/:orgId/transactions Get Transactions by Org Id - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetOrgTransactions * @apiGroup Transaction * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the Transaction. * @apiSuccess {String} orgId Id of the Org. @@ -160,12 +160,12 @@ func GetTransactionsByOrg(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /orgs/:orgId/transactions Create a new Transaction - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostTransaction * @apiGroup Transaction * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id Id 32 character hex string * @apiParam {Date} date Date of the Transaction @@ -246,12 +246,12 @@ func PostTransaction(w rest.ResponseWriter, r *rest.Request) { /** * @api {put} /orgs/:orgId/transactions/:transactionId Modify a Transaction - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutTransaction * @apiGroup Transaction * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id 32 character hex string * @apiParam {Date} date Date of the Transaction @@ -333,12 +333,12 @@ func PutTransaction(w rest.ResponseWriter, r *rest.Request) { /** * @api {delete} /orgs/:orgId/transactions/:transactionId Delete a Transaction - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName DeleteTransaction * @apiGroup Transaction * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK diff --git a/core/api/user.go b/core/api/user.go index 4366c1f..a9380a8 100644 --- a/core/api/user.go +++ b/core/api/user.go @@ -22,12 +22,12 @@ type ResetPasswordParams struct { /** * @api {get} /user Get Authenticated User - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName GetUser * @apiGroup User * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiSuccess {String} id Id of the User. * @apiSuccess {Date} inserted Date User was created @@ -64,11 +64,11 @@ func GetUser(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /users Create a new User - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PostUser * @apiGroup User * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} id 32 character hex string * @apiParam {String} firstName First name of the User. @@ -123,12 +123,12 @@ func PostUser(w rest.ResponseWriter, r *rest.Request) { /** * @api {put} /user Modify User - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName PutUser * @apiGroup User * * @apiHeader {String} Authorization HTTP Basic Auth - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} password New password * @apiParam {String} code Password reset code. (Instead of Authorization header) @@ -204,11 +204,11 @@ func PutUser(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /user/verify Verify user email address - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName VerifyUser * @apiGroup User * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} code Email verification code * @@ -238,11 +238,11 @@ func VerifyUser(w rest.ResponseWriter, r *rest.Request) { /** * @api {post} /user/reset-password Send reset password email - * @apiVersion 1.0.1 + * @apiVersion 1.1.0 * @apiName ResetPassword * @apiGroup User * - * @apiHeader {String} Accept-Version ^1.0.1 semver versioning + * @apiHeader {String} Accept-Version ^1.1.0 semver versioning * * @apiParam {String} email Email address for user * diff --git a/core/api/version.go b/core/api/version.go index d45bbdd..2af8f33 100644 --- a/core/api/version.go +++ b/core/api/version.go @@ -31,7 +31,7 @@ func (mw *VersionMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.Handl rest.Error(writer, "Invalid version", http.StatusBadRequest) } - serverVersion, _ := semver.NewVersion("1.0.1") + serverVersion, _ := semver.NewVersion("1.1.0") // Pre-release versions compatVersion, _ := semver.NewVersion("0.1.8") diff --git a/core/model/db/db.go b/core/model/db/db.go index 73e8b77..168a413 100644 --- a/core/model/db/db.go +++ b/core/model/db/db.go @@ -18,6 +18,7 @@ type Datastore interface { PriceInterface SessionInterface ApiKeyInterface + SystemHealthInteface } func NewDB(dataSourceName string) (*DB, error) { diff --git a/core/model/db/syshealth.go b/core/model/db/syshealth.go new file mode 100644 index 0000000..3a40bd0 --- /dev/null +++ b/core/model/db/syshealth.go @@ -0,0 +1,5 @@ +package db + +type SystemHealthInteface interface { + Ping() error +} diff --git a/core/model/model.go b/core/model/model.go index 47629ba..b84ddbf 100644 --- a/core/model/model.go +++ b/core/model/model.go @@ -22,6 +22,7 @@ type Interface interface { PriceInterface SessionInterface ApiKeyInterface + SystemHealthInteface } func NewModel(db db.Datastore, bcrypt util.Bcrypt, config types.Config) *Model { diff --git a/core/model/syshealth.go b/core/model/syshealth.go new file mode 100644 index 0000000..2b6de73 --- /dev/null +++ b/core/model/syshealth.go @@ -0,0 +1,9 @@ +package model + +type SystemHealthInteface interface { + PingDatabase() error +} + +func (model *Model) PingDatabase() error { + return model.db.Ping() +} diff --git a/core/ws/ws.go b/core/ws/ws.go index 7e7201d..b8b21c7 100644 --- a/core/ws/ws.go +++ b/core/ws/ws.go @@ -14,7 +14,7 @@ import ( "sync" ) -const version = "1.0.1" +const version = "1.1.0" //var upgrader = websocket.Upgrader{} // use default options var txSubscriptions = make(map[string][]*websocket.Conn) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..86d82a8 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module github.com/openaccounting/oa-server + +require ( + github.com/Masterminds/semver v0.0.0-20180807142431-c84ddcca87bf + github.com/ant0ine/go-json-rest v0.0.0-20170913041208-ebb33769ae01 + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-sql-driver/mysql v1.4.1 + github.com/gorilla/websocket v0.0.0-20180605202552-5ed622c449da + github.com/mitchellh/mapstructure v0.0.0-20180511142126-bb74f1db0675 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sendgrid/rest v0.0.0-20180905234047-875828e14d98 // indirect + github.com/sendgrid/sendgrid-go v0.0.0-20180905233524-8cb43f4ca4f5 + github.com/stretchr/objx v0.1.1 // indirect + github.com/stretchr/testify v1.2.2 + golang.org/x/crypto v0.0.0-20171231215028-0fcca4842a8d + google.golang.org/appengine v1.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..be1903b --- /dev/null +++ b/go.sum @@ -0,0 +1,29 @@ +github.com/Masterminds/semver v0.0.0-20180807142431-c84ddcca87bf h1:BMUJnVJI5J506LOcyGHEvbCocMHAmKTRcG6CMAwGFYU= +github.com/Masterminds/semver v0.0.0-20180807142431-c84ddcca87bf/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/ant0ine/go-json-rest v0.0.0-20170913041208-ebb33769ae01 h1:oYAjCHMjyRaNBo3nUEepDce4LC+Kuh+6jU6y+AllvnU= +github.com/ant0ine/go-json-rest v0.0.0-20170913041208-ebb33769ae01/go.mod h1:q6aCt0GfU6LhpBsnZ/2U+mwe+0XB5WStbmwyoPfc+sk= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/gorilla/websocket v0.0.0-20180605202552-5ed622c449da h1:b5fma7aUP2fn6+tdKKCJ0TxXYzY/5wDiqUxNdyi5VF4= +github.com/gorilla/websocket v0.0.0-20180605202552-5ed622c449da/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/mitchellh/mapstructure v0.0.0-20180511142126-bb74f1db0675 h1:/rdJjIiKG5rRdwG5yxHmSE/7ZREjpyC0kL7GxGT/qJw= +github.com/mitchellh/mapstructure v0.0.0-20180511142126-bb74f1db0675/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sendgrid/rest v0.0.0-20180905234047-875828e14d98 h1:wpBZ5DAYLNl+2v4E4WP8k/y8tM5OjIf1FezJS1qX8sU= +github.com/sendgrid/rest v0.0.0-20180905234047-875828e14d98/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE= +github.com/sendgrid/sendgrid-go v0.0.0-20180905233524-8cb43f4ca4f5 h1:V18LU+jSbihmDiWfLSzs9FV1d3KVB1gRTkNxgVHmcvg= +github.com/sendgrid/sendgrid-go v0.0.0-20180905233524-8cb43f4ca4f5/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/crypto v0.0.0-20171231215028-0fcca4842a8d h1:GrqEEc3+MtHKTsZrdIGVoYDgLpbSRzW1EF+nLu0PcHE= +golang.org/x/crypto v0.0.0-20171231215028-0fcca4842a8d/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=