Skip to content

Commit

Permalink
Add actual deps, fly config, and more
Browse files Browse the repository at this point in the history
  • Loading branch information
jlongster committed Apr 29, 2022
1 parent ad0c0f6 commit 6d7ffe6
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 796 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion app-plaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const plaid = require('plaid');
const { middleware: connectDb } = require('./db');
const { handleError } = require('./util/handle-error');
const { validateSubscribedUser } = require('./util/validate-user');
const config = require('./config');
const config = require('./load-config');

const app = express();

Expand Down
2 changes: 1 addition & 1 deletion app-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let uuid = require('uuid');
let AdmZip = require('adm-zip');
let { validateUser } = require('./util/validate-user');
let errorMiddleware = require('./util/error-middleware');
let config = require('./config');
let config = require('./load-config');
let { getAccountDb } = require('./account-db');

let simpleSync = require('./sync-simple');
Expand Down
10 changes: 8 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require('source-map-support').install();
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const config = require('./config');
const config = require('./load-config');

const accountApp = require('./app-account');
const syncApp = require('./app-sync');
Expand All @@ -21,10 +21,16 @@ app.use(bodyParser.raw({ type: 'application/encrypted-file', limit: '50mb' }));
app.use('/sync', syncApp.handlers);
app.use('/account', accountApp.handlers);

app.get('/', (req, res) => {
app.get('/mode', (req, res) => {
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() {
await accountApp.init();
await syncApp.init();
Expand Down
39 changes: 39 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions load-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let config;
try {
config = require('./config');
} catch (e) {
config = {
mode: 'development',
port: 5006,
files: './user-files'
};
}

module.exports = config;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"lint": "eslint --ignore-pattern '**/node_modules/*' --ignore-pattern '**/log/*' --ignore-pattern 'supervise' --ignore-pattern '**/shared/*' ."
},
"dependencies": {
"@actual-app/api": "2.0.1",
"@actual-app/api": "^4.0.1",
"@actual-app/web": "^4.0.1",
"adm-zip": "^0.5.9",
"bcrypt": "^5.0.1",
"better-sqlite3": "^7.5.0",
Expand Down
1 change: 0 additions & 1 deletion util/validate-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function validateUser(req, res) {

let db = getAccountDb();
let rows = db.all('SELECT * FROM sessions WHERE token = ?', [token]);
console.log(req.url, rows, token);

if (rows.length === 0) {
res.status(401);
Expand Down
Loading

0 comments on commit 6d7ffe6

Please sign in to comment.