Add actual deps, fly config, and more
This commit is contained in:
parent
ad0c0f6865
commit
6d7ffe6a25
10 changed files with 96 additions and 796 deletions
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# base node image
|
||||||
|
FROM node:16-bullseye-slim as base
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y openssl
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
RUN yarn install --production
|
||||||
|
|
||||||
|
ADD . .
|
||||||
|
|
||||||
|
CMD ["yarn", "start"]
|
|
@ -5,7 +5,7 @@ const plaid = require('plaid');
|
||||||
const { middleware: connectDb } = require('./db');
|
const { middleware: connectDb } = require('./db');
|
||||||
const { handleError } = require('./util/handle-error');
|
const { handleError } = require('./util/handle-error');
|
||||||
const { validateSubscribedUser } = require('./util/validate-user');
|
const { validateSubscribedUser } = require('./util/validate-user');
|
||||||
const config = require('./config');
|
const config = require('./load-config');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ let uuid = require('uuid');
|
||||||
let AdmZip = require('adm-zip');
|
let AdmZip = require('adm-zip');
|
||||||
let { validateUser } = require('./util/validate-user');
|
let { validateUser } = require('./util/validate-user');
|
||||||
let errorMiddleware = require('./util/error-middleware');
|
let errorMiddleware = require('./util/error-middleware');
|
||||||
let config = require('./config');
|
let config = require('./load-config');
|
||||||
let { getAccountDb } = require('./account-db');
|
let { getAccountDb } = require('./account-db');
|
||||||
|
|
||||||
let simpleSync = require('./sync-simple');
|
let simpleSync = require('./sync-simple');
|
||||||
|
|
10
app.js
10
app.js
|
@ -2,7 +2,7 @@ require('source-map-support').install();
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
const config = require('./config');
|
const config = require('./load-config');
|
||||||
|
|
||||||
const accountApp = require('./app-account');
|
const accountApp = require('./app-account');
|
||||||
const syncApp = require('./app-sync');
|
const syncApp = require('./app-sync');
|
||||||
|
@ -21,10 +21,16 @@ app.use(bodyParser.raw({ type: 'application/encrypted-file', limit: '50mb' }));
|
||||||
app.use('/sync', syncApp.handlers);
|
app.use('/sync', syncApp.handlers);
|
||||||
app.use('/account', accountApp.handlers);
|
app.use('/account', accountApp.handlers);
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/mode', (req, res) => {
|
||||||
res.send(config.mode);
|
res.send(config.mode);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The web frontend
|
||||||
|
app.use(express.static(__dirname + '/node_modules/@actual-app/web/build'));
|
||||||
|
app.get('/*', (req, res) => {
|
||||||
|
res.sendFile(__dirname + '/node_modules/@actual-app/web/build/index.html');
|
||||||
|
});
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
await accountApp.init();
|
await accountApp.init();
|
||||||
await syncApp.init();
|
await syncApp.init();
|
||||||
|
|
39
fly.toml
Normal file
39
fly.toml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
app = "actual-server"
|
||||||
|
|
||||||
|
kill_signal = "SIGINT"
|
||||||
|
kill_timeout = 5
|
||||||
|
processes = []
|
||||||
|
|
||||||
|
[env]
|
||||||
|
PORT = "8080"
|
||||||
|
|
||||||
|
[experimental]
|
||||||
|
allowed_public_ports = []
|
||||||
|
auto_rollback = true
|
||||||
|
|
||||||
|
[[services]]
|
||||||
|
http_checks = []
|
||||||
|
internal_port = 5006
|
||||||
|
processes = ["app"]
|
||||||
|
protocol = "tcp"
|
||||||
|
script_checks = []
|
||||||
|
|
||||||
|
[services.concurrency]
|
||||||
|
hard_limit = 25
|
||||||
|
soft_limit = 20
|
||||||
|
type = "connections"
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
force_https = true
|
||||||
|
handlers = ["http"]
|
||||||
|
port = 80
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
handlers = ["tls", "http"]
|
||||||
|
port = 443
|
||||||
|
|
||||||
|
[[services.tcp_checks]]
|
||||||
|
grace_period = "1s"
|
||||||
|
interval = "15s"
|
||||||
|
restart_limit = 0
|
||||||
|
timeout = "2s"
|
12
load-config.js
Normal file
12
load-config.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
let config;
|
||||||
|
try {
|
||||||
|
config = require('./config');
|
||||||
|
} catch (e) {
|
||||||
|
config = {
|
||||||
|
mode: 'development',
|
||||||
|
port: 5006,
|
||||||
|
files: './user-files'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config;
|
|
@ -8,7 +8,8 @@
|
||||||
"lint": "eslint --ignore-pattern '**/node_modules/*' --ignore-pattern '**/log/*' --ignore-pattern 'supervise' --ignore-pattern '**/shared/*' ."
|
"lint": "eslint --ignore-pattern '**/node_modules/*' --ignore-pattern '**/log/*' --ignore-pattern 'supervise' --ignore-pattern '**/shared/*' ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actual-app/api": "2.0.1",
|
"@actual-app/api": "^4.0.1",
|
||||||
|
"@actual-app/web": "^4.0.1",
|
||||||
"adm-zip": "^0.5.9",
|
"adm-zip": "^0.5.9",
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
"better-sqlite3": "^7.5.0",
|
"better-sqlite3": "^7.5.0",
|
||||||
|
|
|
@ -9,7 +9,6 @@ function validateUser(req, res) {
|
||||||
|
|
||||||
let db = getAccountDb();
|
let db = getAccountDb();
|
||||||
let rows = db.all('SELECT * FROM sessions WHERE token = ?', [token]);
|
let rows = db.all('SELECT * FROM sessions WHERE token = ?', [token]);
|
||||||
console.log(req.url, rows, token);
|
|
||||||
|
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
res.status(401);
|
res.status(401);
|
||||||
|
|
Loading…
Reference in a new issue