Skip to content

Commit

Permalink
Merge pull request #32 from tokenguardio/dev
Browse files Browse the repository at this point in the history
Release 1.9.1
  • Loading branch information
rrozek authored Nov 29, 2024
2 parents f1138de + c0888e4 commit 8f64c2c
Show file tree
Hide file tree
Showing 22 changed files with 541 additions and 88 deletions.
26 changes: 13 additions & 13 deletions k8s/db-api/environment/dev/values-new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ ingressInternal:
enabled: true
name: db-api-new-ingress-internal
rules:
- host: db-api-new.dev.tokenguard.io
- host: db-api-new.dev.patterns.build
http:
paths:
- backend:
service:
name: db-api-new
port:
number: 8082
path: /
pathType: Prefix
paths:
- backend:
service:
name: db-api-new
port:
number: 8082
path: /
pathType: Prefix

dbapi:
deployment:
name: db-api-new
image:
repository: "tokenguard-dev-db-api"
pullPolicy: Always
tag: "3180ea8b2301e29469454514aa1dd60c5e7c99f2"
tag: "b925f46a8d60da231af67b5c02f0b2ed3d153043"
replicaCount: 1
env:
env:
NODE_ENV: "development"
resources:
resources:
requests:
memory: "256Mi"
memory: "256Mi"
cpu: "200m"
limits:
memory: "2Gi"
Expand Down
29 changes: 14 additions & 15 deletions k8s/db-api/environment/dev/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,30 @@ ingressInternal:
enabled: true
name: db-api-ingress-internal
rules:
- host: db-api.dev.tokenguard.io
- host: db-api.dev.patterns.build
http:
paths:
- backend:
service:
name: db-api
port:
number: 8082
path: /
pathType: Prefix
paths:
- backend:
service:
name: db-api
port:
number: 8082
path: /
pathType: Prefix

dbapi:
deployment:
image:
repository: "tokenguard-dev-db-api"
pullPolicy: Always
tag: "c62befa08d6f54383b5eaee7d1f0cc805ee339a3"
tag: "b925f46a8d60da231af67b5c02f0b2ed3d153043"
replicaCount: 1
env:
env:
NODE_ENV: "development"
resources:
resources:
requests:
memory: "256Mi"
memory: "256Mi"
cpu: "200m"
limits:
memory: "2Gi"
cpu: "2000m"

cpu: "2000m"
28 changes: 14 additions & 14 deletions k8s/db-api/environment/prod/demo-dc-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ ingressInternal:
enabled: true
name: demo-dc-db-api-ingress-internal
rules:
- host: demo-dc-db-api.prod.tokenguard.io
- host: demo-dc-db-api.prod.patterns.build
http:
paths:
- backend:
service:
name: demo-dc-db-api
port:
number: 8082
path: /
pathType: Prefix
paths:
- backend:
service:
name: demo-dc-db-api
port:
number: 8082
path: /
pathType: Prefix

dbapi:
deployment:
Expand All @@ -30,19 +30,19 @@ dbapi:
pullPolicy: Always
tag: "a86cce991269bcaf81364a641c1b8fa2af3fdc25"
replicaCount: 1
env:
env:
NODE_ENV: "production"
resources:
resources:
requests:
memory: "256Mi"
memory: "256Mi"
cpu: "200m"
limits:
memory: "2Gi"
cpu: "2000m"
service:
service:
name: demo-dc-db-api
configmap:
name: demo-dc-db-api

secrets:
secrets:
name: demo-dc-db-api-secrets
29 changes: 14 additions & 15 deletions k8s/db-api/environment/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,30 @@ ingressInternal:
enabled: true
name: db-api-ingress-internal
rules:
- host: db-api.prod.tokenguard.io
- host: db-api.prod.patterns.build
http:
paths:
- backend:
service:
name: db-api
port:
number: 8082
path: /
pathType: Prefix
paths:
- backend:
service:
name: db-api
port:
number: 8082
path: /
pathType: Prefix

dbapi:
deployment:
image:
repository: "tokenguard-prod-db-api"
pullPolicy: Always
tag: "234bbe441fed160cd223514dd5feef77a1586d9b"
tag: "f1138de09a2ad15969b8a149cff4f3b2a6d41d9f"
replicaCount: 1
env:
env:
NODE_ENV: "production"
resources:
resources:
requests:
memory: "256Mi"
memory: "256Mi"
cpu: "200m"
limits:
memory: "2Gi"
cpu: "2000m"

cpu: "2000m"
4 changes: 2 additions & 2 deletions k8s/db-api/template/templates/db-api-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: Secret
metadata:
name: {{ .Values.secrets.name }}
stringData:
data-postgres-host: "ref+awsssm://{{ .Values.eksEnvironment }}/infrastructure/rds/postgres/address"
data-postgres-port: "ref+awsssm://{{ .Values.eksEnvironment }}/infrastructure/rds/postgres/port"
data-postgres-host: "ref+awsssm://{{ .Values.eksEnvironment }}/infrastructure/rds/postgres-prod/address"
data-postgres-port: "ref+awsssm://{{ .Values.eksEnvironment }}/infrastructure/rds/postgres-prod/port"
data-postgres-username: "ref+awsssm://{{ .Values.eksEnvironment }}/application/db-api/db/data/username"
data-postgres-password: "ref+awsssm://{{ .Values.eksEnvironment }}/application/db-api/db/data/password"
data-postgres-dbnames: "ref+awsssm://{{ .Values.eksEnvironment }}/application/db-api/db/data/dbnames"
Expand Down
31 changes: 31 additions & 0 deletions migrations/20241019112615_update_dapps_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Knex } from "knex";

exports.up = async function (knex: Knex): Promise<void> {
const airdropContractExists = await knex.schema
.withSchema("dapp_analytics")
.hasColumn("dapps", "airdrop_contract");
const airdropCurrencyExists = await knex.schema
.withSchema("dapp_analytics")
.hasColumn("dapps", "airdrop_currency_contract");

// Perform the table alteration based on column existence
return knex.schema
.withSchema("dapp_analytics")
.alterTable("dapps", function (table) {
if (!airdropContractExists) {
table.text("airdrop_contract");
}
if (!airdropCurrencyExists) {
table.text("airdrop_currency_contract");
}
});
};

exports.down = function (knex: Knex): Promise<void> {
return knex.schema
.withSchema("dapp_analytics")
.alterTable("dapps", function (table) {
table.dropColumn("airdrop_contract");
table.dropColumn("airdrop_currency_contract");
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "db-api",
"version": "1.8.1",
"version": "1.9.1",
"private": true,
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import queryRoutes from "./routes/query";
import databaseInfoRoutes from "./routes/databaseInfo";
import chartDataRouters from "./routes/chartData";
import dappAnalyticsRoutes from "./routes/dapp-analytics";
import segmentsRoutes from "./routes/segments";
import logger from "./utils/logger";
import { ApiError } from "./middleware/joiValidate";

Expand Down Expand Up @@ -52,6 +53,7 @@ app.use(queryRoutes);
app.use(databaseInfoRoutes);
app.use(chartDataRouters);
app.use(dappAnalyticsRoutes);
app.use(segmentsRoutes);

app.use((err: ApiError, req: Request, res: Response, next: NextFunction) => {
const statusCode = err.statusCode || 500;
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/dapp-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const saveDapp = async (
res: Response
): Promise<Response> => {
try {
const { name, logo, blockchain, website, fromBlock, addedBy, abis } =
const { name, logo, blockchain, website, fromBlock, addedBy, abis, airdropContract, airdropCurrencyContract } =
req.body;
const createdDapp = await dappService.saveDapp({
name,
Expand All @@ -16,6 +16,8 @@ export const saveDapp = async (
from_block: fromBlock,
added_by: addedBy,
abis,
airdrop_contract: airdropContract,
airdrop_currency_contract: airdropCurrencyContract,
});

return res.status(201).json({
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export const executeQuery = async (
});
}
}

// Validate names of provided identifiers
for (const savedIdentifier of savedIdentifiers) {
const providedIdentifier = providedIdentifiers.find(
Expand All @@ -196,7 +195,6 @@ export const executeQuery = async (
if (error) {
return res.status(400).json({ message: error });
}

const result = await dataDbQueryService.executeQuery(
selectedDatabase,
sqlQuery,
Expand Down
28 changes: 28 additions & 0 deletions src/controllers/segments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Request, Response } from "express";
import * as segmentsService from "../db/services/segmentsService";

export const createSegment = async (
req: Request,
res: Response
): Promise<Response> => {
try {

const { dappId, segmentId, segmentName, filters } = req.body;
const createdSegment = await segmentsService.createSegment(
dappId,
segmentId,
segmentName,
filters
);

return res.status(201).json({
data: createdSegment,
message: "Segment created successfully",
});
} catch (error) {
console.error("Error creating the segment:", error);
return res.status(500).json({
message: "Error occurred while creating the segment",
});
}
};
Loading

0 comments on commit 8f64c2c

Please sign in to comment.