Skip to content

Commit

Permalink
Merge pull request #344 from itteco/node-fetch
Browse files Browse the repository at this point in the history
Node fetch
  • Loading branch information
nleush authored Nov 18, 2021
2 parents 7628d06 + b0da2b6 commit f891c83
Show file tree
Hide file tree
Showing 336 changed files with 2,587 additions and 2,843 deletions.
8 changes: 2 additions & 6 deletions ansible-docker-iframely/templates/config.local.js.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(function() {
var config = {
export default {

// Specify a path for custom plugins. Custom plugins will override core plugins.
// CUSTOM_PLUGINS_PATH: __dirname + '/yourcustom-plugin-folder',
Expand Down Expand Up @@ -259,7 +258,4 @@
}
}
*/
};

module.exports = config;
})();
};
31 changes: 17 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var sysUtils = require('./utils');
import { cacheMiddleware, NotFound } from './utils.js';
import CONFIG from './config.loader.js';
global.CONFIG = CONFIG;

console.log("");
console.log("Starting Iframely...");
Expand All @@ -8,13 +10,12 @@ if (!CONFIG.baseAppUrl) {
console.warn('Warning: CONFIG.baseAppUrl not set, default value used');
}

var path = require('path');
var express = require('express');
var jsonxml = require('jsontoxml');
import express from 'express';
import * as jsonxml from 'jsontoxml';

var NotFound = sysUtils.NotFound;
const app = express();

var app = express();
export default app;

app.set('view engine', 'ejs');

Expand All @@ -40,12 +41,17 @@ app.use(function(req, res, next) {
next();
});

app.use(sysUtils.cacheMiddleware);
app.use(cacheMiddleware);

import apiViews from './modules/api/views.js';
import debugViews from './modules/debug/views.js';
apiViews(app);
debugViews(app);

require('./modules/api/views')(app);
require('./modules/debug/views')(app);
require('./modules/tests-ui/views')(app);
if (CONFIG.tests) {
const testViews = await import('./modules/tests-ui/views.js');
testViews.default(app);
}

app.use(logErrors);
app.use(errorHandler);
Expand Down Expand Up @@ -168,7 +174,4 @@ app.get('/', function(req, res) {
res.end();
});

process.title = "iframely";
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

module.exports = app;
process.title = "iframely";
6 changes: 3 additions & 3 deletions cluster.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var GracefulCluster = require('graceful-cluster').GracefulCluster;
var sysUtils = require('./utils');
import { GracefulCluster } from 'graceful-cluster';
import * as sysUtils from './utils.js';

process.title = 'iframely-cluster';

Expand All @@ -10,6 +10,6 @@ GracefulCluster.start({
restartOnTimeout: CONFIG.CLUSTER_WORKER_RESTART_ON_PERIOD,
restartOnMemory: CONFIG.CLUSTER_WORKER_RESTART_ON_MEMORY_USED,
serverFunction: function() {
require('./server');
import('./server');
}
});
37 changes: 19 additions & 18 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
(function() {
import * as _ from 'underscore';
import * as path from 'path';
import * as fs from 'fs';

// Monkey patch before you require http for the first time.
var majorVersion = process.version.match(/v(\d+)\./);
majorVersion = parseInt(majorVersion);
if (majorVersion < 10) {
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
}

var _ = require('underscore');
var path = require('path');
var fs = require('fs');
import { fileURLToPath } from 'url';
import { dirname } from 'path';

var version = require('./package.json').version;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

import { readFile } from 'fs/promises';
const json = JSON.parse(await readFile(new URL('./package.json', import.meta.url)));
var version = json.version;

var config = {
const config = {

baseAppUrl: "",
port: 8061,
Expand Down Expand Up @@ -383,7 +382,8 @@
// Providers config loader.
var local_config_path = path.resolve(__dirname, "config.providers.js");
if (fs.existsSync(local_config_path)) {
var local = require(local_config_path);
var local = await import(local_config_path);
local = local && local.default;
_.extend(config, local);
}

Expand All @@ -397,11 +397,13 @@

// Try config by NODE_ENV.
if (fs.existsSync(env_config_path)) {
var local = require(env_config_path);
var local = await import(env_config_path);
local = local && local.default;

} else if (fs.existsSync(local_config_path)) {
// Else - try local config.
var local = require(local_config_path);
var local = await import(local_config_path);
local = local && local.default;
}

_.extend(config, local);
Expand Down Expand Up @@ -429,5 +431,4 @@
config.HTTP2_RETRY_CODES[item] = 1;
});

module.exports = config;
})();
export default config;
5 changes: 5 additions & 0 deletions config.loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import iframelyConfig from './config.js';
// Load global config from exec dir, because `iframely` can be used as library.
var globalConfig = await import(process.cwd() + '/config.js');
globalConfig = globalConfig && globalConfig.default;
export default {...iframelyConfig, ...globalConfig};
Loading

0 comments on commit f891c83

Please sign in to comment.