Skip to content

Commit

Permalink
Merge pull request #934 from autonomys/feat/improve-taskboard-setup
Browse files Browse the repository at this point in the history
Improve taskboard setup
  • Loading branch information
marc-aurele-besner authored Nov 10, 2024
2 parents ef8b6c9 + ada28a2 commit 8c90428
Show file tree
Hide file tree
Showing 27 changed files with 1,067 additions and 457 deletions.
8 changes: 7 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ NETWORK_ID=mainnet
# Testnet - Taurus
# NETWORK_ID=taurus

LOG_LEVEL=debug

# Mainnet
NODE_DOCKER_TAG="mainnet-2024-nov-05"
# Testnet - Taurus
Expand Down Expand Up @@ -44,6 +46,10 @@ REDIS_PORT=6379
BULL_USERNAME=bull
BULL_PASSWORD=board
BULL_PORT=3020
BULL_SESSION_SECRET=keyboardcat

NR_API_KEY=""
NR_AGENT_IDENTIFIER=""
NR_AGENT_IDENTIFIER=""

SLACK_TOKEN=""
SLACK_CONVERSATION_ID=""
4 changes: 2 additions & 2 deletions .vscode/astral.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"path": "../indexers/gemini-3h"
},
{
"name": "indexer - Gemini 3G",
"path": "../indexers/gemini-3g"
"name": "Taskboard",
"path": "../indexers/taskboard"
}
],
"settings": {
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ services:

# Task Board Action Endpoint
HASURA_GRAPHQL_ACTION_TASK_BOARD: http://taskboard:${BULL_PORT}
HASURA_GRAPHQL_ACTION_TASK_BOARD_SESSION_SECRET: ${BULL_SESSION_SECRET}
ports:
- "${HASURA_GRAPHQL_PORT}:8080"
command:
Expand Down Expand Up @@ -342,6 +343,7 @@ services:
BULL_USERNAME: ${BULL_USERNAME}
BULL_PASSWORD: ${BULL_PASSWORD}
BULL_PORT: ${BULL_PORT}
BULL_SESSION_SECRET: ${BULL_SESSION_SECRET}

REDIS_HOST: redis
REDIS_PORT: ${REDIS_PORT}
Expand All @@ -351,3 +353,9 @@ services:
DB_DATABASE: ${DB_DATABASE}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}

NETWORK_ID: ${NETWORK_ID}
LOG_LEVEL: ${LOG_LEVEL}

SLACK_TOKEN: ${SLACK_TOKEN}
SLACK_CONVERSATION_ID: ${SLACK_CONVERSATION_ID}
21 changes: 14 additions & 7 deletions indexers/db/metadata/actions.graphql
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
type Mutation {
updateAccount(
args: AddTaskUpdateAccountInput!
): UpdateAccountOutput
slackNotification(args: SlackNotificationInput!): SlackNotificationOutput
}

type Mutation {
updateAccount(args: UpdateAccountInput!): UpdateAccountOutput
}

input UpdateAccountInput {
networkId: String!
accountId: String!
}

input AddTaskUpdateAccountInput {
queueName: String!
data: UpdateAccountInput!
jobId: String!
input SlackNotificationInput {
title: String!
path: String
message: String
logData: String
messageId: String
}

type UpdateAccountOutput {
blockNumber: String!
}

type SlackNotificationOutput {
title: String!
}
21 changes: 19 additions & 2 deletions indexers/db/metadata/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
actions:
- name: slackNotification
definition:
kind: asynchronous
handler: "{{HASURA_GRAPHQL_ACTION_TASK_BOARD}}/add-task"
forward_client_headers: true
headers:
- name: taskboard_session_secret
value: "{{HASURA_GRAPHQL_ACTION_TASK_BOARD_SESSION_SECRET}}"
permissions:
- role: astral-api
comment: Send a slack notification
- name: updateAccount
definition:
kind: asynchronous
handler: '{{HASURA_GRAPHQL_ACTION_TASK_BOARD}}/add-task'
handler: "{{HASURA_GRAPHQL_ACTION_TASK_BOARD}}/add-task"
forward_client_headers: true
headers:
- name: taskboard_session_secret
value: "{{HASURA_GRAPHQL_ACTION_TASK_BOARD_SESSION_SECRET}}"
permissions:
- role: astral-api
comment: Update account in db (will add the account if it was not indexed before)
custom_types:
enums: []
input_objects:
- name: UpdateAccountInput
- name: AddTaskUpdateAccountInput
- name: SlackNotificationInput
objects:
- name: UpdateAccountOutput
- name: SlackNotificationOutput
scalars: []
4 changes: 2 additions & 2 deletions indexers/taskboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USER node
RUN yarn install

# Expose the port the app runs on
EXPOSE 3000
EXPOSE ${BULL_PORT}

# Command to run the app
CMD ["yarn", "start"]
CMD yarn start
187 changes: 0 additions & 187 deletions indexers/taskboard/index.js

This file was deleted.

16 changes: 13 additions & 3 deletions indexers/taskboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"description": "A taskboard using Express and BullMQ to manage tasks",
"private": true,
"license": "MIT",
"main": "index.js",
"main": "src/index.ts",
"scripts": {
"start": "node index.js"
"start": "ts-node src/index.ts",
"dev": "export $(grep -v '^#' ../../.env | xargs) && export $(grep -v '^#' ../../.env.dev | xargs) && ts-node-dev src/index.ts"
},
"dependencies": {
"@autonomys/auto-consensus": "^1.0.1",
Expand All @@ -15,14 +16,23 @@
"@bull-board/express": "^5.23.0",
"body-parser": "^1.20.0",
"bullmq": "^4.6.0",
"connect-ensure-login": "^0.1.1",
"connect-redis": "^7.1.1",
"express": "^4.21.0",
"express-session": "^1.17.2",
"ioredis": "^5.4.1",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
"pg": "^8.13.0"
},
"devDependencies": {
"@types/bull": "^4.10.4",
"@types/express": "^5.0.0",
"@types/express-session": "^1.18.0",
"@types/node": "^22.9.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2"
},
"workspaces": {
"nohoist": [
"**"
Expand Down
Loading

0 comments on commit 8c90428

Please sign in to comment.