-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(template): utilize new GET /v1/templates/{id} endpoint for t…
…emplate and deployment detail refs #477
- Loading branch information
1 parent
7bd3a89
commit bc893c6
Showing
15 changed files
with
158 additions
and
109 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 |
---|---|---|
|
@@ -21,7 +21,8 @@ | |
"repo", | ||
"styling", | ||
"observability", | ||
"analytics" | ||
"analytics", | ||
"template" | ||
] | ||
] | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import { DeploymentDetail } from "@src/components/deployments/DeploymentDetail"; | ||
import type { GetServerSideProps } from "next"; | ||
import { z } from "zod"; | ||
|
||
type Props = { | ||
dseq: string; | ||
}; | ||
import { DeploymentDetail, DeploymentDetailProps } from "@src/components/deployments/DeploymentDetail"; | ||
import { CI_CD_TEMPLATE_ID } from "@src/config/remote-deploy.config"; | ||
import { services } from "@src/services/http/http-server.service"; | ||
|
||
const DeploymentDetailPage: React.FunctionComponent<Props> = ({ dseq }) => { | ||
return <DeploymentDetail dseq={dseq} />; | ||
}; | ||
export default DeploymentDetail; | ||
|
||
export default DeploymentDetailPage; | ||
const contextSchema = z.object({ | ||
params: z.object({ | ||
dseq: z.string() | ||
}) | ||
}); | ||
type Params = z.infer<typeof contextSchema>["params"]; | ||
|
||
export const getServerSideProps: GetServerSideProps<DeploymentDetailProps, Params> = async context => { | ||
const { params } = contextSchema.parse(context); | ||
const remoteDeployTemplate = await services.template.findById(CI_CD_TEMPLATE_ID); | ||
|
||
export async function getServerSideProps({ params }) { | ||
return { | ||
props: { | ||
dseq: params?.dseq | ||
remoteDeployTemplate, | ||
dseq: params.dseq | ||
} | ||
}; | ||
} | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
apps/deploy-web/src/services/http-factory/http-factory.service.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,31 @@ | ||
import { TxHttpService, UserHttpService } from "@akashnetwork/http-sdk"; | ||
import { StripeService } from "@akashnetwork/http-sdk/src/stripe/stripe.service"; | ||
import { TemplateHttpService } from "@akashnetwork/http-sdk/src/template/template-http.service"; | ||
import { event } from "nextjs-google-analytics"; | ||
|
||
import type { BrowserEnvConfig, ServerEnvConfig } from "@src/config/env-config.schema"; | ||
import { authService } from "@src/services/auth/auth.service"; | ||
import { AnalyticsCategory, AnalyticsEvents } from "@src/types/analytics"; | ||
import { customRegistry } from "@src/utils/customRegistry"; | ||
|
||
export const createServices = (config: Pick<ServerEnvConfig, "BASE_API_MAINNET_URL"> | Pick<BrowserEnvConfig, "NEXT_PUBLIC_BASE_API_MAINNET_URL">) => { | ||
const apiConfig = { baseURL: "BASE_API_MAINNET_URL" in config ? config.BASE_API_MAINNET_URL : config.NEXT_PUBLIC_BASE_API_MAINNET_URL }; | ||
|
||
const user = new UserHttpService(apiConfig); | ||
const stripe = new StripeService(apiConfig); | ||
const tx = new TxHttpService(customRegistry, apiConfig); | ||
const template = new TemplateHttpService(apiConfig); | ||
|
||
user.interceptors.request.use(authService.withAnonymousUserHeader); | ||
stripe.interceptors.request.use(authService.withAnonymousUserHeader); | ||
tx.interceptors.request.use(authService.withAnonymousUserHeader); | ||
|
||
user.interceptors.response.use(response => { | ||
if (response.config.url?.startsWith("/v1/anonymous-users") && response.config.method === "post" && response.status === 200) { | ||
event(AnalyticsEvents.ANONYMOUS_USER_CREATED, { category: AnalyticsCategory.USER, label: "Anonymous User Created" }); | ||
} | ||
return response; | ||
}); | ||
|
||
return { user, stripe, tx, template }; | ||
}; |
Oops, something went wrong.