Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jwt in native app for qewd up. #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/master-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ function configure(config, routes, qOper8, qExt) {
console.log('webServerRootPath = ' + config.webServerRootPath);
if (config.cors) {
app.use('/', function (req, res, next) {
//res.header('Access-Control-Allow-Origin', '*');
//res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');

res.header('Access-Control-Allow-Credentials', 'true');
res.header('Access-Control-Allow-Headers', 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization');
//res.header('Access-Control-Allow-Credentials', 'true');
//res.header('Access-Control-Allow-Headers', 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization');
res.header('Access-Control-Allow-Methods', 'GET, PUT, DELETE, POST, OPTIONS');
res.header('Access-Control-Allow-Origin', '*');
//res.header('Access-Control-Allow-Origin', '*');
next();
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ function start(params, routes) {
if (!config.webSockets.module) config.webSockets.module = 'socket.io';
if (config.webSockets.module === 'socket.io') {
if (!config.webSockets.engine) {
io = require('socket.io')(server, {wsEngine: 'ws'});
io = require('socket.io')(server, {wsEngine: 'ws', cors: {origin: '*', credentials: true}, cookie: {name: "io", httpOnly: false, path: "/"}});
}
else {
var engine = config.webSockets.engine;
if (engine !== 'ws' && engine !== 'uws') engine = 'ws';
io = require('socket.io')(server, {wsEngine: engine});
io = require('socket.io')(server, {wsEngine: engine, cors: {origin: '*', credentials: true}, cookie: {name: "io", httpOnly: false, path: "/"}});
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions up/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ module.exports = {
var _this = this;
var router = require('qewd-router');
var routes = getRoutes();
console.log('Faisal:');
console.log(routes);
routes = router.initialise(routes, module.exports);
console.log('Faisal2:');
console.log(routes);
if (errorResponse) {
var statusCode = errorResponse.statusCode || 404;
var text = errorResponse.text || 'Not Found';
Expand Down
21 changes: 12 additions & 9 deletions up/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ function setup(isDocker, service_name) {
}
else {
// native app
if (config_data.jwt && config_data.jwt.secret) {
config.jwt = Object.assign({}, config_data.jwt); // prevent it being simply by reference
}
createModuleMap(cwd, config);
}

Expand Down Expand Up @@ -876,20 +879,20 @@ module.exports = function(isDocker, serviceName) {
if (config.database && config.database.type === 'gtm') {

try {
console.log('Running down YottaDB...');
child_process.execSync(process.env.ydb_dist + '/mupip rundown -region DEFAULT', {stdio:[0,1,2]});
child_process.execSync(process.env.ydb_dist + '/mupip rundown -region qewdreg', {stdio:[0,1,2]});
console.log('Rundown completed');
//console.log('Running down YottaDB...');
//child_process.execSync(process.env.ydb_dist + '/mupip rundown -region DEFAULT', {stdio:[0,1,2]});
//child_process.execSync(process.env.ydb_dist + '/mupip rundown -region qewdreg', {stdio:[0,1,2]});
//console.log('Rundown completed');
}
catch(err) {
console.log('Error running down YottaDB: ' + err);
console.log('Recovering journal...');
//console.log('Error running down YottaDB: ' + err);
//console.log('Recovering journal...');
try {
child_process.execSync(process.env.ydb_dist + '/mupip journal -recover -backward ' + process.env.ydb_dir + '/' + process.env.ydb_rel + '/g/yottadb.mjl', {stdio:[0,1,2]});
console.log('Journal recovered');
//child_process.execSync(process.env.ydb_dist + '/mupip journal -recover -backward ' + process.env.ydb_dir + '/' + process.env.ydb_rel + '/g/yottadb.mjl', {stdio:[0,1,2]});
//console.log('Journal recovered');
}
catch(err) {
console.log('YottaDB is probably already in use');
//console.log('YottaDB is probably already in use');
}
}
}
Expand Down