Skip to content

Commit

Permalink
[PROTO-1789] Fix up minor entrypoint issues and deploy (#8252)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Apr 29, 2024
1 parent 7e4ec20 commit ca8133d
Show file tree
Hide file tree
Showing 13 changed files with 4,145 additions and 267 deletions.
4,200 changes: 4,046 additions & 154 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"packages/ddex/webapp/server",
"packages/ddex/webapp/client",
"packages/ddex/publisher",
"packages/ddex/processor",
"packages/ddex/entrypoint",
"packages/es-indexer"
],
Expand Down
15 changes: 9 additions & 6 deletions packages/ddex/entrypoint/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# DDEX entrypoint

Found at distro.audius.co.

Simple redirects to relevant DDEX apps.
Artist-facing entrypoint to distributor apps.

## Development
```
npm run dev
npm run start:<dev|stage|prod>
```

## Build
```
npm run build:<dev|stage|prod>
```

## Deployment
## Deploy
```
npm run deploy
npm run deploy:<dev|stage|prod>
```
6 changes: 5 additions & 1 deletion packages/ddex/entrypoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"start:stage": "env-cmd -f .env.stage turbo run start --filter=@audius/ddex-entrypoint",
"start:prod": "env-cmd -f .env.prod turbo run start --filter=@audius/ddex-entrypoint",
"build": "tsc && vite build",
"build:dev": "env-cmd -f .env.dev turbo run build --filter=@audius/ddex-entrypoint",
"build:stage": "env-cmd -f .env.stage turbo run build --filter=@audius/ddex-entrypoint",
"build:prod": "env-cmd -f .env.prod turbo run build --filter=@audius/ddex-entrypoint",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"deploy": "npm run build && wrangler pages deploy ./dist"
"deploy:stage": "npm run build:stage && wrangler pages deploy --branch=stage ./dist",
"deploy:prod": "npm run build:prod && wrangler pages deploy ./dist"
},
"dependencies": {
"@audius/harmony": "*",
Expand Down
84 changes: 44 additions & 40 deletions packages/ddex/entrypoint/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
} from '@tanstack/react-query'
import { Flex } from '@audius/harmony'
import { Footer } from './components/Footer'
import { AudiusSdkProvider } from './contexts/AudiusSdkProvider'
import { ConnectDistributor } from './components/ConnectDistributor'
import { AuthProvider, Status, useAuth } from './contexts/AuthProvider'
import { AuthProvider, useAuth } from './contexts/AuthProvider'
import { Success } from './components/Success'
import { Status } from './contexts/types'

const queryClient = new QueryClient()

Expand Down Expand Up @@ -75,45 +75,51 @@ const Nav = () => {
}

const Page = () => {
const { user } = useAuth()
const { user, status } = useAuth()
return (
<Flex
direction='column'
backgroundColor='default'
h={'100vh'}
css={{ userSelect: 'none' }}
>
<Nav />
<Flex
flex={1}
direction='column'
justifyContent='center'
alignItems='center'
>
<Flex
w='640px'
gap='xl'
direction='column'
justifyContent='center'
alignItems='center'
>
<Paper
direction='column'
p='2xl'
gap='2xl'
>
<Flex justifyContent='center'>
<IconAudiusLogoHorizontalColor />
</Flex>
{
user
? <Success />
: <ConnectDistributor />
}
</Paper>
<Support />
</Flex>
</Flex>
<Footer />
{status === Status.LOADING || status === Status.IDLE
? <></>
: <>
<Nav />
<Flex
flex={1}
direction='column'
justifyContent='center'
alignItems='center'
>
<Flex
w='640px'
gap='xl'
direction='column'
justifyContent='center'
alignItems='center'
>
<Paper
direction='column'
p='2xl'
gap='2xl'
>
<Flex justifyContent='center'>
<IconAudiusLogoHorizontalColor />
</Flex>
{
user
? <Success />
: <ConnectDistributor />
}
</Paper>
<Support />
</Flex>
</Flex>
<Footer />
</>
}
</Flex>
)
}
Expand All @@ -122,11 +128,9 @@ export const App = () => {
return (
<HarmonyThemeProvider theme='day'>
<QueryClientProvider client={queryClient}>
<AudiusSdkProvider>
<AuthProvider>
<Page />
</AuthProvider>
</AudiusSdkProvider>
<AuthProvider>
<Page />
</AuthProvider>
</QueryClientProvider>
</HarmonyThemeProvider>
)
Expand Down
5 changes: 3 additions & 2 deletions packages/ddex/entrypoint/src/components/DistributorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
} from '@tanstack/react-query'
import { sdk } from '@audius/sdk'
import { Flex, IconEmbed, Text } from "@audius/harmony"
import { useSdk } from '../contexts/AudiusSdkProvider'
import { useSdk } from '../hooks/useSdk'
import { useCallback } from 'react'
import { Status } from '../contexts/types'

Expand All @@ -18,7 +18,7 @@ export const DistributorCard = ({
appKey,
url
}: DistributorCardProps) => {
const {sdk: audiusSdk, status} = useSdk()
const {sdk: audiusSdk } = useSdk()

const { data } = useQuery({
queryKey: ['todos'],
Expand Down Expand Up @@ -92,6 +92,7 @@ export const DistributorCard = ({
variant='body'
size='s'
color='default'
textAlign='center'
>
{data?.name ?? ''}
</Text>
Expand Down
3 changes: 0 additions & 3 deletions packages/ddex/entrypoint/src/components/RequestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ export const RequestCard = () => {
p='s'
w='136px'
h='136px'
css={{
cursor: 'pointer'
}}
>
<Text
variant='body'
Expand Down
45 changes: 0 additions & 45 deletions packages/ddex/entrypoint/src/contexts/AudiusSdkProvider.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions packages/ddex/entrypoint/src/contexts/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { User } from '@audius/sdk'
import { ReactNode, createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { useSdk } from './AudiusSdkProvider'
import { ReactNode, createContext, useCallback, useContext, useEffect, useState } from 'react'
import { useSdk } from '../hooks/useSdk'
import { Status } from './types'

type AuthContext = {
Expand All @@ -25,12 +25,14 @@ export const AuthProvider = ({ children }: { children: ReactNode}) => {
if (sdk) {
const fn = async () => {
try {
setStatus(Status.LOADING)
const urlParams = new URLSearchParams(window.location.search)
let token = localStorage.getItem(tokenLocalStorageKey)
if (!token) {
token = urlParams.get('token')
}
if (!token) {
setStatus(Status.SUCCESS)
return
}
const tokenRes = await sdk?.users.verifyIDToken({ token })
Expand Down
7 changes: 6 additions & 1 deletion packages/ddex/entrypoint/src/distributors/stage.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"distributors": []
"distributors": [
{
"appKey": "0x49d5e13d355709b615b7cce7369174fb240b6b39",
"url": "https://audius-ddex.staging.audius.co"
}
]
}
17 changes: 17 additions & 0 deletions packages/ddex/entrypoint/src/hooks/useSdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { DiscoveryNodeSelector, productionConfig, sdk, stagingConfig } from '@audius/sdk'

const env = import.meta.env.VITE_ENVIRONMENT as 'dev' | 'stage' | 'prod'

const config = env === 'prod' ? productionConfig : stagingConfig
const discoveryNodeSelector = new DiscoveryNodeSelector({
bootstrapServices: config.discoveryNodes,
})

const instance = sdk({
appName: 'ddex',
services: {
discoveryNodeSelector
}
})

export const useSdk = () => ({ sdk: instance })
20 changes: 10 additions & 10 deletions packages/ddex/processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
"@audius/sdk": "*",
"@aws-sdk/client-s3": "3.504.0",
"@aws-sdk/credential-provider-ini": "3.556.0",
"@hono/node-server": "^1.10.0",
"better-sqlite3": "^9.5.0",
"cheerio": "^1.0.0-rc.12",
"commander": "^12.0.0",
"decompress": "^4.2.1",
"@hono/node-server": "1.10.0",
"better-sqlite3": "9.5.0",
"cheerio": "1.0.0-rc.12",
"commander": "12.0.0",
"decompress": "4.2.1",
"dotenv": "16.3.1",
"file-type": "^19.0.0",
"hono": "^4.2.5",
"file-type": "19.0.0",
"hono": "4.2.5",
"web3": "4.3.0"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.9",
"@types/decompress": "^4.2.7",
"@types/better-sqlite3": "7.6.9",
"@types/decompress": "4.2.7",
"@types/node": "20.11.10",
"@typescript-eslint/eslint-plugin": "6.17.0",
"@typescript-eslint/parser": "6.17.0",
Expand All @@ -42,6 +42,6 @@
"prettier": "3.1.1",
"tsx": "4.7.2",
"typescript": "5.3.3",
"vitest": "^1.5.0"
"vitest": "1.5.0"
}
}
3 changes: 0 additions & 3 deletions scripts/install-git-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ git secrets --add "AIza[0-9A-Za-z\\-_]{35}"
# Google Drive OAuth
git secrets --add "[0-9]+-[0-9A-Za-z_]{32}\\.apps\\.googleusercontent\\.com"

# Google (GCP) Service-account
git secrets --add "\"type\": \"service_account\""

# Google Gmail API Key
git secrets --add "AIza[0-9A-Za-z\\-_]{35}"

Expand Down

0 comments on commit ca8133d

Please sign in to comment.