Skip to content

Commit

Permalink
Feature/separate server from site
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadsden authored Apr 26, 2021
2 parents 2b94784 + a8df2b1 commit 59f2a1f
Show file tree
Hide file tree
Showing 89 changed files with 1,397 additions and 1,240 deletions.
6 changes: 3 additions & 3 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
td/public/libs/
td/public/app/threatdragon.js
td/public/app/*.min.js
td.site/libs/
td.site/app/threatdragon.js
td.site/app/*.min.js
td.tests/
8 changes: 4 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'td/public/app/app.js',
'td.site/app/app.js',
'td.tests/clientspec/**/*.js',
'td/public/app/**/*.html'
'td.site/app/**/*.html'
],

// list of files to exclude
Expand All @@ -26,8 +26,8 @@ module.exports = function (config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'td/public/app/**/*.html': ['ng-html2js'],
'td/public/app/app.js': ['browserify'],
'td.site/app/**/*.html': ['ng-html2js'],
'td.site/app/app.js': ['browserify'],
'td.tests/clientspec/test.js': ['browserify']
},

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"private": false,
"scripts": {
"build": "npm run-script bundle && npm run-script bundle-minify && npm run-script bundle-css && npm run-script bundle-minify-css && npm run-script copy-fonts",
"build-templates": "browserify -t [browserify-ng-html2js --module templates] ./td/public/app/templates.build.js -o ./td/public/app/templates.js",
"copy-fonts": "./node_modules/.bin/copyfiles -f ./node_modules/font-awesome/fonts/*.* ./node_modules/bootstrap/dist/fonts/*.* ./td/public/fonts",
"bundle-css": "./node_modules/.bin/rework-npm ./td/public/content/app.css -o ./td/public/content/threatdragon.css",
"minify-css": "./node_modules/.bin/uglifycss ./td/public/content/threatdragon.css > ./td/public/content/threatdragon.min.css",
"build-templates": "browserify -t [browserify-ng-html2js --module templates] ./td.site/app/templates.build.js -o ./td.site/app/templates.js",
"copy-fonts": "./node_modules/.bin/copyfiles -f ./node_modules/font-awesome/fonts/*.* ./node_modules/bootstrap/dist/fonts/*.* ./td.site/fonts",
"bundle-css": "./node_modules/.bin/rework-npm ./td.site/content/app.css -o ./td.site/content/threatdragon.css",
"minify-css": "./node_modules/.bin/uglifycss ./td.site/content/threatdragon.css > ./td.site/content/threatdragon.min.css",
"bundle-minify-css": "npm run-script bundle-css && npm run-script minify-css",
"bundle": "browserify --debug ./td/public/app/app.js -o ./td/public/app/threatdragon.js",
"bundle-minify": "browserify ./td/public/app/app.js -d -p [minifyify --map ./td/public/app/threatdragon.js.map --output ./td/public/app/threatdragon.js.map ] > ./td/public/app/threatdragon.min.js",
"bundle": "browserify --debug ./td.site/app/app.js -o ./td.site/app/threatdragon.js",
"bundle-minify": "browserify ./td.site/app/app.js -d -p [minifyify --map ./td.site/app/threatdragon.js.map --output ./td.site/app/threatdragon.js.map ] > ./td.site/app/threatdragon.min.js",
"start": "node server.js",
"pretest": "node ./node_modules/jshint/bin/jshint --verbose --show-non-errors td",
"pretest": "node ./node_modules/jshint/bin/jshint --verbose --show-non-errors td.server td.site",
"test": "npm run-script test-client-firefox && npm run-script test-server",
"test-client-phantomjs": "./node_modules/.bin/karma start --single-run --browsers PhantomJS",
"test-client-firefox": "./node_modules/.bin/karma start --single-run --browsers Firefox",
"test-client-chrome": "./node_modules/.bin/karma start --single-run --browsers Chrome",
"test-client-ie": "./node_modules/.bin/karma start --single-run --browsers IE",
"test-server": "istanbul cover --include-all-sources -x public/** --root ./td/ --dir ./coverage/Server/ ./td.tests/serverspec/support/jasmine-runner.js",
"test-server": "istanbul cover --include-all-sources -x ./td.site --root ./td.server/ --dir ./coverage/Server/ ./td.tests/serverspec/support/jasmine-runner.js",
"test-local": "npm run-script pretest && npm run-script test-client-chrome && npm run-script test-client-ie && npm run-script test-client-phantomjs && npm run-script test-client-firefox && npm run-script test-server",
"citest": "./node_modules/.bin/karma start --single-run false --browsers Firefox",
"codecov": "./node_modules/.bin/codecov"
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var debug = require('debug')('OWASP Threat Dragon');
var app = require('./td/app');
var app = require('./td.server/app');

app.set('port', process.env.PORT || 3000);

Expand Down
8 changes: 5 additions & 3 deletions td/app.js → td.server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ var path = require('path');
var favicon = require('serve-favicon');
var bunyan = require('bunyan');

var upDir = '..' + path.sep;

try {
var app = express();
app.set('trust proxy', true);
app.set('views', './td/views');
app.set('views', path.join(__dirname, upDir, 'td.site', 'views'));
app.set('view engine', 'pug');

// environment configuration
require('./config/env.config').tryLoadDotEnv();

//static content
app.use('/public', express.static(path.join(__dirname, 'public')));
app.use('/public', express.static(path.join(__dirname, upDir, 'td.site')));

//security headers
require('./config/securityheaders.config')(app);
Expand All @@ -25,7 +27,7 @@ try {
require('./config/passport.config')(app);

//favicon
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(favicon(path.join(__dirname, upDir, 'td.site', 'favicon.ico')));

//logging
require('./config/loggers.config').config(app);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ homeController.index = function (req, res) {
}

res.cookie('XSRF-TOKEN', req.csrfToken(), cookieOptions);
res.sendFile(path.join(__dirname, '../', 'index.html'));
res.sendFile(path.join(__dirname, '..' + path.sep, '..' + path.sep, 'td.site', 'index.html'));
};

homeController.login = function (req, res) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 59f2a1f

Please sign in to comment.