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
Show 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 (
...
@@ -9,18 +9,19 @@ import (
"github.com/go-chi/chi"
"github.com/go-chi/chi"
)
)
// Database interface for deposits
// TODO in this pr most of these types should be coming from the ORM instead
type
DepositDB
interface
{
// DepositsDAO represents the Database Access Object for deposits
type
DepositDAO
interface
{
GetDeposits
(
limit
int
,
cursor
string
,
sortDirection
string
)
([]
Deposit
,
string
,
bool
,
error
)
GetDeposits
(
limit
int
,
cursor
string
,
sortDirection
string
)
([]
Deposit
,
string
,
bool
,
error
)
}
}
//
Database interface for withdrawal
s
//
WithdrawalDAO represents the Database Access Object for deposit
s
type
WithdrawalD
B
interface
{
type
WithdrawalD
AO
interface
{
GetWithdrawals
(
limit
int
,
cursor
string
,
sortDirection
string
,
sortBy
string
)
([]
Withdrawal
,
string
,
bool
,
error
)
GetWithdrawals
(
limit
int
,
cursor
string
,
sortDirection
string
,
sortBy
string
)
([]
Withdrawal
,
string
,
bool
,
error
)
}
}
// Deposit data structure
// Deposit data structure
// TODO this should be coming from the ORM instead
type
Deposit
struct
{
type
Deposit
struct
{
Guid
string
`json:"guid"`
Guid
string
`json:"guid"`
Amount
string
`json:"amount"`
Amount
string
`json:"amount"`
...
@@ -34,7 +35,6 @@ type Deposit struct {
...
@@ -34,7 +35,6 @@ type Deposit struct {
}
}
// Withdrawal data structure
// Withdrawal data structure
// TODO this should be coming from teh ORM instead
type
Withdrawal
struct
{
type
Withdrawal
struct
{
Guid
string
`json:"guid"`
Guid
string
`json:"guid"`
Amount
string
`json:"amount"`
Amount
string
`json:"amount"`
...
@@ -88,7 +88,7 @@ func (a *Api) DepositsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -88,7 +88,7 @@ func (a *Api) DepositsHandler(w http.ResponseWriter, r *http.Request) {
cursor
:=
r
.
URL
.
Query
()
.
Get
(
"cursor"
)
cursor
:=
r
.
URL
.
Query
()
.
Get
(
"cursor"
)
sortDirection
:=
r
.
URL
.
Query
()
.
Get
(
"sortDirection"
)
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
{
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
return
...
@@ -109,7 +109,7 @@ func (a *Api) WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -109,7 +109,7 @@ func (a *Api) WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
sortDirection
:=
r
.
URL
.
Query
()
.
Get
(
"sortDirection"
)
sortDirection
:=
r
.
URL
.
Query
()
.
Get
(
"sortDirection"
)
sortBy
:=
r
.
URL
.
Query
()
.
Get
(
"sortBy"
)
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
{
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
return
...
@@ -144,17 +144,17 @@ func jsonResponse(w http.ResponseWriter, data interface{}, statusCode int) {
...
@@ -144,17 +144,17 @@ func jsonResponse(w http.ResponseWriter, data interface{}, statusCode int) {
type
Api
struct
{
type
Api
struct
{
Router
*
chi
.
Mux
Router
*
chi
.
Mux
DepositD
B
DepositDB
DepositD
AO
DepositDAO
WithdrawalD
B
WithdrawalDB
WithdrawalD
AO
WithdrawalDAO
}
}
func
NewApi
(
depositD
B
DepositDB
,
withdrawalDB
WithdrawalDB
)
*
Api
{
func
NewApi
(
depositD
AO
DepositDAO
,
withdrawalDAO
WithdrawalDAO
)
*
Api
{
r
:=
chi
.
NewRouter
()
r
:=
chi
.
NewRouter
()
api
:=
&
Api
{
api
:=
&
Api
{
Router
:
r
,
Router
:
r
,
DepositD
B
:
depositDB
,
DepositD
AO
:
depositDAO
,
WithdrawalD
B
:
withdrawalDB
,
WithdrawalD
AO
:
withdrawalDAO
,
}
}
r
.
Get
(
"/api/v0/deposits"
,
api
.
DepositsHandler
)
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