Skip to content

Commit

Permalink
fix(portal-app): wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherPHolder committed Jul 9, 2024
1 parent 3240e18 commit 30e55c5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 9 deletions.
6 changes: 6 additions & 0 deletions packages/aws-deploy/src/executors/lambda-deploy/executor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { resolve } from 'node:path';
import { env } from 'node:process';
import { PassThrough } from 'node:stream';
import { PromiseExecutor } from '@nx/devkit';
import { LambdaClient, UpdateFunctionCodeCommand } from '@aws-sdk/client-lambda';
import 'dotenv';

import { LambdaDeployExecutorSchema } from './schema';
import archiver = require('archiver');
Expand All @@ -27,6 +29,10 @@ const zip = (sourceDir: string): Promise<Uint8Array> => {
const runExecutor: PromiseExecutor<LambdaDeployExecutorSchema> = async ({ dist, functionName }) => {
const client = new LambdaClient({
region: 'us-east-1',
credentials: {
accessKeyId: env._AWS_ACCESS_KEY_ID!,
secretAccessKey: env._AWS_SECRET_ACCESS_KEY!,
},
});

const file = await zip(resolve(dist));
Expand Down
8 changes: 8 additions & 0 deletions packages/data-access/src/websocket.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export class WebsocketResource {
constructor() {
const socket = new WebSocket(environment.ufoSocketUrl);

console.log(socket.protocol);
socket.onopen = (e) => {
socket.send(
JSON.stringify({
body: {
action: 'is-online',
},
}),
);
console.log('Websocket opened', e);
};
socket.onmessage = (e) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/environments/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const environment = {
url: 'https://deepblue-userflow-records.s3.eu-central-1.amazonaws.com/',
name: 'deepblue-userflow-records',
},
ufoSocketUrl: 'wss://vq6maapfzc.execute-api.us-east-1.amazonaws.com/prod/',
ufoSocketUrl: 'wss://2of68hlyc3.execute-api.us-east-1.amazonaws.com/prod/',
isOnlineApi: 'https://ib3ncok6l1.execute-api.us-east-1.amazonaws.com/Prod/is-online',
};
2 changes: 1 addition & 1 deletion packages/userflow-conductor/is-online-ser/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"executor": "@app-speed/aws-deploy:lambda-deploy",
"options": {
"dist": "dist/packages/userflow-conductor/is-online-ser",
"functionName": "is-online"
"functionName": "AppSpeed_IsOnline"
},
"dependsOn": ["build"]
},
Expand Down
8 changes: 4 additions & 4 deletions packages/userflow-conductor/is-online-ser/src/lib/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { APIGatewayProxyEvent, APIGatewayProxyResult, Handler } from 'aws-lambda
import { RESPONSE_SUCCESSFUL, RESPONSE_SERVER_ERROR } from '@app-speed/userflow-conductor/shared-util-lib';
import { extractedError, formatedResponse } from '@app-speed/userflow-conductor/shared-util-lib';

export const handler: Handler<APIGatewayProxyEvent, APIGatewayProxyResult> = async ({ requestContext }) => {
const { domainName } = requestContext;

export const handler: Handler<APIGatewayProxyEvent, APIGatewayProxyResult> = async (event, context) => {
try {
console.log('-- > ', event, context);
const { domainName } = event.requestContext;
return formatedResponse(RESPONSE_SUCCESSFUL.OK, '1', domainName);
} catch (error: unknown) {
return formatedResponse(RESPONSE_SERVER_ERROR.INTERNAL_SERVER_ERROR, extractedError(error), domainName);
return formatedResponse(RESPONSE_SERVER_ERROR.INTERNAL_SERVER_ERROR, extractedError(error));
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const SOCKET_ROUTE = {
SCHEDULE_AUDIT: 'scheduleAudits',
};
2 changes: 1 addition & 1 deletion packages/userflow-conductor/socket-io-ser/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"executor": "@app-speed/aws-deploy:lambda-deploy",
"options": {
"dist": "dist/packages/userflow-conductor/socket-io-ser",
"functionName": "{@TODO}"
"functionName": "AppSpeed_Socket-IO"
},
"dependsOn": ["build"]
},
Expand Down
6 changes: 4 additions & 2 deletions packages/userflow-conductor/socket-io-ser/src/lib/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const enum EVENT_TYPE {
}

export const handler: Handler<APIGatewayProxyWebsocketEventV2, APIGatewayProxyResult> = async (event, context) => {
const { eventType, domainName } = event.requestContext;
const { functionName } = context;
console.log('-- > ', event, context);
try {
const { eventType, domainName } = event.requestContext;
const { functionName } = context;
switch (eventType) {
case EVENT_TYPE.CONNECT:
return formatedResponse(RESPONSE_SUCCESSFUL.CREATED, 'Successfully connected to web socket', domainName);
Expand All @@ -37,6 +38,7 @@ export const handler: Handler<APIGatewayProxyWebsocketEventV2, APIGatewayProxyRe
);
}
} catch (error) {
console.error('Catcher', event, context, error);
return formatedResponse(RESPONSE_SERVER_ERROR.INTERNAL_SERVER_ERROR, extractedError(error));
}
};

0 comments on commit 30e55c5

Please sign in to comment.