Skip to content

Commit

Permalink
feat: Replace structured events with binary ones (#182)
Browse files Browse the repository at this point in the history
closes #154
  • Loading branch information
levansuper authored Jun 25, 2023
1 parent df776f8 commit a68b074
Show file tree
Hide file tree
Showing 45 changed files with 844 additions and 471 deletions.
2 changes: 1 addition & 1 deletion k8s/broker.yml → k8s/api-broker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
name: authority-broker
name: authority-api-broker
2 changes: 1 addition & 1 deletion k8s/api-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ spec:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: authority-broker
name: authority-api-broker
4 changes: 4 additions & 0 deletions k8s/awala-broker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
name: authority-awala-broker
69 changes: 69 additions & 0 deletions k8s/awala-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: veraid-authority-awala
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/min-scale: "1"
spec:
containers:
- name: queue
image: dev.local/veraid-authority
args: [awala]
readinessProbe:
httpGet:
path: /
initialDelaySeconds: 1
env:
- name: AUTHORITY_VERSION
value: "1.0.0dev1"
- name: MONGODB_USERNAME
valueFrom:
configMapKeyRef:
name: credentials
key: mongodb_username
- name: MONGODB_PASSWORD
valueFrom:
secretKeyRef:
name: credentials
key: mongodb_password
- name: MONGODB_URI
value: mongodb://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@mongodb

# Mock AWS KMS (used by WebCrypto KMS)
- name: KMS_ADAPTER
value: AWS
- name: AWS_ACCESS_KEY_ID
valueFrom:
configMapKeyRef:
name: mock-aws-kms
key: access_key_id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: credentials
key: aws_kms_secret_access_key
- name: AWS_KMS_ENDPOINT
valueFrom:
configMapKeyRef:
name: mock-aws-kms
key: endpoint
- name: AWS_KMS_REGION
value: eu-west-2
---
apiVersion: sources.knative.dev/v1
kind: SinkBinding
metadata:
name: veraid-authority-awala-sink-binding
spec:
subject:
apiVersion: serving.knative.dev/v1
kind: Service
name: veraid-authority-awala
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: authority-awala-broker
1 change: 0 additions & 1 deletion k8s/member-bundle-request-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: member-bundle-request-trigger
spec:
schedule: "*/1 * * * *"
contentType: "application/cloudevents+json"
data: '{"id":"ce-id","type":"net.veraid.authority.member-bundle-request-trigger","source":"https://veraid.net/authority","specversion":"1.0","data":{}}'
sink:
ref:
Expand Down
17 changes: 1 addition & 16 deletions k8s/mock-awala-middleware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,12 @@ spec:
- name: MOCKSERVER_SERVER_PORT
value: "8080"
---
apiVersion: sources.knative.dev/v1
kind: SinkBinding
metadata:
name: mock-awala-middleware-sink-binding
spec:
subject:
apiVersion: serving.knative.dev/v1
kind: Service
name: mock-awala-middleware
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: authority-broker
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: mock-awala-middleware-trigger
spec:
broker: authority-broker
broker: authority-awala-broker
subscriber:
ref:
apiVersion: serving.knative.dev/v1
Expand Down
4 changes: 2 additions & 2 deletions k8s/queue-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ spec:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: authority-broker
name: authority-api-broker
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: veraid-authority-queue-trigger
spec:
broker: authority-broker
broker: authority-api-broker
subscriber:
ref:
apiVersion: serving.knative.dev/v1
Expand Down
5 changes: 0 additions & 5 deletions src/api/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import type { FastifyInstance } from 'fastify';

import { mockSpy } from '../testUtils/jest.js';

const mockRegisterAwalaRoute = mockSpy(jest.fn());
jest.unstable_mockModule('./routes/awala.routes.js', () => ({
default: mockRegisterAwalaRoute,
}));

const mockFastify: FastifyInstance = {
register: mockSpy(jest.fn()),
} as any;
Expand Down
7 changes: 1 addition & 6 deletions src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ import jwksPlugin from '../utilities/fastify/plugins/jwksAuthentication.js';

import healthcheckRoutes from './routes/healthcheck.routes.js';
import orgRoutes from './routes/org.routes.js';
import awalaRoutes from './routes/awala.routes.js';

export async function makeApiServerPlugin(server: FastifyInstance): Promise<void> {
const rootRoutes: FastifyPluginCallback<RouteOptions>[] = [
healthcheckRoutes,
orgRoutes,
awalaRoutes,
];
const rootRoutes: FastifyPluginCallback<RouteOptions>[] = [healthcheckRoutes, orgRoutes];

await server.register(jwksPlugin);
await Promise.all(rootRoutes.map((route) => server.register(route)));
Expand Down
Loading

0 comments on commit a68b074

Please sign in to comment.