Skip to content

Commit

Permalink
Fixed Deployment errors (#5)
Browse files Browse the repository at this point in the history
* Working on deployment

* modifying env options.

* Updated deploy2ec2.yml

* Update deploy2ec2.yml

* Update deploy2ec2.yml

* Update deploy2ec2.yml

* Updating deployment.

* sanity commit.

* sc

* Update deploy2ec2.yml

* Update deploy2ec2.yml

* Update docker-compose.dev.yml

* Update deploy2ec2.yml

* Update deploy2ec2.yml

* Update deploy2ec2.yml

* Exculding test files from build.

* Updated Docker compose and merged changes.

* Correcting docekr compsoe.

* sanity commit .

* Sanity Commit.

* fix.

* moved env to specific file in utils.

* Minor fixes to build process.

---------

Co-authored-by: Parminderwits <[email protected]>
  • Loading branch information
abhik-wil and Parminderwits authored Jan 3, 2025
1 parent fb1687b commit d9fe940
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy2ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ jobs:
echo "BUILT"
# Cleanup
sudo docker builder prune -af
echo "NGINX Restarted"
# Restart nginx
sudo systemctl restart nginx
Submodule draft-healthcare-service updated 24 files
+44 −364 api/build/build.yaml
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm.json
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm_bpp_collect.json
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm_multi_collection.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init_bpp_collect.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init_multi_collection.json
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm.yaml
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm_bpp_collect.yaml
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm_multi_collection.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init_bpp_collect.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init_multi_collection.yaml
+1 −1 api/components/Examples/Health_care_services_yaml/search/search.yaml
+4 −4 api/components/flows/Health_Care_Service/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Cancellation/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Merchant_Cancellation/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Multi_Collection/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Number_Of_Patients/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Recollection/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Slot_Reschedule/index.yaml
+5 −5 api/components/flows/Health_Care_Services_Updation/index.yaml
+20 −12 api/docs/#prd#_for_healthcare_services.md
+1 −1 ui/build.js
3 changes: 2 additions & 1 deletion apps/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dotenv/config'
import express, { Express, Request, Response } from "express";
import swaggerUi from "swagger-ui-express";
import cron from "node-cron"; // Import node-cron
Expand Down Expand Up @@ -25,7 +26,7 @@ import {
import { retailRouter } from "./controllers/retail";
import { sendUpsolicieatedOnStatus } from "./lib/utils/sendUpsolicieatedOnStatus";
import { loadConfig } from "./lib/utils";
import 'dotenv/config'


export const app: Express = express();
const port = process.env.PORT || 3000;
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/lib/utils/redis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Redis, { RedisOptions } from "ioredis";

const redisOptions: RedisOptions = {
host: process.env.REDIS_HOST || "localhost",
port: (process.env.REDIS_PORT || 6379) as number,
Expand All @@ -12,6 +11,7 @@ export type TransactionType = {
response?: object
};

console.log("REDIS OPTIONS", redisOptions);


export const redis = new Redis(redisOptions);
38 changes: 24 additions & 14 deletions apps/frontend/src/components/MockRequestSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useAction, useDomain, useMock } from "../utils/hooks";
import { URL_MAPPING } from "../utils";
import axios, { AxiosError } from "axios";
import { UserGuide } from "./UserGuideSection";
import { VITE_SERVER_URL } from "../utils/env";

// type MockRequestSectionProp = {
// domain: string;
Expand All @@ -33,13 +34,14 @@ export const MockRequestSection = () => {

const { domain } = useDomain();
const [version, setVersion] = useState("");
const { action, detectAction, logError, scenarios,setLogError } = useAction();
const { action, detectAction, logError, scenarios, setLogError } =
useAction();
const { setAsyncResponse, setSyncResponse } = useMock();

useEffect(()=>{
setLog("")
setLogError(false)
},[domain])
useEffect(() => {
setLog("");
setLogError(false);
}, [domain]);
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand All @@ -53,24 +55,28 @@ export const MockRequestSection = () => {
const [curl, setCurl] = useState<string>();

const handleVersion = (
event: React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FocusEvent<Element> | null,
event:
| React.MouseEvent<Element>
| React.KeyboardEvent<Element>
| React.FocusEvent<Element>
| null,
value: {} | null
) => {
console.log("event",event)
console.log("event", event);
if (value) {
setVersion(value as string); // Ensure value is a string and set the version
}
};

const handleLogChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setLog(e.target.value);
detectAction(e.target.value,version);
detectAction(e.target.value, version);
};

const handleSubmit = async () => {
let url = `${[
import.meta.env.VITE_SERVER_URL,
]}/${domain.toLowerCase()}/${Object.keys(URL_MAPPING).filter((key) =>
let url = `${
VITE_SERVER_URL
}/${domain.toLowerCase()}/${Object.keys(URL_MAPPING).filter((key) =>
URL_MAPPING[key as keyof typeof URL_MAPPING].includes(action as string)
)}/${action}?mode=mock&version=${version}`;
if (activeScenario?.scenario)
Expand All @@ -86,10 +92,10 @@ export const MockRequestSection = () => {
const response = await axios.post(url, JSON.parse(log as string), {
headers: {
"Content-Type": "application/json",
"mode": "mock"
mode: "mock",
},
});

setSyncResponse(response.data.sync);
setAsyncResponse(response.data.async || {});
} catch (error) {
Expand All @@ -111,7 +117,11 @@ export const MockRequestSection = () => {
<Stack spacing={2} justifyContent="center" alignItems="center">
<Typography variant="h5">Mock Server</Typography>
{domain === "retail" && (
<Select placeholder="Select a version" sx={{ width: "100%" }} onChange={handleVersion}>
<Select
placeholder="Select a version"
sx={{ width: "100%" }}
onChange={handleVersion}
>
<Option value="b2b">B2B</Option>
<Option value="b2c">B2C</Option>
</Select>
Expand Down
16 changes: 10 additions & 6 deletions apps/frontend/src/components/SandboxRequestSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useAction, useDomain, useSandbox } from "../utils/hooks";
import { URL_MAPPING } from "../utils";
import axios, { AxiosError } from "axios";
import { UserGuide } from "./UserGuideSection";
import { VITE_SERVER_URL } from "../utils/env";

export const SandboxRequestSection = () => {
const [authHeader, setAuthHeader] = useState<string>();
Expand Down Expand Up @@ -54,20 +55,23 @@ export const SandboxRequestSection = () => {
};

const handleVersion = (
event: React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FocusEvent<Element> | null,
event:
| React.MouseEvent<Element>
| React.KeyboardEvent<Element>
| React.FocusEvent<Element>
| null,
value: {} | null
) => {
console.log("event",event)
console.log("event", event);
if (value) {
setVersion(value as string); // Ensure value is a string and set the version
}
};


const handleSubmit = async () => {
let url = `${[
import.meta.env.VITE_SERVER_URL,
]}/${domain.toLowerCase()}/${Object.keys(URL_MAPPING).filter((key) =>
let url = `${
VITE_SERVER_URL
}/${domain.toLowerCase()}/${Object.keys(URL_MAPPING).filter((key) =>
URL_MAPPING[key as keyof typeof URL_MAPPING].includes(action as string)
)}/${action}?mode=sandbox&version=${version}`;

Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/src/components/TransactionSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as _ from "lodash";
import { useAnalyse, useMessage } from "../utils/hooks";
import { useState } from "react";
import RefreshIcon from "@mui/icons-material/Refresh";
import { VITE_SERVER_URL } from "../utils/env";

export const TransactionSearch = () => {
const theme = useTheme();
Expand All @@ -21,9 +22,10 @@ export const TransactionSearch = () => {
const [transactionId, setTransactionId] = useState("");

const fetchTransaction = async (transaction: string) => {
console.log('API URL:', VITE_SERVER_URL);
try {
const response = await axios.get(
`${import.meta.env.VITE_SERVER_URL}/analyse/${transaction}`
`${VITE_SERVER_URL}/analyse/${transaction}`
);
const formattedResponse = response.data
.reduce(
Expand Down
8 changes: 5 additions & 3 deletions apps/frontend/src/pages/sandbox/InitiateRequestSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useDomain, useEnvironment, useMessage } from "../../utils/hooks";
import HelpOutlineTwoToneIcon from "@mui/icons-material/HelpOutlineTwoTone";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import { VITE_SERVER_URL } from "../../utils/env";

// import { Item } from "common/index";
// type InitiateRequestSectionProp = {
Expand Down Expand Up @@ -98,7 +99,7 @@ export const InitiateRequestSection = () => {
message: { matchingItems: any[] };
}>(
`${
import.meta.env.VITE_SERVER_URL
VITE_SERVER_URL
}/${domain.toLowerCase()}/getCatalog/?mode=mock`,
{ transactionId },
{
Expand Down Expand Up @@ -237,10 +238,11 @@ export const InitiateRequestSection = () => {

const handleSubmit = async () => {
try {
console.log('API URL:', VITE_SERVER_URL);
const response = await axios.post(
`${
import.meta.env.VITE_SERVER_URL
}/${domain}/initiate/${action}?mode=mock&version=${version}&scenario=${selectedScenario}`,
VITE_SERVER_URL
}/${domain.toLowerCase()}/initiate/${action}?mode=mock&version=${version}&scenario=${selectedScenario}`,
formState,
{
headers: {
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/pages/sign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useState } from "react";
import axios, { AxiosError } from "axios";
import { MessageDialog } from "../../components";
import { useMessage } from "../../utils/hooks";
import { VITE_SERVER_URL } from "../../utils/env";

export const Sign = () => {
const theme = useTheme();
Expand All @@ -22,7 +23,7 @@ export const Sign = () => {
const handleSubmit = async () => {
try {
const response = await axios.post(
`${[import.meta.env.VITE_SERVER_URL]}/auth/signCheck`,
`${VITE_SERVER_URL}/auth/signCheck`,
requestBody,
{
headers: {
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/pages/swagger/domains/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import "swagger-ui-react/swagger-ui.css";
import { Toolbar } from "@mui/material";
import swaggerSpec from "openapi-specs/auth.json";
import { SwaggerDownloadButton } from "../../../../components";
import { VITE_SERVER_URL } from "../../../../utils/env";

export const AuthSwagger = () => {
swaggerSpec.servers = swaggerSpec.servers.map(({ url }: { url: string }) =>
url.startsWith(import.meta.env.VITE_SERVER_URL)
url.startsWith(VITE_SERVER_URL)
? { url }
: {
url: import.meta.env.VITE_SERVER_URL + url.replace("/api", ""),
url: VITE_SERVER_URL + url.replace("/api", ""),
// eslint-disable-next-line no-mixed-spaces-and-tabs
}
);
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/pages/swagger/domains/misc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import "swagger-ui-react/swagger-ui.css";
import { Toolbar } from "@mui/material";
import swaggerSpec from "openapi-specs/misc.json";
import { SwaggerDownloadButton } from "../../../../components";
import { VITE_SERVER_URL } from "../../../../utils/env";

export const MiscSwagger = () => {
swaggerSpec.servers = swaggerSpec.servers.map(({ url }: { url: string }) =>
url.startsWith(import.meta.env.VITE_SERVER_URL)
url.startsWith(VITE_SERVER_URL)
? { url }
: {
url: import.meta.env.VITE_SERVER_URL + url.replace("/api", ""),
url: VITE_SERVER_URL + url.replace("/api", ""),
// eslint-disable-next-line no-mixed-spaces-and-tabs
}
);
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VITE_SERVER_URL = import.meta.env.VITE_SERVER_URL || "https://mock.ondc.org/api";
3 changes: 2 additions & 1 deletion init_submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ git submodule add -b b2c_exports_2.0 https://github.com/ONDC-Official/ONDC-RET-S
# Services
git submodule add -b draft-services https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-services
git submodule add -b draft-agri_services https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-agri-services
git submodule add -b draft-healthcare https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-healthcare-services
git submodule add -b draft-healthcare https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-healthcare-service
git submodule add -b draft-agri_equipment https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-agri_equipment
git submodule add -b draft-agri_bids_and_auction https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-agri_bids_and_auction
git submodule add -b draft-astro https://github.com/ONDC-Official/ONDC-SRV-Specifications domain-repos/@services/draft-astro


# Logisitcs
Expand Down
Submodule draft-healthcare-services updated 24 files
+44 −364 api/build/build.yaml
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm.json
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm_bpp_collect.json
+0 −107 api/components/Examples/Health_care_services/on_confirm/on_confirm_multi_collection.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init_bpp_collect.json
+6 −6 api/components/Examples/Health_care_services/on_init/on_init_multi_collection.json
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm.yaml
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm_bpp_collect.yaml
+0 −64 api/components/Examples/Health_care_services_yaml/on_confirm/on_confirm_multi_collection.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init_bpp_collect.yaml
+2 −2 api/components/Examples/Health_care_services_yaml/on_init/on_init_multi_collection.yaml
+1 −1 api/components/Examples/Health_care_services_yaml/search/search.yaml
+4 −4 api/components/flows/Health_Care_Service/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Cancellation/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Merchant_Cancellation/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Multi_Collection/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Number_Of_Patients/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Recollection/index.yaml
+4 −4 api/components/flows/Health_Care_Services_Slot_Reschedule/index.yaml
+5 −5 api/components/flows/Health_Care_Services_Updation/index.yaml
+20 −12 api/docs/#prd#_for_healthcare_services.md
+1 −1 ui/build.js
1 change: 0 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"persistent": false
},
"dev": {
"dependsOn": ["db:migrate:dev","start:nginx"],
"cache": false,
"persistent": true
},
Expand Down

0 comments on commit d9fe940

Please sign in to comment.