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
a3e3ecb0
Commit
a3e3ecb0
authored
Jul 13, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trash storage
parent
679e51d3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
quiz.js
src/api/quiz.js
+46
-0
No files found.
src/api/quiz.js
View file @
a3e3ecb0
...
@@ -63,6 +63,7 @@ updated_at
...
@@ -63,6 +63,7 @@ updated_at
created_at
created_at
*/
*/
var
getTrash
;
var
fs
=
require
(
'fs'
);
var
fs
=
require
(
'fs'
);
const
util
=
require
(
'util'
);
const
util
=
require
(
'util'
);
const
readFile
=
util
.
promisify
(
fs
.
readFile
);
const
readFile
=
util
.
promisify
(
fs
.
readFile
);
...
@@ -386,5 +387,49 @@ module.exports = {
...
@@ -386,5 +387,49 @@ module.exports = {
return
questions
;
return
questions
;
}
}
},
'/api/user/data/:userID'
:
{
options
:
{
userID
:
{
required
:
false
,
description
:
'id of user'
,
type
:
Number
},
},
method
:
'POST'
,
summary
:
'Assign user any data storage'
,
fn
:
async
function
(
args
)
{
var
trash
=
await
getTrash
(
args
);
trash
=
Object
.
assign
(
trash
,
args
.
body
);
// sub my completed attempt
var
str
=
JSON
.
stringify
(
trash
);
await
asyncPool
(
`
INSERT INTO trash (user_id, json)
VALUES(?, ?)
ON DUPLICATE KEY UPDATE json = ?;`
,
[
args
.
userID
,
str
,
str
]);
return
trash
;
}
},
'/api/user/data/get/:userID'
:
{
options
:
{
userID
:
{
required
:
false
,
description
:
'id of user'
,
type
:
Number
},
},
method
:
'GET'
,
summary
:
'Get user data storage'
,
fn
:
getTrash
=
async
function
(
args
)
{
var
out
=
{};
var
data
=
await
asyncPool
(
`select * from trash where user_id=?;`
,
[
args
.
userID
]);
if
(
data
&&
data
[
0
]){
var
json
=
data
[
0
].
json
;
if
(
json
){
try
{
out
=
JSON
.
parse
(
json
);
if
(
typeof
out
!==
'object'
)
out
=
{};
}
catch
(
e
)
{
}
}
}
}
return
out
;
}
},
};
};
\ No newline at end of file
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