Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
62ef7a7f
Commit
62ef7a7f
authored
Feb 17, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logs
parent
306b2a1f
Pipeline
#551
canceled with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
apiMappers.js
src/apiMappers.js
+47
-0
No files found.
src/apiMappers.js
View file @
62ef7a7f
...
...
@@ -65,6 +65,47 @@ const parseArgs = function(req, res, opts) {
return
args
;
};
var
logStream
=
fs
.
createWriteStream
(
"/var/log/kus-quizard.txt"
,
{
flags
:
'a'
});
function
getDate
(
date
){
if
(
date
instanceof
Date
)
{
return
{
day
:
date
.
getDate
(),
month
:
date
.
getMonth
(),
//monthName: months[date.getMonth()],
year
:
date
.
getFullYear
(),
date
:
date
};
}
else
if
(
date
===
null
||
date
===
void
0
){
return
null
;
}
else
{
return
date
;
}
}
const
months
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'Jule'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
];
const
shortMonths
=
months
.
map
(
function
(
name
)
{
return
name
.
substr
(
0
,
3
);
});
shortMonths
[
8
]
=
'Sept'
;
function
humanDate
(
date
)
{
let
d
=
getDate
(
date
);
return
[
d
.
day
,
shortMonths
[
d
.
month
],
d
.
year
].
join
(
' '
);
}
module
.
exports
=
{
api2html
:
function
(
apis
)
{
var
out
=
[];
...
...
@@ -112,11 +153,17 @@ ${opt.required?'<span class="api-option-required">Required</span>': '<span class
try{
let result = await api.fn(args, req, res);
// fs.writeFileSync('./data/tmp/full.json', JSON.stringify(data, null, 2))
logStream.write(`
$
{
humanDate
(
new
Date
())}
$
{
api
.
method
}:
$
{
key
}
$
{
JSON
.
stringify
(
args
)}
`)
logStream.write(`
$
{
JSON
.
stringify
(
result
.
log
,
null
,
1
)}
\
n
`);
res.end(typeof result === 'string' ? result : JSON.stringify(result, null,1), 'utf-8');
clearTimeout(timeout)
}catch(e){
debugger
logStream.write(`
$
{
humanDate
(
new
Date
())}
$
{
api
.
method
}:
$
{
key
}
$
{
JSON
.
stringify
(
args
)}
`)
logStream.write(`
ERROR
:
$
{
e
.
message
+
'
\
n'
+
e
.
stack
}
\
n
\
n
`)
res.end(e.message+'\n'+e.stack)
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment