Added compile time attributes to config class
This commit is contained in:
parent
12a0eee216
commit
87f6f48b32
|
@ -7,8 +7,6 @@ POSTGRES_PASSWORD=
|
|||
|
||||
# Backend
|
||||
BACKEND_URL=URL
|
||||
BACKEND_ADMIN_EMAIL=
|
||||
BACKEND_ADMIN_PASSWORD=
|
||||
# Backend - API
|
||||
BACKEND_API_GRAPHQL_PLAYGROUND=false
|
||||
BACKEND_JWT_SECRET=
|
||||
|
|
|
@ -11,7 +11,7 @@ module Backend
|
|||
|
||||
def draw_routes : Nil
|
||||
# enable graphql playground when in development mode or explicitly enabled
|
||||
if Backend.config.api.graphql_playground || {{ flag?(:development) }}
|
||||
if Backend.config.api.graphql_playground_fully_enabled
|
||||
Log.info { "GraphQL playground enabled" }
|
||||
|
||||
get "/" do |context|
|
||||
|
|
|
@ -13,6 +13,23 @@ module Backend
|
|||
class Config
|
||||
include EnvConfig
|
||||
|
||||
enum BuildEnv
|
||||
Development
|
||||
Production
|
||||
end
|
||||
|
||||
def development : Bool
|
||||
{{ flag?(:development) }}
|
||||
end
|
||||
|
||||
def production : Bool
|
||||
!development
|
||||
end
|
||||
|
||||
def build_env : BuildEnv
|
||||
development ? BuildEnv::Development : BuildEnv::Production
|
||||
end
|
||||
|
||||
getter url : String
|
||||
|
||||
@[EnvConfig::Setting(key: "api")]
|
||||
|
@ -32,6 +49,10 @@ module Backend
|
|||
|
||||
getter graphql_playground : Bool
|
||||
getter jwt_secret : String
|
||||
|
||||
def graphql_playground_fully_enabled : Bool
|
||||
Backend.config.development || graphql_playground
|
||||
end
|
||||
end
|
||||
|
||||
class WorkerConfig
|
||||
|
|
|
@ -5,8 +5,6 @@ import Router from "next/router";
|
|||
import * as cookieNames from "../lib/cookieNames";
|
||||
|
||||
function Navbar(): JSX.Element {
|
||||
const isLoggedIn = !!Cookies.get(cookieNames.TOKEN);
|
||||
|
||||
function handleLogout(event: Event): void {
|
||||
event.preventDefault();
|
||||
Cookies.remove(cookieNames.TOKEN);
|
||||
|
@ -17,7 +15,7 @@ function Navbar(): JSX.Element {
|
|||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
{isLoggedIn ? (
|
||||
{!!Cookies.get(cookieNames.TOKEN) ? (
|
||||
<button onClick={handleLogout as any}>Logout</button>
|
||||
) : (
|
||||
<Link href="/login" passHref>
|
||||
|
|
Loading…
Reference in a new issue