Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
fd0a77f7
Commit
fd0a77f7
authored
May 31, 2023
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: Rename DB Dao
parent
6c62f3f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
api.go
indexer/api/api.go
+15
-15
No files found.
indexer/api/api.go
View file @
fd0a77f7
...
...
@@ -9,18 +9,19 @@ import (
"github.com/go-chi/chi"
)
// Database interface for deposits
type
DepositDB
interface
{
// TODO in this pr most of these types should be coming from the ORM instead
// DepositsDAO represents the Database Access Object for deposits
type
DepositDAO
interface
{
GetDeposits
(
limit
int
,
cursor
string
,
sortDirection
string
)
([]
Deposit
,
string
,
bool
,
error
)
}
//
Database interface for withdrawal
s
type
WithdrawalD
B
interface
{
//
WithdrawalDAO represents the Database Access Object for deposit
s
type
WithdrawalD
AO
interface
{
GetWithdrawals
(
limit
int
,
cursor
string
,
sortDirection
string
,
sortBy
string
)
([]
Withdrawal
,
string
,
bool
,
error
)
}
// Deposit data structure
// TODO this should be coming from the ORM instead
type
Deposit
struct
{
Guid
string
`json:"guid"`
Amount
string
`json:"amount"`
...
...
@@ -34,7 +35,6 @@ type Deposit struct {
}
// Withdrawal data structure
// TODO this should be coming from teh ORM instead
type
Withdrawal
struct
{
Guid
string
`json:"guid"`
Amount
string
`json:"amount"`
...
...
@@ -88,7 +88,7 @@ func (a *Api) DepositsHandler(w http.ResponseWriter, r *http.Request) {
cursor
:=
r
.
URL
.
Query
()
.
Get
(
"cursor"
)
sortDirection
:=
r
.
URL
.
Query
()
.
Get
(
"sortDirection"
)
deposits
,
nextCursor
,
hasNextPage
,
err
:=
a
.
DepositD
B
.
GetDeposits
(
limit
,
cursor
,
sortDirection
)
deposits
,
nextCursor
,
hasNextPage
,
err
:=
a
.
DepositD
AO
.
GetDeposits
(
limit
,
cursor
,
sortDirection
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
...
...
@@ -109,7 +109,7 @@ func (a *Api) WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
sortDirection
:=
r
.
URL
.
Query
()
.
Get
(
"sortDirection"
)
sortBy
:=
r
.
URL
.
Query
()
.
Get
(
"sortBy"
)
withdrawals
,
nextCursor
,
hasNextPage
,
err
:=
a
.
WithdrawalD
B
.
GetWithdrawals
(
limit
,
cursor
,
sortDirection
,
sortBy
)
withdrawals
,
nextCursor
,
hasNextPage
,
err
:=
a
.
WithdrawalD
AO
.
GetWithdrawals
(
limit
,
cursor
,
sortDirection
,
sortBy
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
...
...
@@ -143,18 +143,18 @@ func jsonResponse(w http.ResponseWriter, data interface{}, statusCode int) {
}
type
Api
struct
{
Router
*
chi
.
Mux
DepositD
B
DepositDB
WithdrawalD
B
WithdrawalDB
Router
*
chi
.
Mux
DepositD
AO
DepositDAO
WithdrawalD
AO
WithdrawalDAO
}
func
NewApi
(
depositD
B
DepositDB
,
withdrawalDB
WithdrawalDB
)
*
Api
{
func
NewApi
(
depositD
AO
DepositDAO
,
withdrawalDAO
WithdrawalDAO
)
*
Api
{
r
:=
chi
.
NewRouter
()
api
:=
&
Api
{
Router
:
r
,
DepositD
B
:
depositDB
,
WithdrawalD
B
:
withdrawalDB
,
Router
:
r
,
DepositD
AO
:
depositDAO
,
WithdrawalD
AO
:
withdrawalDAO
,
}
r
.
Get
(
"/api/v0/deposits"
,
api
.
DepositsHandler
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment