-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] Update imports for using esm - [x] Add docker support - [x] Add health check endpoint
- Loading branch information
Showing
44 changed files
with
283 additions
and
140 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,6 @@ | ||
node_modules | ||
build | ||
coverage | ||
.git | ||
zkeys | ||
|
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,32 @@ | ||
# Copy source code and build the project | ||
FROM node:20-alpine AS builder | ||
|
||
WORKDIR /builder | ||
|
||
COPY . . | ||
|
||
RUN npm i -g pnpm@9 | ||
RUN pnpm install | ||
RUN pnpm run build | ||
|
||
# Create image by copying build artifacts | ||
FROM node:20-alpine AS runner | ||
RUN npm i -g pnpm@9 | ||
|
||
RUN mkdir -p ~/rapidsnark/build; \ | ||
wget -qO ~/rapidsnark/build/prover https://maci-devops-zkeys.s3.ap-northeast-2.amazonaws.com/rapidsnark-linux-amd64-1c137; \ | ||
chmod +x ~/rapidsnark/build/prover | ||
RUN wget -qO ~/circom https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64; \ | ||
chmod +x ~/circom; \ | ||
mv ~/circom /bin | ||
|
||
USER node | ||
ARG PORT=3000 | ||
|
||
WORKDIR /maci | ||
COPY --chown=node:node --from=builder /builder/ ./ | ||
RUN pnpm run download-zkeys:test:relayer | ||
WORKDIR /maci/apps/relayer | ||
|
||
EXPOSE ${PORT} | ||
CMD ["sh", "-c", "pnpm run hardhat & node build/ts/main.js"] |
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,46 @@ | ||
version: "3.8" | ||
|
||
services: | ||
service: | ||
build: | ||
context: ../.. | ||
dockerfile: apps/relayer/Dockerfile | ||
volumes: | ||
- .:/app | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- RELAYER_RPC_URL=${RELAYER_RPC_URL} | ||
- TTL=${TTL} | ||
- LIMIT=${LIMIT} | ||
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS} | ||
- MAX_MESSAGES=${MAX_MESSAGES} | ||
- MONGO_DB_URI=mongodb://mongodb:27017 | ||
- MONGODB_USER=${MONGODB_USER} | ||
- MONGODB_PASSWORD=${MONGODB_PASSWORD} | ||
- MONGODB_DATABASE=${MONGODB_DATABASE} | ||
- MNEMONIC=${MNEMONIC} | ||
depends_on: | ||
- mongodb | ||
networks: | ||
- mongo-net | ||
|
||
mongodb: | ||
image: mongo:latest | ||
container_name: mongodb | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER} | ||
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASSWORD} | ||
- MONGO_INITDB_DATABASE=${MONGODB_DATABASE} | ||
volumes: | ||
- mongodb-data:/data/db | ||
networks: | ||
- mongo-net | ||
|
||
networks: | ||
mongo-net: | ||
driver: bridge | ||
|
||
volumes: | ||
mongodb-data: | ||
driver: local |
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
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
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
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
28 changes: 28 additions & 0 deletions
28
apps/relayer/ts/health/__tests__/health.controller.test.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,28 @@ | ||
import { jest } from "@jest/globals"; | ||
import { Test } from "@nestjs/testing"; | ||
|
||
import { HealthController } from "../health.controller.js"; | ||
|
||
describe("HealthController", () => { | ||
let controller: HealthController; | ||
|
||
beforeEach(async () => { | ||
const app = await Test.createTestingModule({ | ||
controllers: [HealthController], | ||
}).compile(); | ||
|
||
controller = app.get<HealthController>(HealthController); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe("v1/health/check", () => { | ||
test("should check properly", () => { | ||
const isRunning = controller.check(); | ||
|
||
expect(isRunning).toBe(true); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
/* eslint-disable @typescript-eslint/no-shadow */ | ||
import { Controller, Get, HttpStatus } from "@nestjs/common"; | ||
import { ApiResponse, ApiTags } from "@nestjs/swagger"; | ||
|
||
@ApiTags("v1/health") | ||
@Controller("v1/health") | ||
export class HealthController { | ||
/** | ||
* Health check api method. | ||
* | ||
* @param args fetch arguments | ||
* @returns message batches | ||
*/ | ||
@ApiResponse({ status: HttpStatus.OK, description: "The service is running" }) | ||
@Get("check") | ||
check(): boolean { | ||
return true; | ||
} | ||
} |
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,8 @@ | ||
import { Module } from "@nestjs/common"; | ||
|
||
import { HealthController } from "./health.controller.js"; | ||
|
||
@Module({ | ||
controllers: [HealthController], | ||
}) | ||
export class HealthModule {} |
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
Oops, something went wrong.