Skip to content

Commit

Permalink
F #3951: Fireedge master (#164)
Browse files Browse the repository at this point in the history
* POST oneflow fireedge
* schemas oneflow fireedge
* http code accepted

Signed-off-by: Jorge Lobo <[email protected]>
  • Loading branch information
jloboescalona2 authored and rsmontero committed Aug 26, 2020
1 parent e9e99ac commit db059be
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
9 changes: 2 additions & 7 deletions src/fireedge/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@ LOG: prod
# Enable cors (cross-origin resource sharing)
CORS: true

# Webpack mode:
# - development
# - production
MODE: production

# JWT user password encryption key (AUTH)
TOKEN_SECRET: token_secreto
TOKEN_SECRET: secret_token

# Flow Server
# ONE_FLOW_SERVER:
# PROTOCOL: 'https'
# HOST: '0.0.0.0'
# POST: 2474

# JWT life time
# JWT life time (days)
LIMIT_TOKEN:
MIN: 14
MAX: 30
6 changes: 4 additions & 2 deletions src/fireedge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"build-node": "webpack --mode=production --env=node",
"build-front": "webpack --mode=production --env=front && concurrently \"npm run copy_static_assets\" \"npm run build:css\"",
"build:css": "node-sass src/public/scss/main.scss dist/public/app.css --output-style compressed",
"dev": "webpack --mode=development && npm run copy_static_assets && concurrently \"webpack --watch\" \"npm run build:css\" \"nodemon --inspect dist\"",
"dev:front": "webpack --mode=development --env=front && npm run copy_static_assets && concurrently \"webpack --watch\" \"npm run build:css\" \"nodemon --inspect dist\"",
"dev": "npm run copy_static_assets && concurrently \"npm run build:css\" \"nodemon --inspect dist\" \"webpack --mode=development --session=false --watch\"",
"dev:front": "npm run copy_static_assets && concurrently \"npm run build:css\" \"nodemon --inspect dist\" \"webpack --mode=development --session=false --env=front --watch\"",

"start": "node dist/index",
"cypress:open": "cypress open",
"cypress:run": "cypress run --headless --browser chrome --spec \"cypress/integration/**/*.spec.js\"",
Expand Down Expand Up @@ -102,6 +103,7 @@
"style-loader": "^1.0.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.7",
"webpack-livereload-plugin": "^2.3.0",
"webpack-node-externals": "^1.7.2"
}
}
6 changes: 3 additions & 3 deletions src/fireedge/src/routes/entrypoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

const entrypoint404 = require('server-entrypoints/404');
const entrypointApi = require('server-entrypoints/Api');
const entrypointApp = require('server-entrypoints/App');
const entrypoint404 = require('./404');
const entrypointApi = require('./Api');
const entrypointApp = require('./App');

module.exports = {
entrypoint404,
Expand Down
19 changes: 12 additions & 7 deletions src/fireedge/src/routes/entrypoints/middlewares/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ const validateResource = (req, res, next) => {
idUserOpennebula = session.iss;
userOpennebula = session.aud;
passOpennebula = session.jti;
// deberia estar condicionado por la variable de entorno dev
if (
global &&
global.users &&
global.users[userOpennebula] &&
global.users[userOpennebula] === passOpennebula
) {

if (!process.env.session) {
if (
global &&
global.users &&
global.users[userOpennebula] &&
global.users[userOpennebula] === passOpennebula
) {
next();
return;
}
} else {
next();
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/fireedge/src/utils/constants/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const defaults = {
defaultConfigFile: `${__dirname}/../config.yml`,
defaultTypeLog: 'prod',
defaultWebpackMode: 'development',
defaultWebpackDevTool: 'inline-source-map',
defaultConfigLogPath: '/var/log/one/',
defaultConfigLogFile: 'fireedge.log',
defaultBaseURL: '',
Expand Down
40 changes: 25 additions & 15 deletions src/fireedge/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const { getConfig } = require('./src/utils/');
const { defaultWebpackMode } = require('./src/utils/constants');

// settings
const appConfig = getConfig();
const mode = appConfig.MODE || defaultWebpackMode;
const devtool = mode === defaultWebpackMode ? 'inline-source-map' : '';
const {
defaultWebpackMode,
defaultWebpackDevTool
} = require('./src/utils/constants/defaults');

const js = {
test: /\.js$/,
Expand All @@ -43,15 +41,13 @@ const js = {
const alias = {
alias: {
server: path.resolve(__dirname, 'src/'),
client: path.resolve(__dirname, 'src/public/'),
'server-entrypoints': path.resolve(__dirname, 'src/routes/entrypoints/'),
'server-api': path.resolve(__dirname, 'src/routes/api/')
client: path.resolve(__dirname, 'src/public/')
},
extensions: ['.js']
};

const serverConfig = {
mode,
mode: defaultWebpackMode,
target: 'node',
node: {
__dirname: false
Expand All @@ -68,11 +64,11 @@ const serverConfig = {
filename: '[name]'
},
resolve: alias,
devtool
devtool: defaultWebpackDevTool
};

const clientConfig = {
mode,
mode: defaultWebpackMode,
target: 'web',
entry: {
'app.js': path.resolve(__dirname, 'src/public/front-app.js')
Expand All @@ -90,10 +86,24 @@ const clientConfig = {
filename: '[name]'
},
resolve: alias,
devtool
devtool: defaultWebpackDevTool
};

module.exports = env => {
module.exports = (env, argv) => {
if (argv && argv.mode !== defaultWebpackMode) {
[clientConfig.mode, serverConfig.mode] = Array(2).fill('production');
[clientConfig.devtool, serverConfig.devtool] = Array(2).fill('');
} else if (argv && argv.session && argv.session === 'false') {
const pluginProcessEnv = [
new webpack.DefinePlugin({
'process.env': {
session: JSON.stringify(argv.session)
}
})
];
clientConfig.plugins = pluginProcessEnv;
serverConfig.plugins = pluginProcessEnv;
}
let build = [];
if (env) {
switch (env) {
Expand Down

0 comments on commit db059be

Please sign in to comment.