Przeglądaj źródła

Atlas-meta-server v1.3.0

update atlas-meta-server for Orion v2
attemka 1 rok temu
rodzic
commit
d10292c518

+ 1 - 1
packages/atlas-meta-server/.env

@@ -1,5 +1,5 @@
 # This file is committed. Do not store secrets here
 
-APP_URL=https://play.joystream.org
+APP_URL=https://gleev.xyz
 # ORION_URL is used only for generating queries code, in runtime, Orion URL is fetched from index.html
 ORION_URL=https://orion.joystream.org/graphql

+ 1 - 2
packages/atlas-meta-server/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@joystream/atlas-meta-server",
-  "version": "1.2.1",
+  "version": "1.3.0",
   "description": "Node server for pre rendering html meta tags",
   "license": "GPL-3.0",
   "scripts": {
@@ -9,7 +9,6 @@
     "graphql": "rimraf src/api/__generated__ && graphql-codegen --config codegen.config.yml -r dotenv/config"
   },
   "dependencies": {
-    "bn.js": "^5.2.1",
     "cross-fetch": "^3.1.5",
     "date-fns": "^2.29.3",
     "dotenv": "^16.0.3",

Plik diff jest za duży
+ 7661 - 34225
packages/atlas-meta-server/src/api/__generated__/sdk.ts


+ 4 - 4
packages/atlas-meta-server/src/api/index.ts

@@ -18,12 +18,12 @@ export class OrionClient {
   }
 
   async getVideo(id: string) {
-    const { videoByUniqueInput } = await this.sdk.GetVideo({ id })
-    return videoByUniqueInput
+    const { videoById } = await this.sdk.GetVideo({ id })
+    return videoById
   }
 
   async getChannel(id: string) {
-    const { channelByUniqueInput } = await this.sdk.GetChannel({ id })
-    return channelByUniqueInput
+    const { channelById } = await this.sdk.GetChannel({ id })
+    return channelById
   }
 }

+ 5 - 14
packages/atlas-meta-server/src/api/queries.graphql

@@ -1,15 +1,6 @@
 fragment DataObjectFields on StorageDataObject {
   id
-  storageBag {
-    distributionBuckets {
-      distributing
-      operators {
-        metadata {
-          nodeEndpoint
-        }
-      }
-    }
-  }
+  resolvedUrls
 }
 
 fragment BasicChannelFields on Channel {
@@ -50,8 +41,8 @@ query TestQuery {
   }
 }
 
-query GetChannel($id: ID!) {
-  channelByUniqueInput(where: { id: $id }) {
+query GetChannel($id: String!) {
+  channelById(id: $id) {
     ...BasicChannelFields
     avatarPhoto {
       ...DataObjectFields
@@ -59,8 +50,8 @@ query GetChannel($id: ID!) {
   }
 }
 
-query GetVideo($id: ID!) {
-  videoByUniqueInput(where: { id: $id }) {
+query GetVideo($id: String!) {
+  videoById(id: $id) {
     ...BasicVideoFields
     thumbnailPhoto {
       ...DataObjectFields

+ 1 - 16
packages/atlas-meta-server/src/utils.ts

@@ -1,31 +1,16 @@
-import BN from 'bn.js'
 import fetch from 'cross-fetch'
 import parseHtml, { HTMLElement } from 'node-html-parser'
 
 import { DataObjectFieldsFragment } from './api/__generated__/sdk'
 import { AppData, MetaTags } from './types'
 
-const DISTRIBUTOR_ASSET_PATH = 'api/v1/assets'
-
 export const joinUrlFragments = (...fragments: string[]) => {
   const strippedFragments = fragments.map((f) => f.replace(/^\/|\/$/, ''))
   return strippedFragments.join('/')
 }
 
 export const generateAssetUrl = (asset: DataObjectFieldsFragment) => {
-  const workingBuckets = asset.storageBag.distributionBuckets.filter((bucket) => bucket.distributing)
-  const distributorsEndpoints = workingBuckets.reduce((acc, bucket) => {
-    const endpoints = bucket.operators
-      .filter((operator) => !!operator.metadata?.nodeEndpoint)
-      .map((operator) => operator.metadata?.nodeEndpoint) as string[]
-    return [...acc, ...endpoints]
-  }, [] as string[])
-
-  const assetIdBn = new BN(asset.id)
-  const endpointsCountBn = new BN(distributorsEndpoints.length)
-  const distributorIndex = assetIdBn.mod(endpointsCountBn).toNumber()
-  const endpoint = distributorsEndpoints[distributorIndex]
-  return joinUrlFragments(endpoint, DISTRIBUTOR_ASSET_PATH, asset.id)
+  return asset.resolvedUrls[0]
 }
 
 export const getEnvVariable = (varName: string, required?: boolean) => {

+ 0 - 1
yarn.lock

@@ -3525,7 +3525,6 @@ __metadata:
     "@graphql-codegen/typescript-graphql-request": ^4.5.8
     "@graphql-codegen/typescript-operations": ^2.5.10
     "@types/express": ^4.17.14
-    bn.js: ^5.2.1
     cross-fetch: ^3.1.5
     date-fns: ^2.29.3
     dotenv: ^16.0.3

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików