49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
// @ts-nocheck
|
|
'use strict';
|
|
|
|
const express = require ('express');
|
|
const auth = require ('@sapphirecode/auth-server-helper');
|
|
const body_parser = require ('body-parser');
|
|
const cookie_parser = require ('cookie-parser');
|
|
const db = require ('./lib/db');
|
|
const crypto = require ('@sapphirecode/crypto-helper');
|
|
const password_helper = require ('@sapphirecode/password-helper');
|
|
const api = require ('./lib/api');
|
|
const http_proxy = require ('express-http-proxy');
|
|
const history_fallback = require ('connect-history-api-fallback');
|
|
const fs = require ('fs');
|
|
|
|
const salt = crypto.create_salt ();
|
|
const hash = crypto.hash_sha512 ('asd', salt);
|
|
|
|
const user = {
|
|
id: 0,
|
|
salt,
|
|
password: password_helper.hash (hash)
|
|
};
|
|
|
|
(async () => {
|
|
fs.unlinkSync ('db.sqlite');
|
|
await db.init (true);
|
|
|
|
const app = express ();
|
|
app.use (cookie_parser ());
|
|
app.use (body_parser.json ());
|
|
|
|
/*
|
|
* app.use (auth ((name) => {
|
|
*if (name === 'timo')
|
|
* return user;
|
|
*return null;
|
|
*}));
|
|
*/
|
|
|
|
app.use (api);
|
|
app.use (history_fallback ());
|
|
app.use (http_proxy ('localhost:8080'));
|
|
|
|
app.listen (3000, () => {
|
|
console.log ('listening on 3000');
|
|
});
|
|
}) ();
|