AppReports/index.js

42 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2020-08-19 12:33:09 +02:00
/*
* 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 */
2020-07-29 20:56:03 +02:00
// @ts-nocheck
'use strict';
const express = require ('express');
const body_parser = require ('body-parser');
const db = require ('./lib/db');
2020-07-29 21:13:18 +02:00
const api = require ('./lib/api');
const http_proxy = require ('express-http-proxy');
2020-07-30 18:39:37 +02:00
const history_fallback = require ('connect-history-api-fallback');
2020-08-22 10:43:35 +02:00
const { argv } = require ('yargs');
const version = require ('./version');
2020-07-29 20:56:03 +02:00
2020-08-22 10:43:35 +02:00
const is_dev = argv.dev;
console.log (`starting appreports build ${version}`);
2020-07-29 20:56:03 +02:00
(async () => {
2020-08-22 10:43:35 +02:00
await db.init (is_dev);
2020-07-29 20:56:03 +02:00
const app = express ();
app.use (body_parser.json ());
2020-07-29 21:13:18 +02:00
app.use (api);
2020-07-30 18:39:37 +02:00
app.use (history_fallback ());
2020-08-22 10:43:35 +02:00
if (is_dev)
app.use (http_proxy ('localhost:8080'));
else
app.use (express.static ('dist'));
2020-07-29 21:13:18 +02:00
app.listen (3000, () => {
console.log ('listening on 3000');
});
2020-07-29 20:56:03 +02:00
}) ();