generated from amattu2/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dynamic project configuration per environment (#64)
* feat: Dynamic project configuration per environment * feat: Dynamic page titles * Remove unused `manifest.json` * docs: Update docs for `.env` config
- Loading branch information
Showing
21 changed files
with
169 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
REACT_APP_NAME="" | ||
REACT_APP_DESCRIPTION="" | ||
REACT_APP_SLOGAN="" | ||
REACT_APP_API_URL="" | ||
REACT_APP_MEDIA_API_URL="" | ||
REACT_APP_MEDIA_CDN_URL="" | ||
REACT_APP_API_CLIENT="" |
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,4 +1,5 @@ | ||
{ | ||
"MD033": false, | ||
"MD025": false | ||
"MD025": false, | ||
"MD013": false | ||
} |
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 was deleted.
Oops, something went wrong.
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,3 +1,2 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const CONFIG: AppConfig = { | ||
name: process.env.REACT_APP_NAME || "React App", | ||
description: process.env.REACT_APP_DESCRIPTION || "", | ||
slogan: process.env.REACT_APP_SLOGAN || "", | ||
API_URL: process.env.REACT_APP_API_URL || "http://localhost:8080/", | ||
MEDIA_API_URL: process.env.REACT_APP_MEDIA_API_URL || "http://localhost:8081/", | ||
MEDIA_CDN_URL: process.env.REACT_APP_MEDIA_CDN_URL || "http://localhost:8082/", | ||
API_CLIENT: process.env.REACT_APP_API_CLIENT || "react-app", | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useEffect } from "react"; | ||
import { CONFIG } from "../config/AppConfig"; | ||
|
||
/** | ||
* Exposes a hook to set and restore the page title | ||
* | ||
* @param title The new title to set | ||
* @param [suffix] Include the application name suffix | ||
* @param [restore] Restore the title on unmount | ||
*/ | ||
const usePageTitle = (title: string, suffix: boolean = true, restore: boolean = true): void => { | ||
// Update title on mount | ||
useEffect(() => { | ||
document.title = suffix ? `${title} - ${CONFIG.name}` : title; | ||
}, [title]); | ||
|
||
// Revert on unmount if requested | ||
useEffect(() => { | ||
if (!restore) { | ||
return () => {}; | ||
} | ||
|
||
return () => document.title = CONFIG.name; | ||
}, []); | ||
}; | ||
|
||
export default usePageTitle; |
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,6 +1,11 @@ | ||
import React from "react"; | ||
import ForgotView from "./View"; | ||
import usePageTitle from "../../hooks/usePageTitle"; | ||
|
||
const ForgotController = () => <ForgotView />; | ||
const ForgotController = () => { | ||
usePageTitle("Forgot Password"); | ||
|
||
return (<ForgotView />); | ||
}; | ||
|
||
export default ForgotController; |
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,6 +1,11 @@ | ||
import React from "react"; | ||
import LoginView from "./View"; | ||
import usePageTitle from "../../hooks/usePageTitle"; | ||
|
||
const LoginController = () => <LoginView />; | ||
const LoginController = () => { | ||
usePageTitle("Login"); | ||
|
||
return <LoginView />; | ||
}; | ||
|
||
export default LoginController; |
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,6 +1,11 @@ | ||
import React from "react"; | ||
import RegisterView from "./View"; | ||
import usePageTitle from "../../hooks/usePageTitle"; | ||
|
||
const RegisterController = () => <RegisterView />; | ||
const RegisterController = () => { | ||
usePageTitle("Register"); | ||
|
||
return (<RegisterView />); | ||
}; | ||
|
||
export default RegisterController; |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* The strict type definition for the Application configuration | ||
*/ | ||
type AppConfig = { | ||
/** | ||
* The name of the application | ||
* | ||
* Used by: | ||
* - Page titles | ||
* - Auth page banners | ||
* - etc | ||
*/ | ||
name: string; | ||
/** | ||
* The HTML meta description of the application | ||
* | ||
* Used by: | ||
* - *Nothing yet* | ||
*/ | ||
description: string; | ||
/** | ||
* The slogan of the application | ||
* | ||
* Visible under the name in the header. | ||
*/ | ||
slogan: string; | ||
/** | ||
* The base URL for the API server | ||
* | ||
* NOTE: Should end with a trailing slash | ||
*/ | ||
API_URL: string; | ||
/** | ||
* The base URL for the media API server | ||
* | ||
* NOTE: Should end with a trailing slash | ||
*/ | ||
MEDIA_API_URL: string; | ||
/** | ||
* The base URL for the media CDN server | ||
*/ | ||
MEDIA_CDN_URL: string; | ||
/** | ||
* The name of the client passed in the `client` property of | ||
* a new Feed Post | ||
*/ | ||
API_CLIENT: string; | ||
}; |