Add default config files and use it

This commit is contained in:
Alice Gaudon 2020-06-27 17:20:06 +02:00
parent dd7ea780ee
commit 34b0798fdf
10 changed files with 74 additions and 12 deletions

View File

@ -1,2 +1,43 @@
export default Object.assign(require("wms-core/config/default").default, { export default Object.assign(require("wms-core/config/default").default, {
app: {
name: 'Example App',
contact_email: 'noreply@example.net'
},
log_level: "DEV",
db_log_level: "ERROR",
public_url: "http://localhost:4899",
public_websocket_url: "ws://localhost:4899",
port: 4899,
gitlab_webhook_token: 'secret',
mysql: {
connectionLimit: 10,
host: "localhost",
user: "root",
password: "",
database: "wms2",
create_database_automatically: false
},
redis: {
host: "127.0.0.1",
port: 6379,
prefix: 'wms'
},
session: {
secret: "very_secret_not_known",
cookie: {
secure: false
}
},
mail: {
host: "127.0.0.1",
port: "1025",
secure: false,
username: "",
password: "",
allow_invalid_tls: true
},
view: {
cache: false
},
approval_mode: false,
}); });

View File

@ -1,2 +1,15 @@
export default Object.assign(require("wms-core/config/production").default, { export default Object.assign(require("wms-core/config/production").default, {
log_level: "DEBUG",
db_log_level: "ERROR",
public_url: "https://watch-my.stream",
public_websocket_url: "wss://watch-my.stream",
session: {
cookie: {
secure: true
}
},
mail: {
secure: true,
allow_invalid_tls: false
}
}); });

View File

@ -1,2 +1,9 @@
export default Object.assign(require("wms-core/config/test").default, { export default Object.assign(require("wms-core/config/test").default, {
mysql: {
host: "localhost",
user: "root",
password: "",
database: "wms2_test",
create_database_automatically: true
}
}); });

View File

@ -1,8 +1,8 @@
{ {
"name": "aldap", "name": "Example App",
"version": "0.1.0", "version": "0.1.0",
"description": "Authentication LDAP server", "description": "Example App based on wms-core",
"repository": "git@gitlab.com:ArisuOngaku/aldap.git", "repository": "git@gitlab.com:ArisuOngaku/wms-boilerplate.git",
"author": "Alice Gaudon <alice@gaudon.pro>", "author": "Alice Gaudon <alice@gaudon.pro>",
"private": true, "private": true,
"main": "dist/main.js", "main": "dist/main.js",

View File

@ -19,7 +19,7 @@ import WebSocketServerComponent from "wms-core/components/WebSocketServerCompone
import HomeController from "./controllers/HomeController"; import HomeController from "./controllers/HomeController";
import AutoUpdateComponent from "wms-core/components/AutoUpdateComponent"; import AutoUpdateComponent from "wms-core/components/AutoUpdateComponent";
export default class ExampleApp extends Application { export default class App extends Application {
private readonly port: number; private readonly port: number;
constructor(port: number) { constructor(port: number) {

View File

@ -1,8 +1,9 @@
import Logger from "wms-core/Logger"; import Logger from "wms-core/Logger";
import ExampleApp from "./ExampleApp"; import App from "./App";
import config from "config";
(async () => { (async () => {
const app = new ExampleApp(4899); const app = new App(config.get<number>('port'));
await app.start(); await app.start();
})().catch(err => { })().catch(err => {
Logger.error(err); Logger.error(err);

View File

@ -1,6 +1,6 @@
{% extends 'layouts/base.njk' %} {% extends 'layouts/base.njk' %}
{% set title = 'Example App - About us' %} {% set title = app.name + ' - About us' %}
{% block body %} {% block body %}
<h1>Very interesting</h1> <h1>Very interesting</h1>

View File

@ -7,7 +7,7 @@
{% endblock %} {% endblock %}
{% block _body %} {% block _body %}
<div class="logo"><a href="/">Example app</a></div> <div class="logo"><a href="/">{{ app.name }}</a></div>
<main class="{% block class %}{% endblock %}"> <main class="{% block class %}{% endblock %}">
{% if flash %} {% if flash %}
@ -31,6 +31,6 @@
Error ID: {{ error_id }} Error ID: {{ error_id }}
<br> <br>
If you think this isn't right, please contact us with the above error ID at If you think this isn't right, please contact us with the above error ID at
<a href="mailto:contact@example.net">contact@example.net</a>. <a href="mailto:{{ app.contact_email }}">{{ app.contact_email }}</a>.
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,6 +1,6 @@
{% extends 'layouts/base.njk' %} {% extends 'layouts/base.njk' %}
{% set title = 'Example App - Hello world!' %} {% set title = app.name + ' - Hello world!' %}
{% block body %} {% block body %}
<h1>Hello world!</h1> <h1>Hello world!</h1>

View File

@ -12,7 +12,7 @@
{% endblock %} {% endblock %}
{% block header %} {% block header %}
<a href="/" class="logo"><img src="/img/logo.svg" alt="Logo"> Example app</a> <a href="/" class="logo"><img src="/img/logo.svg" alt="Logo"> {{ app.name }}</a>
<nav> <nav>
<ul> <ul>
<li><a href="{{ route('about') }}"><i data-feather="info"></i> About</a></li> <li><a href="{{ route('about') }}"><i data-feather="info"></i> About</a></li>
@ -37,4 +37,4 @@
</main> </main>
{% endblock %} {% endblock %}
{% block footer %}Example app v{{ app_version }} - all rights reserved.{% endblock %} {% block footer %}{{ app.name }} v{{ app_version }} - all rights reserved.{% endblock %}