Skip to content

Commit

Permalink
Merge pull request #83 from perimetre/dev
Browse files Browse the repository at this point in the history
Promoting dev
  • Loading branch information
AssisrMatheus authored Feb 1, 2022
2 parents 37acae9 + bc21fff commit 5ffb71d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.development
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Backend
NEXT_PUBLIC_GRAPHQL_URI="https://dev.api.marathon.perimetre.co/graphql"
NEXT_PUBLIC_GRAPHQL_URI="https://dev.api.marathon.perimetre.co/v1/status"
#NEXT_PUBLIC_GRAPHQL_URI="http://localhost:3001/graphql"
#NEXT_PUBLIC_STATUS_URI="http://localhost:3001/v1/status"

# Unity
NEXT_PUBLIC_UNITY_PUBLIC_FOLDER="unity"
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ARG NEXT_PUBLIC_DEFAULT_LOCALE
ENV NEXT_PUBLIC_DEFAULT_LOCALE=${NEXT_PUBLIC_DEFAULT_LOCALE}
ARG NEXT_PUBLIC_GRAPHQL_URI
ENV NEXT_PUBLIC_GRAPHQL_URI=${NEXT_PUBLIC_GRAPHQL_URI}
ARG NEXT_PUBLIC_STATUS_URI
ENV NEXT_PUBLIC_STATUS_URI=${NEXT_PUBLIC_STATUS_URI}
ARG NEXT_PUBLIC_UNITY_PUBLIC_FOLDER
ENV NEXT_PUBLIC_UNITY_PUBLIC_FOLDER=${NEXT_PUBLIC_UNITY_PUBLIC_FOLDER}
ARG NEXT_PUBLIC_UNITY_BUILD_NAME
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const env = () => {
NEXT_PUBLIC_DEFAULT_LOCALE: process.env.NEXT_PUBLIC_DEFAULT_LOCALE,
// Backend
NEXT_PUBLIC_GRAPHQL_URI: process.env.NEXT_PUBLIC_GRAPHQL_URI,
NEXT_PUBLIC_STATUS_URI: process.env.NEXT_PUBLIC_STATUS_URI,
// Unity
NEXT_PUBLIC_UNITY_PUBLIC_FOLDER: process.env.NEXT_PUBLIC_UNITY_PUBLIC_FOLDER,
NEXT_PUBLIC_UNITY_BUILD_NAME: process.env.NEXT_PUBLIC_UNITY_BUILD_NAME,
Expand Down
50 changes: 50 additions & 0 deletions src/pages/api/status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import env from '../../env';

type Data = {
name: string;
};

export default async function handler(req: NextApiRequest, res: NextApiResponse<Data>) {
const envs = env();
const { NEXT_PUBLIC_STATUS_URI } = envs;

const status: any = {
frontend: {
status: 'success'
}
};

if (NEXT_PUBLIC_STATUS_URI) {
try {
const backend = await fetch(NEXT_PUBLIC_STATUS_URI);
const result = await backend.json();
const text = JSON.stringify(result);
status.backend = {
status: text.indexOf('error') < 0 ? 'success' : 'warning',
result
};
} catch (error) {
// If failed
status.backend = {
status: 'failed',
error
};
}
}

status.env = {
NODE_ENV: envs.NODE_ENV,
NEXT_PUBLIC_STATUS_URI: process.env.NEXT_PUBLIC_STATUS_URI,
// Unity
NEXT_PUBLIC_UNITY_PUBLIC_FOLDER: envs.NEXT_PUBLIC_UNITY_PUBLIC_FOLDER,
// Unity player
NEXT_PUBLIC_UNITY_PUBLIC_MEDIA_URI: envs.NEXT_PUBLIC_UNITY_PUBLIC_MEDIA_URI,
NEXT_PUBLIC_UNITY_ASSET_BUNDLE_FOLDER: envs.NEXT_PUBLIC_UNITY_ASSET_BUNDLE_FOLDER,
NEXT_PUBLIC_UNITY_DEFAULT_PLATFORM: envs.NEXT_PUBLIC_UNITY_DEFAULT_PLATFORM,
NEXT_PUBLIC_UNITY_MODULE_MATERIALS_FOLDER: envs.NEXT_PUBLIC_UNITY_MODULE_MATERIALS_FOLDER,
NEXT_PUBLIC_UNITY_MANIFEST_ASSET_NAME: envs.NEXT_PUBLIC_UNITY_MANIFEST_ASSET_NAME
};

res.json(status);
}

0 comments on commit 5ffb71d

Please sign in to comment.