Browse Source

make static file serving more sensible in app.js

Signed-off-by: Dušan Mitrović <dusan@dusanmitrovic.xyz>
master
Dušan Mitrović 2 months ago
parent
commit
8a7d63f2f3
Signed by: dusan GPG Key ID: 8ADCE8E1BC42EB06
1 changed files with 13 additions and 9 deletions
  1. +13
    -9
      app.js

+ 13
- 9
app.js View File

@@ -17,14 +17,14 @@ const express = require('express');
const expressHandlebars = require('express-handlebars');
const handlebarsConfig = require('./config/handlebars');
const methodOverride = require('method-override');
const { dirname } = require('path');
const {dirname} = require('path');
const session = require('./config/session');
const passSessionToHandlebars = require('./middleware/session');
const notFoundHandler = require('./middleware/404-handler');
const knex = require('./db/connection');
const { Model } = require('objection');
const {Model} = require('objection');
const https = require('https');
const { readFileSync } = require('fs');
const {readFileSync} = require('fs');

// Defined routes
const home = require('./routes/home');
@@ -36,12 +36,16 @@ const images = require('./routes/images');

const app = express();

parseInt(process.env.SERVE_STATIC_FILES_WITH_NGINX)
? null
: app.use(
'/static',
express.static(dirname(require.main.filename) + '/static/')
);
serveStaticFilesWithNginx = parseInt(process.env.SERVE_STATIC_FILES_WITH_NGINX)
if (
Number.isNaN(serveStaticFilesWithNginx) ||
serveStaticFilesWithNginx <= 0
) {
app.use(
'/static',
express.static(dirname(require.main.filename) + '/static/')
);
}

// Redis session
app.use(session);


Loading…
Cancel
Save