Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Commit

Permalink
Update to use new internal api
Browse files Browse the repository at this point in the history
Co-authored-by: Nathan Flurry <[email protected]>
  • Loading branch information
yusufsallam64 and NathanFlurry committed Oct 8, 2023
1 parent c7bb013 commit 9effe19
Show file tree
Hide file tree
Showing 22 changed files with 1,383 additions and 1,401 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ This will open `http://localhost:5080` in your browser. By default, this will co
>
> See our backend repo [here](https://github.com/rivet-gg/rivet).
### Configuration `BASE_URL`
### Configuration `RIVET_ORIGIN_API`

To configure the hub to connect to your own server (for example, `mydomain.com`), update the `.env` file in this folder to include the following:

```
BASE_URL=https://mydomain.com
RIVET_ORIGIN_API=https://mydomain.com
```

### Backend configuration
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@aws-sdk/abort-controller": "3.78.0",
"@aws-sdk/protocol-http": "3.78.0",
"@rivet-gg/api-internal": "0.0.1-3770bf8",
"@rivet-gg/api-internal": "0.0.1-698a6aa",
"@rivet-gg/auth": "file:gen/api-auth",
"@rivet-gg/chat": "file:gen/api-chat",
"@rivet-gg/cloud": "file:gen/api-cloud",
Expand Down Expand Up @@ -74,7 +74,7 @@
"style-loader": "^2.0.0",
"tailwindcss": "^3.3.3",
"ts-loader": "^8.0.15",
"typescript": "^4.6.1-rc",
"typescript": "^5.2.2",
"uuid": "^8.3.2",
"webpack": "^5.21.2",
"webpack-bundle-analyzer": "^4.5.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/copy-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for api in auth chat cloud group identity kv party portal; do

echo
echo "> Copying $path"
(cp -r ../backend-ee/gen/svc/api-$api/smithy/typescript/ $path || cp -r ../backend-ee/gen/svc/api-$api/openapi/typescript/ $path)
(cp -r ../../rivet/gen/svc/api-$api/smithy/typescript/ $path || cp -r ../../rivet/gen/svc/api-$api/openapi/typescript/ $path)
done

./scripts/build-libs.sh
Expand Down
26 changes: 13 additions & 13 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Provide default env if env variable is not defined. Any uses of `ENV.ABC` will be
// overridden because of the WebPack `DefinePlugin`, so these act as defaults.

const BASE_URL = localStorage.BASE_URL || ENV_BASE_URL;
const RIVET_ORIGIN_API = localStorage.RIVET_ORIGIN_API || ENV_RIVET_ORIGIN_API;

const config = {
RIVET_NAMESPACE: ENV_RIVET_NAMESPACE,
Expand All @@ -13,22 +13,22 @@ const config = {
GIT_COMMIT: ENV_GIT_COMMIT,
GIT_BRANCH: ENV_GIT_BRANCH,

BASE_URL: BASE_URL as string,
ORIGIN_API: RIVET_ORIGIN_API as string,
ASSETS_URL: ENV_ASSETS_URL as string,

MEDIA_URL: modifyBaseUrl(BASE_URL, 'media.'),
MEDIA_URL: RIVET_ORIGIN_API + "/media",

API_AUTH_URL: modifyBaseUrl(BASE_URL, 'auth.api.', '/v1'),
API_PORTAL_URL: modifyBaseUrl(BASE_URL, 'portal.api.', '/v1'),
API_IDENTITY_URL: modifyBaseUrl(BASE_URL, 'identity.api.', '/v1'),
API_GROUP_URL: modifyBaseUrl(BASE_URL, 'group.api.', '/v1'),
API_CHAT_URL: modifyBaseUrl(BASE_URL, 'chat.api.', '/v1'),
API_CLOUD_URL: modifyBaseUrl(BASE_URL, 'cloud.api.', '/v1'),
API_KV_URL: modifyBaseUrl(BASE_URL, 'kv.api.', '/v1'),
API_PARTY_URL: modifyBaseUrl(BASE_URL, 'party.api.', '/v1'),
API_AUTH_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'auth.', '/v1'),
API_PORTAL_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'portal.', '/v1'),
API_IDENTITY_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'identity.', '/v1'),
API_GROUP_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'group.', '/v1'),
API_CHAT_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'chat.', '/v1'),
API_CLOUD_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'cloud.', '/v1'),
API_KV_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'kv.', '/v1'),
API_PARTY_URL: modifyBaseUrl(RIVET_ORIGIN_API, 'party.', '/v1'),

COMMUNITY_URL: 'https://discord.gg/MskhvCXPEh',
DOCUMENTATION_URL: 'https://docs.rivet.gg',
COMMUNITY_URL: 'https://discord.com/invite/aXYfyNxYVn',
DOCUMENTATION_URL: 'https://rivet.gg/docs',

THUMBNAIL_MEDIA_SIZE: { width: 640, height: 480 },
LARGE_BANNER_SIZE: { width: 768, height: 432 },
Expand Down
55 changes: 27 additions & 28 deletions src/elements/common/file-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import timing from '../../utils/timing';
import { classMap } from 'lit/directives/class-map.js';
import { styleMap } from 'lit/directives/style-map.js';
import { bodyEventGroups } from '../../utils/global-events';
import * as cloud from '@rivet-gg/cloud';
import { Rivet } from '@rivet-gg/api-internal';
import logging from '../../utils/logging';
import utils, { Deferred } from '../../utils/utils';
import { showAlert } from '../../ui/helpers';

export interface FileInput {
path: string;
prepared: cloud.UploadPrepareFile;
prepared: Rivet.cloud.UploadPrepareFile;
fileHandle: File;
}

Expand All @@ -25,7 +25,7 @@ export interface PrepareResponse {
}

export interface PreparedFile {
presignedRequest: cloud.UploadPresignedRequest;
presignedRequest: Rivet.upload.PresignedRequest;
input: FileInput;
}

Expand Down Expand Up @@ -325,8 +325,8 @@ export default class FileUploader extends LitElement {
? this.uploadState.type == 'uploading'
? this.uploadState.progress / this.uploadState.total
: this.uploadState.type == 'completing'
? 1
: 0
? 1
: 0
: 0;

// Separate file type from current upload
Expand All @@ -346,8 +346,8 @@ export default class FileUploader extends LitElement {
let accept = this.video
? 'video/mp4,video/x-m4v,video/*'
: this.image
? 'image/*'
: this.accept ?? null;
? 'image/*'
: this.accept ?? null;

return html`
<div id="base" @drop=${this.onChange.bind(this)} @dragover=${(e: Event) => e.preventDefault()}>
Expand All @@ -356,54 +356,53 @@ export default class FileUploader extends LitElement {
<slot name="icon"></slot>
<slot name="content"></slot>
${when(
this.uploadError,
() =>
html`<h3 id="error">
this.uploadError,
() =>
html`<h3 id="error">
${when(
typeof this.uploadError == 'string',
() => this.uploadError,
() => html`Error while uploading. Please try again.</h3>`
)}
typeof this.uploadError == 'string',
() => this.uploadError,
() => html`Error while uploading. Please try again.</h3>`
)}
</h3>`
)}
)}
</div>
${uploading
? html` <div id="upload">
? html` <div id="upload">
<div id="upload-background" style=${loadingBarStyles}></div>
<div id="upload-content">
${this.uploadState.type == 'preparing'
? html` <h1>
? html` <h1>
Preparing ${this.uploadState.count}
file${this.uploadState.count == 1 ? '' : 's'}...
</h1>
<div id="progress-area">
<loading-bar .progress=${0}></loading-bar>
</div>`
: null}
: null}
${this.uploadState.type == 'uploading'
? html`
? html`
<h1>Uploading...</h1>
<h2><span id='upload-name'>${currentUpload[0].repeat(2)}</span id='upload-type'><span>${
currentUpload[1]
}</span></h2>
<h2><span id='upload-name'>${currentUpload[0].repeat(2)}</span id='upload-type'><span>${currentUpload[1]
}</span></h2>
<div id='progress-area'>
<loading-bar .progress=${progress}></loading-bar>
<h3>${this.uploadState.progress}/${this.uploadState.total}</h3>
</div>`
: null}
: null}
${this.uploadState.type == 'completing'
? html` <h1>Completing upload...</h1>
? html` <h1>Completing upload...</h1>
<div id="progress-area">
<loading-bar .progress=${1}></loading-bar>
</div>`
: null}
: null}
</div>
</div>`
: null}
: null}
${this.dragActive && !uploading
? html` <div id="overlay">Drag and drop files here</div>`
: null}
? html` <div id="overlay">Drag and drop files here</div>`
: null}
</label>
<input
id="file-upload"
Expand Down
28 changes: 14 additions & 14 deletions src/elements/common/namespace-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html, LitElement, TemplateResult } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { cssify } from '../../utils/css';
import styles from './namespace-dropdown.scss';
import cloud from '@rivet-gg/cloud';
import { Rivet } from '@rivet-gg/api-internal';
import routes from '../../routes';
import clsx from 'clsx';

Expand All @@ -11,10 +11,10 @@ export default class RichEmbed extends LitElement {
static styles = cssify(styles);

@property({ type: Object })
game: cloud.GameFull;
game: Rivet.cloud.GameFull;

@property({ type: Object })
currentNamespace: cloud.NamespaceSummary;
currentNamespace: Rivet.cloud.NamespaceSummary;

@property({ type: Boolean })
expanded: boolean;
Expand All @@ -24,22 +24,22 @@ export default class RichEmbed extends LitElement {
return this.expanded;
}

renderNamespaceListEntry(namespace: cloud.NamespaceSummary, isCurrent: boolean): TemplateResult {
renderNamespaceListEntry(namespace: Rivet.cloud.NamespaceSummary, isCurrent: boolean): TemplateResult {
return html`
<a
class="pt-3 last:pb-3 transition-all first:border-t-[1px] border-zinc-800 first:aria-expanded:border-zinc-600/80 group text-sm text-gray-200 hover:text-white flex flex-row place-content-around"
href=${routes.devNamespace.build({
gameId: this.game.gameId,
namespaceId: namespace.namespaceId
})}
gameId: this.game.gameId,
namespaceId: namespace.namespaceId
})}
aria-expanded=${this.expanded}
>
<div class=${clsx(isCurrent ? 'font-bold text-white' : '', 'mr-auto')}>
${namespace.displayName}
</div>
<!-- ${isCurrent
? html` <e-svg src="regular/check" class="mb-[2px] h-full" preserve></e-svg> `
: html``} -->
? html` <e-svg src="regular/check" class="mb-[2px] h-full" preserve></e-svg> `
: html``} -->
</a>
`;
}
Expand Down Expand Up @@ -85,11 +85,11 @@ export default class RichEmbed extends LitElement {
aria-expanded=${this.expanded}
>
${this.game.namespaces.map(namespace => {
return this.renderNamespaceListEntry(
namespace,
namespace.namespaceId === this.currentNamespace.namespaceId
);
})}
return this.renderNamespaceListEntry(
namespace,
namespace.namespaceId === this.currentNamespace.namespaceId
);
})}
</ul>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions src/elements/dev/version/ext.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import * as cloud from '@rivet-gg/api-internal/api/resources/cloud';
import { Rivet } from '@rivet-gg/api-internal';

export interface MatchmakerConfigExt {
config: cloud.version.matchmaker.Config;
config: Rivet.cloud.version.matchmaker.Config;
gameModes: GameModeExt[];
docker: GameModeRuntimeDockerExt;
}

export interface GameModeExt {
nameId: string;
gameMode: cloud.version.matchmaker.gameMode.GameMode;
gameMode: Rivet.cloud.version.matchmaker.gameMode.GameMode;
regions: GameModeRegionExt[];
}

export interface GameModeRegionExt {
nameId: string;
region: cloud.version.matchmaker.gameMode.GameModeRegion;
region: Rivet.cloud.version.matchmaker.gameMode.GameModeRegion;
}

export interface GameModeRuntimeDockerExt {
docker: cloud.version.matchmaker.gameMode.GameModeRuntimeDocker;
docker: Rivet.cloud.version.matchmaker.gameMode.GameModeRuntimeDocker;
env: { key: string; value: string }[];
ports: GameModeRuntimeDockerPortExt[];
}

export interface GameModeRuntimeDockerPortExt {
label: string;
port: cloud.version.matchmaker.gameMode.GameModeRuntimeDockerPort;
port: Rivet.cloud.version.matchmaker.gameMode.GameModeRuntimeDockerPort;
}
Loading

0 comments on commit 9effe19

Please sign in to comment.