Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 9f3302f

Browse files
author
hicetnunc2000
committed
latest
1 parent e0b43c4 commit 9f3302f

File tree

7 files changed

+86
-28
lines changed

7 files changed

+86
-28
lines changed

.env

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
REACT_APP_FEED='http://localhost:3001/feed'
2-
REACT_APP_TZ='http://localhost:3001/tz'
3-
REACT_APP_OBJKT='http://localhost:3001/objkt'
1+
TIMESTAMP=''
2+
BUFFER=''

.serverless/cloudformation-template-update-stack.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"S3Bucket": {
147147
"Ref": "ServerlessDeploymentBucket"
148148
},
149-
"S3Key": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z/hicetnunc-apiv2.zip"
149+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z/hicetnunc-apiv2.zip"
150150
},
151151
"FunctionName": "hicetnunc-apiv2-dev-handler",
152152
"Handler": "index.handler",
@@ -164,14 +164,14 @@
164164
"HandlerLogGroup"
165165
]
166166
},
167-
"HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E": {
167+
"HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA": {
168168
"Type": "AWS::Lambda::Version",
169169
"DeletionPolicy": "Retain",
170170
"Properties": {
171171
"FunctionName": {
172172
"Ref": "HandlerLambdaFunction"
173173
},
174-
"CodeSha256": "A5PEtCLwbB+fMx1VYq50HcNNaaGwfrVhq2LCEwgYZbk="
174+
"CodeSha256": "XzPgs+74v32jD1VtT3EQIuiguzI/+h1FI5G32MCoFNc="
175175
}
176176
},
177177
"ApiGatewayRestApi": {
@@ -383,7 +383,7 @@
383383
"MethodResponses": []
384384
}
385385
},
386-
"ApiGatewayDeployment1615880658144": {
386+
"ApiGatewayDeployment1616044838303": {
387387
"Type": "AWS::ApiGateway::Deployment",
388388
"Properties": {
389389
"RestApiId": {
@@ -445,7 +445,7 @@
445445
"HandlerLambdaFunctionQualifiedArn": {
446446
"Description": "Current Lambda function version",
447447
"Value": {
448-
"Ref": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
448+
"Ref": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
449449
}
450450
},
451451
"ServiceEndpoint": {

.serverless/hicetnunc-apiv2.zip

30.7 KB
Binary file not shown.

.serverless/serverless-state.json

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"S3Bucket": {
160160
"Ref": "ServerlessDeploymentBucket"
161161
},
162-
"S3Key": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z/hicetnunc-apiv2.zip"
162+
"S3Key": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z/hicetnunc-apiv2.zip"
163163
},
164164
"FunctionName": "hicetnunc-apiv2-dev-handler",
165165
"Handler": "index.handler",
@@ -177,14 +177,14 @@
177177
"HandlerLogGroup"
178178
]
179179
},
180-
"HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E": {
180+
"HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA": {
181181
"Type": "AWS::Lambda::Version",
182182
"DeletionPolicy": "Retain",
183183
"Properties": {
184184
"FunctionName": {
185185
"Ref": "HandlerLambdaFunction"
186186
},
187-
"CodeSha256": "A5PEtCLwbB+fMx1VYq50HcNNaaGwfrVhq2LCEwgYZbk="
187+
"CodeSha256": "XzPgs+74v32jD1VtT3EQIuiguzI/+h1FI5G32MCoFNc="
188188
}
189189
},
190190
"ApiGatewayRestApi": {
@@ -396,7 +396,7 @@
396396
"MethodResponses": []
397397
}
398398
},
399-
"ApiGatewayDeployment1615880658144": {
399+
"ApiGatewayDeployment1616044838303": {
400400
"Type": "AWS::ApiGateway::Deployment",
401401
"Properties": {
402402
"RestApiId": {
@@ -458,7 +458,7 @@
458458
"HandlerLambdaFunctionQualifiedArn": {
459459
"Description": "Current Lambda function version",
460460
"Value": {
461-
"Ref": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
461+
"Ref": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
462462
}
463463
},
464464
"ServiceEndpoint": {
@@ -616,7 +616,7 @@
616616
"memory": 1024,
617617
"runtime": "nodejs12.x",
618618
"vpc": {},
619-
"versionLogicalId": "HandlerLambdaVersion9JxeJVymMLadKim0CA2xts3Sq7MjDv9hgb8Kjy21D9E"
619+
"versionLogicalId": "HandlerLambdaVersionBQ36OgfBcIfPgSb706UIr9lOrJOtZ0Z0CUitLzdpqA"
620620
}
621621
},
622622
"configValidationMode": "warn",
@@ -1010,6 +1010,45 @@
10101010
"node_modules/big-integer/package.json",
10111011
"node_modules/big-integer/README.md",
10121012
"node_modules/big-integer/tsconfig.json",
1013+
"node_modules/dotenv/CHANGELOG.md",
1014+
"node_modules/dotenv/config.js",
1015+
"node_modules/dotenv/lib/cli-options.js",
1016+
"node_modules/dotenv/lib/env-options.js",
1017+
"node_modules/dotenv/lib/main.js",
1018+
"node_modules/dotenv/LICENSE",
1019+
"node_modules/dotenv/package.json",
1020+
"node_modules/dotenv/README.md",
1021+
"node_modules/dotenv/types/index.d.ts",
1022+
"node_modules/dotenv/types/test.ts",
1023+
"node_modules/dotenv/types/tsconfig.json",
1024+
"node_modules/dotenv/types/tslint.json",
1025+
"node_modules/cloud-local-storage/lib/commands/create.d.ts",
1026+
"node_modules/cloud-local-storage/lib/commands/create.js",
1027+
"node_modules/cloud-local-storage/lib/commands/get-all-keys.d.ts",
1028+
"node_modules/cloud-local-storage/lib/commands/get-all-keys.js",
1029+
"node_modules/cloud-local-storage/lib/commands/get-item.d.ts",
1030+
"node_modules/cloud-local-storage/lib/commands/get-item.js",
1031+
"node_modules/cloud-local-storage/lib/commands/init.d.ts",
1032+
"node_modules/cloud-local-storage/lib/commands/init.js",
1033+
"node_modules/cloud-local-storage/lib/commands/list.d.ts",
1034+
"node_modules/cloud-local-storage/lib/commands/list.js",
1035+
"node_modules/cloud-local-storage/lib/commands/reset-password.d.ts",
1036+
"node_modules/cloud-local-storage/lib/commands/reset-password.js",
1037+
"node_modules/cloud-local-storage/lib/commands/set-item.d.ts",
1038+
"node_modules/cloud-local-storage/lib/commands/set-item.js",
1039+
"node_modules/cloud-local-storage/lib/index.d.ts",
1040+
"node_modules/cloud-local-storage/lib/index.js",
1041+
"node_modules/cloud-local-storage/lib/utils/consts.d.ts",
1042+
"node_modules/cloud-local-storage/lib/utils/consts.js",
1043+
"node_modules/cloud-local-storage/package.json",
1044+
"node_modules/cloud-local-storage/readme.md",
1045+
"node_modules/cloud-local-storage/src/commands/create.ts",
1046+
"node_modules/cloud-local-storage/src/commands/get-all-keys.ts",
1047+
"node_modules/cloud-local-storage/src/commands/get-item.ts",
1048+
"node_modules/cloud-local-storage/src/commands/set-item.ts",
1049+
"node_modules/cloud-local-storage/src/index.ts",
1050+
"node_modules/cloud-local-storage/src/utils/consts.ts",
1051+
"node_modules/cloud-local-storage/tsconfig.json",
10131052
"node_modules/lodash/_apply.js",
10141053
"node_modules/lodash/_arrayAggregator.js",
10151054
"node_modules/lodash/_arrayEach.js",
@@ -2507,7 +2546,7 @@
25072546
"node_modules/@types/aws-lambda/trigger/sqs.d.ts"
25082547
],
25092548
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip",
2510-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z"
2549+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z"
25112550
},
25122551
"plugins": {
25132552
"$ref": "$[\"service\"][\"plugins\"]"
@@ -2524,7 +2563,7 @@
25242563
"artifact": "/home/crzy/Desktop/programs/lambdas-aws/api-final/new2/hicetnunc-api/.serverless/hicetnunc-apiv2.zip"
25252564
},
25262565
"package": {
2527-
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1615880662823-2021-03-16T07:44:22.823Z",
2566+
"artifactDirectoryName": "serverless/hicetnunc-apiv2/dev/1616044842570-2021-03-18T05:20:42.570Z",
25282567
"artifact": "hicetnunc-apiv2.zip"
25292568
}
25302569
}

index.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ const axios = require('axios')
33
const express = require('express')
44
const cors = require('cors')
55
const _ = require('lodash')
6-
76
const conseilUtil = require('./conseilUtil')
7+
const cls = require('cloud-local-storage')
8+
require('dotenv').config()
89

910
const reducer = (accumulator, currentValue) => accumulator + currentValue;
1011

@@ -34,10 +35,10 @@ const getTokenHoldersArr = async (arr) => {
3435
return await arr.map(async e => await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data))
3536
/* await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + arr[0]).then(res => console.log(res.data))
3637
*//* var result = arr.map(async e => {
37-
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data)
38-
})
39-
40-
console.log(result) */
38+
return await axios.get('https://api.better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens/holders?token_id=' + e).then(res => res.data)
39+
})
40+
41+
console.log(result) */
4142
}
4243

4344
const owners = async (obj) => {
@@ -128,7 +129,10 @@ const filterTz = (data, tz) => _.filter(data, { tz: tz })
128129
const test = async () => console.log(desc(await getObjkts()))
129130

130131
const getFeed = async (counter, res) => {
132+
133+
131134
var arr = await conseilUtil.getArtisticUniverse(0)
135+
132136
var feed = offset(desc(arr), counter)
133137
console.log(feed)
134138
feed = await feed.map(async e => {
@@ -143,7 +147,7 @@ const getFeed = async (counter, res) => {
143147
promise.then(async (results) => {
144148
var aux_arr = results.map(e => e)
145149

146-
//console.log(aux_arr)
150+
console.log(aux_arr)
147151
res.json({ result: aux_arr })
148152
})
149153
}
@@ -163,16 +167,19 @@ const getTzLedger = async (tz, res) => {
163167
console.log(hdao)
164168

165169
var arr = []
166-
167-
var arr = _.union(collection, creations[0])
170+
console.log([...collection, ...creations])
171+
var arr = [...collection, ...creations]
168172

169173
var result = arr.map(async e => {
170174
e.token_info = await getIpfsHash(e.ipfsHash)
175+
171176
if (e.piece != undefined) {
172177
e.token_id = parseInt(e.piece)
173178
} else {
174179
e.token_id = parseInt(e.objectId)
180+
175181
}
182+
console.log(e)
176183
return e
177184
})
178185

@@ -184,7 +191,7 @@ const getTzLedger = async (tz, res) => {
184191
result: _.uniqBy(result, (e) => {
185192
return e.token_id
186193
}),
187-
hdao : hdao
194+
hdao: hdao
188195
})
189196
})
190197

@@ -258,16 +265,26 @@ app.post('/tz', async (req, res) => {
258265
})
259266

260267
app.post('/objkt', async (req, res) => {
261-
res.json({ result: await getObjktById(req.body.objkt_id) })
268+
var list = await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => res.data)
269+
270+
list.includes(parseInt(req.body.objkt_id))
271+
?
272+
res.json({ result: [] })
273+
:
274+
res.json({ result: await getObjktById(req.body.objkt_id) })
262275
})
263276

264277
app.post('/hdao', async (req, res) => {
265278
await hDAOFeed(parseInt(req.body.counter), res)
266279
})
267280

268281
app.listen(3001)
269-
module.exports.handler = serverless(app)
282+
//module.exports.handler = serverless(app)
270283

284+
/* const test2 = async () => {
285+
await axios.get('https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/o.json').then(res => console.log(res.data))
286+
}
287+
test2() */
271288
//testTkHolder([{'kt' : 2020}, {'kt' : 2021}])
272289
//getFeed(1)
273290
//getObjktById(2000)

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
"homepage": "https://github.com/hicetnunc2000/hicetnunc#readme",
1919
"dependencies": {
2020
"axios": "^0.21.1",
21+
"cloud-local-storage": "0.0.11",
2122
"conseiljs": "5.0.7-2",
2223
"cors": "^2.8.5",
24+
"dotenv": "^8.2.0",
2325
"express": "^4.17.1",
2426
"fetch": "^1.1.0",
2527
"lodash": "^4.17.21",
2628
"loglevel": "1.7.1",
2729
"node-fetch": "2.6.1",
30+
"serverless-dotenv-plugin": "^3.8.1",
2831
"serverless-http": "^2.7.0"
2932
},
3033
"engines": {

serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package:
99

1010
plugins:
1111
- serverless-plugin-include-dependencies
12-
12+
- serverless-dotenv-plugin
1313
provider:
1414
name: aws
1515
runtime: nodejs12.x

0 commit comments

Comments
 (0)