Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Sep 29, 2023
1 parent 20250b4 commit f61e422
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ui/app/api/peers/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function POST(request: Request) {
const flowServiceAddress = process.env.PEERDB_FLOW_SERVER_ADDRESS!;
const flowServiceClient = GetFlowServiceClient(flowServiceAddress);
const peer = constructPeer(name, type, config);
const req: CreatePeerRequest = {peer};
const req: CreatePeerRequest = { peer };
const status: CreatePeerResponse = await flowServiceClient.createPeer(req);
if (status.status === CreatePeerStatus.FAILED) {
return new Response(status.message);
Expand Down
10 changes: 7 additions & 3 deletions ui/app/api/peers/util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { PeerConfig } from '@/app/peers/create/configuration/types';
import { DBType, Peer, PostgresConfig, SnowflakeConfig } from '@/grpc_generated/peers';
import { DBType, Peer, PostgresConfig } from '@/grpc_generated/peers';

export const constructPeer = (name:string, type: string, config: PeerConfig):Peer|undefined => {
export const constructPeer = (
name: string,
type: string,
config: PeerConfig
): Peer | undefined => {
switch (type) {
case 'POSTGRES':
return {
name,
type: DBType.POSTGRES,
postgresConfig: config as PostgresConfig
postgresConfig: config as PostgresConfig,
};
default:
return;
Expand Down
5 changes: 3 additions & 2 deletions ui/app/api/peers/validate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export async function POST(request: Request) {
const flowServiceAddress = process.env.PEERDB_FLOW_SERVER_ADDRESS!;
const flowServiceClient = GetFlowServiceClient(flowServiceAddress);
const peer = constructPeer(name, type, config);
const req: ValidatePeerRequest = {peer};
const status: ValidatePeerResponse = await flowServiceClient.validatePeer(req);
const req: ValidatePeerRequest = { peer };
const status: ValidatePeerResponse =
await flowServiceClient.validatePeer(req);
if (status.status === ValidatePeerStatus.INVALID) {
return new Response(status.message);
} else if (status.status === ValidatePeerStatus.VALID) {
Expand Down
17 changes: 8 additions & 9 deletions ui/app/peers/create/configuration/helpers/common.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { blankPostgresSetting } from "./pg";
import { blankPostgresSetting } from './pg';

export const getBlankSetting = (dbType: string) => {
switch (dbType) {
case 'POSTGRES':
return blankPostgresSetting;
default:
return blankPostgresSetting;
}
};

switch (dbType) {
case 'POSTGRES':
return blankPostgresSetting;
default:
return blankPostgresSetting;
}
};
2 changes: 1 addition & 1 deletion ui/app/peers/create/configuration/helpers/pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export const blankPostgresSetting = {
password: '',
database: '',
transactionSnapshot: '',
}
};
2 changes: 1 addition & 1 deletion ui/app/peers/create/configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { useRouter, useSearchParams } from 'next/navigation';
import { useState } from 'react';
import PgConfig from './configForm';
import { handleCreate, handleValidate } from './handlers';
import { getBlankSetting } from './helpers/common';
import { postgresSetting } from './helpers/pg';
import { PeerConfig } from './types';
import { getBlankSetting } from './helpers/common';
export default function CreateConfig() {
const searchParams = useSearchParams();
const router = useRouter();
Expand Down
6 changes: 2 additions & 4 deletions ui/components/SelectSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ interface SelectSourceProps {
setPeerType: Dispatch<SetStateAction<string>>;
}

export default function SelectSource({
setPeerType,
}: SelectSourceProps) {
export default function SelectSource({ setPeerType }: SelectSourceProps) {
const dbTypes: string[] = Object.values(DBType).filter(
(value): value is string =>
typeof value === 'string' && value === "POSTGRES"
typeof value === 'string' && value === 'POSTGRES'
);
return (
<Select
Expand Down

0 comments on commit f61e422

Please sign in to comment.