-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from hollow-leaf/feat/arBackend
feat: ar backend
- Loading branch information
Showing
14 changed files
with
12,267 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
wallet.json | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:18.16-alpine3.16 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apk add git | ||
|
||
COPY package.json . | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["npx", "ts-node", "--esm" ,"src/app.ts" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '3.7' | ||
services: | ||
ar_backend: | ||
container_name: ar_backend | ||
image: ar_backend | ||
ports: | ||
- '8080:8080' | ||
restart: always | ||
networks: | ||
- ar_network | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
caddy: | ||
container_name: ar_caddy | ||
image: caddy:latest | ||
restart: unless-stopped | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- ./scripts/caddy_data:/data | ||
- ./scripts/caddy_config:/config | ||
- ./scripts/caddy_config/Caddyfile:/etc/caddy/Caddyfile | ||
networks: | ||
- ar_network | ||
- public_access | ||
|
||
networks: | ||
public_access: | ||
ar_network: | ||
name: ar_network | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "arweave-service", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"start": "ts-node --esm src/service/ar.ts", | ||
"ar:local": "arlocal", | ||
"build": "docker build -f Dockerfile -t arbackend ." | ||
}, | ||
"devDependencies": { | ||
"@types/cors": "^2.8.14", | ||
"@types/express": "^4.17.17", | ||
"arlocal": "^1.1.61", | ||
"dotenv": "^16.3.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"arweavekit": "^1.4.9", | ||
"cors": "^2.8.5", | ||
"ethers": "6.7.1", | ||
"express": "^4.18.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import express from 'express' | ||
import cors from 'cors' | ||
import { upload, list } from './service/ar.js' | ||
import fs from 'fs' | ||
|
||
const app = express() | ||
|
||
app.use(cors()) | ||
app.use(express.json()) | ||
app.use(express.urlencoded({ extended: true })) | ||
|
||
app.post('/upload', async (req, res) => { | ||
const key = JSON.parse(fs.readFileSync('./wallet.json').toString()) | ||
try { | ||
const data = { | ||
in: req.body.in, | ||
conv2d_weights: req.body.conv2d_weights, | ||
conv2d_bias: req.body.conv2d_bias, | ||
batch_normalization_a: req.body.batch_normalization_a, | ||
dense_weights: req.body.dense_weights, | ||
dense_bias: req.body.dense_bias, | ||
} | ||
const response = await upload(data, key, 'mainnet') | ||
res.send(response) | ||
} catch (e) { | ||
res.send(`Error: ${e}`) | ||
} | ||
}) | ||
|
||
app.post('/uploadTest', async (req, res) => { | ||
const key = JSON.parse(fs.readFileSync('./wallet.json').toString()) | ||
try { | ||
const data = { | ||
in: req.body.in, | ||
conv2d_weights: req.body.conv2d_weights, | ||
conv2d_bias: req.body.conv2d_bias, | ||
batch_normalization_a: req.body.batch_normalization_a, | ||
dense_weights: req.body.dense_weights, | ||
dense_bias: req.body.dense_bias, | ||
} | ||
const response = await upload(data, key, 'local') | ||
res.send(response) | ||
} catch (e) { | ||
res.send(`Error: ${e}`) | ||
} | ||
}) | ||
|
||
app.get('/uploadExample', async (req, res) => { | ||
const key = JSON.parse(fs.readFileSync('./wallet.json').toString()) | ||
const data = JSON.parse(fs.readFileSync('./src/resource/model.json').toString()) | ||
const tx = await upload(data, key, 'local') | ||
res.send(JSON.parse(tx)) | ||
}) | ||
|
||
app.post('/list', async (req, res) => { | ||
const data = req.body | ||
const response = await list(data.priv, data.name, data.url) | ||
res.send(response) | ||
}) | ||
app.listen(8080) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface IAgeModel { | ||
in: number[][] | ||
conv2d_weights: number[] | ||
conv2d_bias: number[] | ||
batch_normalization_a: number[] | ||
batch_normalization_b: number[] | ||
dense_weights: number[] | ||
dense_bias: number[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"status":"1","message":"OK-Missing/Invalid API Key, rate limit of 1/5sec applied","result":"[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"buyWeight\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getList\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"url\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"uploadType\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"}],\"name\":\"uploadWeight\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"userWeight\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"weightList\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"url\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"uploadType\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]"} |
Oops, something went wrong.