Skip to content

Commit 9112f9f

Browse files
committed
fix (cloud-runner) invalid path to application server code modules
1 parent 52f306d commit 9112f9f

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

lib/server-code/runners/tasks/invoke-handler.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const domain = require('domain'),
1212
resultWrapper = require('./util/result-wrapper');
1313

1414
const TIMED_OUT_ERR = 'Task execution aborted due to timeout';
15-
const defaultClassMappings = { [Backendless.User.prototype.___class]: Backendless.User };
15+
16+
const defaultClassMappings = {
17+
[Backendless.User.prototype.___class]: Backendless.User
18+
};
1619

1720
/**
1821
* @typedef {CodeRunnerTask} InvokeHandlerTask
@@ -104,7 +107,7 @@ module.exports = function(task, runnerOpts, model) {
104107
* @returns {ServerCodeModel}
105108
*/
106109
function buildModel(task, runnerOpts) {
107-
const codePath = path.resolve(runnerOpts.backendless.repoPath, task.relativePath);
110+
const codePath = path.resolve(runnerOpts.backendless.repoPath, task.applicationId.toLowerCase(), task.relativePath);
108111

109112
logger.debug(`Path to application server code resolved as ${codePath}`);
110113

@@ -116,7 +119,6 @@ function buildModel(task, runnerOpts) {
116119
}
117120

118121
const modelDescriptor = require(modelDescriptorPath);
119-
120122
const handler = modelDescriptor.handlers[handlerKey];
121123

122124
if (!handler) {
@@ -148,7 +150,7 @@ function fixTargetJSON(target) {
148150
* UTF8 Bytes Array -> JSON -> Array of objects classified according to classMappings
149151
*
150152
* @param {Array<number>} args
151-
* @param {Object} classMappings
153+
* @param {Object<String, Function>} classMappings
152154
* @returns {Array<*>}
153155
*/
154156
function decodeTaskArguments(args, classMappings) {

lib/util/json.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ exports.stringify = function(value) {
3434
* and resolving object references placed there by {@link json.stringify} or webORB serializer
3535
*
3636
* @param {String} text The string to parse as JSON
37-
* @param {Array<Object.<String, Class>>} classMappings
37+
* @param {Object.<String, Function>} classMappings
3838
* @returns {Object}
3939
*/
4040
exports.parse = function(text, classMappings) {
41-
classMappings = classMappings || [];
41+
classMappings = classMappings || {};
4242

4343
/**
4444
* A JSON.parse reviver which transforms object class to the mapped one

lib/util/logger.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,33 @@
44
* Logging tool for Backendless CodeRunner
55
* @module util/logger
66
*/
7+
78
'use strict';
89

910
const util = require('util');
1011
const PREFIX = ' [JS_CODERUNNER]';
1112

13+
function zeroPad(n, size) {
14+
n = n.toString();
15+
16+
while (n.length < size) {
17+
n = "0" + n;
18+
}
19+
20+
return n;
21+
}
22+
23+
// 16:19:34.754
1224
function timestamp() {
13-
return new Date().toISOString();
25+
const d = new Date();
26+
27+
const time = [
28+
zeroPad(d.getHours(), 2),
29+
zeroPad(d.getMinutes(), 2),
30+
zeroPad(d.getSeconds(), 2)
31+
].join(':');
32+
33+
return [time, zeroPad(d.getMilliseconds(), 3)].join('.');
1434
}
1535

1636
function prefix() {

0 commit comments

Comments
 (0)