42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
/*
|
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
* This file is part of appreports which is released under GPL-3.0-or-later.
|
|
* See file 'LICENSE' for full license details.
|
|
* Created by Timo Hocker <timo@scode.ovh>, August 2020
|
|
*/
|
|
|
|
/* eslint-disable no-console */
|
|
// @ts-nocheck
|
|
'use strict';
|
|
|
|
const express = require ('express');
|
|
const body_parser = require ('body-parser');
|
|
const db = require ('./lib/db');
|
|
const api = require ('./lib/api');
|
|
const http_proxy = require ('express-http-proxy');
|
|
const history_fallback = require ('connect-history-api-fallback');
|
|
const { argv } = require ('yargs');
|
|
const version = require ('./version');
|
|
|
|
const is_dev = argv.dev;
|
|
|
|
console.log (`starting appreports build ${version}`);
|
|
|
|
(async () => {
|
|
await db.init (is_dev);
|
|
|
|
const app = express ();
|
|
app.use (body_parser.json ());
|
|
|
|
app.use (api);
|
|
app.use (history_fallback ());
|
|
if (is_dev)
|
|
app.use (http_proxy ('localhost:8080'));
|
|
else
|
|
app.use (express.static ('dist'));
|
|
|
|
app.listen (3000, () => {
|
|
console.log ('listening on 3000');
|
|
});
|
|
}) ();
|