@@ -113,134 +113,185 @@ Below are the available endpoints for each table.
113
113
114
114
---
115
115
116
- ## Rate Limits Endpoints
116
+ ## Github Validation Endpoints
117
+
118
+ ### ** Validate Github User ID**
119
+
120
+ ** GET** ` /api/github-validation/:userId `
121
+
122
+ - ** Description** : Validates a Github user by fetching their information from the Github API using their user ID.
123
+ - ** Request Params** :
124
+ - ` userId ` (string): The Github User ID to validate.
125
+
126
+ - ** Curl Command** :
127
+ ``` bash
128
+ curl -v http://localhost:3000/api/gh-validation/exampleUser
129
+ ```
130
+ -** Response** :
131
+ ``` json
132
+ {
133
+ "valid" : " boolean"
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Transactions Endpoints
117
140
118
- ### ** Create a New Rate Limit **
141
+ ### ** Create a New Transaction **
119
142
120
- ** POST** ` /api/rate-limits `
143
+ ** POST** ` /api/transactions `
121
144
122
- - ** Description** : Adds a new rate limit entry.
145
+ - ** Description** : Creates a new transaction entry with a unique signature .
123
146
- ** Request Body** :
124
147
``` json
125
148
{
126
- "key" : " string" ,
127
- "timestamps" : [" number" ]
149
+ "signature" : " string" ,
150
+ "ip_address" : " string" ,
151
+ "wallet_address" : " string" ,
152
+ "github_id" : " string (optional)" ,
153
+ "timestamp" : " number"
128
154
}
129
155
```
130
156
- ** Curl Command** :
131
157
``` bash
132
- curl -v -X POST http://localhost:3000/api/rate-limits \
133
- -H " Content-Type: application/json" \
134
- -d ' {"key": "test_key_1", "timestamps": [1635793421]}'
158
+ curl -v -X POST http://localhost:3000/api/transactions \
159
+ -H " Content-Type: application/json" \
160
+ -d ' {
161
+ "signature": "tx_123",
162
+ "ip_address": "192.168.0.1",
163
+ "wallet_address": "wallet_abc",
164
+ "github_id": "user123",
165
+ "timestamp": 1714752000
166
+ }'
135
167
```
136
168
- ** Response** :
137
169
``` json
138
170
{
139
- "key" : " string" ,
140
- "timestamps" : [" number" ]
171
+ "signature" : " tx_123" ,
172
+ "ip_address" : " 192.168.0.1" ,
173
+ "wallet_address" : " wallet_abc" ,
174
+ "github_id" : " user123" ,
175
+ "timestamp" : 1714752000
141
176
}
142
177
```
143
178
144
- ### ** Get a Rate Limit by Key**
179
+ ---
180
+
181
+ ### ** Get the Most Recent Transaction(s)**
182
+
183
+ ** GET** ` /api/transactions/last `
145
184
146
- ** GET** ` /api/rate-limits/:key `
185
+ - ** Description** : Retrieves the most recent transaction(s) matching the given query parameters. You must provide at least one of ` wallet_address ` or ` ip_address ` .
186
+ - ** Query Params** :
187
+ - ` wallet_address ` (string, optional)
188
+ - ` github_id ` (string, optional)
189
+ - ` ip_address ` (string, optional)
190
+ - ` count ` (number, optional – number of results to return; defaults to 1)
147
191
148
- - ** Description** : Retrieves the rate limit entry for a specific key.
149
192
- ** Curl Command** :
150
193
``` bash
151
- curl -v http://localhost:3000/api/rate-limits/test_key_1
194
+ curl -v " http://localhost:3000/api/transactions/last?wallet_address=wallet_abc&count=2 "
152
195
```
153
- - ** Response** :
196
+ - ** Response** (if found):
197
+ ``` json
198
+ [
199
+ {
200
+ "signature" : " tx_123" ,
201
+ "ip_address" : " 192.168.0.1" ,
202
+ "wallet_address" : " wallet_abc" ,
203
+ "github_id" : " user123" ,
204
+ "timestamp" : 1714752000
205
+ }
206
+ ]
207
+ ```
208
+
209
+ - ** Response** (if not found):
154
210
``` json
155
211
{
156
- "key" : " string" ,
157
- "timestamps" : [" number" ]
212
+ "message" : " No transaction found for the given criteria."
158
213
}
159
214
```
160
215
161
- ### ** Update Timestamps for a Rate Limit **
216
+ ---
162
217
163
- ** PUT ** ` /api/rate-limits/:key `
218
+ ### ** Delete a Transaction by Signature **
164
219
165
- - ** Description** : Updates the timestamps for a specific rate limit key.
166
- - ** Request Body** :
220
+ ** DELETE** ` /api/transactions/:signature `
221
+
222
+ - ** Description** : Deletes a transaction based on its signature.
223
+ - ** Curl Command** :
224
+ ``` bash
225
+ curl -v -X DELETE http://localhost:3000/api/transactions/tx_123
226
+ ```
227
+ - ** Response** (if deleted):
167
228
``` json
168
229
{
169
- "timestamps" : [" number" ]
230
+ "signature" : " tx_123" ,
231
+ "ip_address" : " 192.168.0.1" ,
232
+ "wallet_address" : " wallet_abc" ,
233
+ "github_id" : " user123" ,
234
+ "timestamp" : 1714752000
170
235
}
171
236
```
172
- - ** Curl Command** :
173
- ``` bash
174
- curl -v -X PUT http://localhost:3000/api/rate-limits/test_key_1 \
175
- -H " Content-Type: application/json" \
176
- -d ' {"timestamps": [1635793500]}'
177
- ```
178
- - ** Response** :
237
+
238
+ - ** Response** (if not found):
179
239
``` json
180
240
{
181
- "key" : " string" ,
182
- "timestamps" : [" number" ]
241
+ "message" : " Transaction not found"
183
242
}
184
243
```
185
244
186
- ### ** Create a New Rate Limit Combination**
245
+ ---
246
+
247
+ ### ** Validate User Information**
248
+
249
+ ** POST** ` /api/validate `
250
+
251
+ - ** Description** : Validates a GitHub account and checks the transaction history for the given IP address, wallet address, and GitHub ID.
187
252
188
- ** POST** ` /api/rate-limits-combo `
253
+ #### Validation Criteria:
254
+ - ** GitHub Account**
255
+ - Must be at least 30 days old
256
+ - Must have at least 1 public repository
257
+ - Must be of type ` User `
258
+
259
+ - ** Transaction Limits**
260
+ - Max 200 transactions per IP address (all-time)
261
+ - Max 100 transactions per wallet address (all-time)
262
+ - Max 100 transactions per GitHub ID (all-time)
263
+ - Max 50 transactions for the combination of all three within the last 30 days
189
264
190
- - ** Description** : Adds a new rate limit combination entry. Each combination of ` ip_address ` , ` wallet_address ` ,
191
- and ` github_userid ` is checked for uniqueness before inserting to DB.
192
265
- ** Request Body** :
193
266
``` json
194
267
{
195
268
"ip_address" : " string" ,
196
269
"wallet_address" : " string" ,
197
- "github_userid " : " string"
270
+ "github_id " : " string"
198
271
}
199
272
```
273
+
200
274
- ** Curl Command** :
201
275
``` bash
202
- curl -v -X POST http://localhost:3000/api/rate-limits-combo \
203
- -H " Content-Type: application/json" \
204
- -d ' {
205
- "ip_address": "19216801",
206
- "wallet_address": "wallet_123",
207
- "github_userid": "user123"
208
- }'
276
+ curl -v -X POST http://localhost:3000/api/validate -H " Content-Type: application/json" -d ' {"ip_address": "1234567", "wallet_address": "some_address", "github_id": "54321"}'
209
277
```
210
- - ** Response** :
211
- ``` json
278
+
279
+ - ** Response (Valid)** :
280
+ ``` json
212
281
{
213
- "id" : " 3" ,
214
- "ip_address" :" 19216801" ,
215
- "wallet_address" :" wallet_123" ,
216
- "github_userid" :" user123"
282
+ "valid" : true ,
283
+ "reason" : " "
217
284
}
218
285
```
219
286
220
- ---
221
-
222
- ## Github Validation Endpoints
223
-
224
- ### ** Validate Github User ID**
225
-
226
- ** GET** ` /api/github-validation/:userId `
227
-
228
- - ** Description** : Validates a Github user by fetching their information from the Github API using their user ID.
229
- - ** Request Params** :
230
- - ` userId ` (string): The Github User ID to validate.
231
-
232
- - ** Curl Command** :
233
- ``` bash
234
- curl -v http://localhost:3000/api/gh-validation/exampleUser
287
+ - ** Response (Invalid)** :
288
+ ``` json
289
+ {
290
+ "valid" : false ,
291
+ "reason" : " Transaction history is invalid"
292
+ }
235
293
```
236
- -** Response** :
237
- ``` json
238
- {
239
- "valid" : " boolean"
240
- }
241
- ```
242
294
243
- ---
244
295
245
296
## Error Handling
246
297
0 commit comments