-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
51 lines (51 loc) · 1.32 KB
/
Copy pathtest.lua
File metadata and controls
51 lines (51 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
return {
DB = 'postgresql://postgres:password@0.0.0.0:5432/pico',
ROUTES = {
['test'] = {
GET = {
PREPROCESS = function(params, jwt)
print('PREPROCESS called with params:', params, 'JWT:', jwt)
if jwt then
print('JWT userId:', jwt.userId)
else
print('No JWT provided')
end
return params
end,
POSTPROCESS = function(obj, jwt)
print('POSTPROCESS called with obj:', obj, 'JWT:', jwt)
local result = {
message = "Test successful",
jwt_present = jwt ~= nil
}
if jwt and jwt.userId then
result.user_id = jwt.userId
result.message = "Test successful for user " .. jwt.userId
end
return result
end,
},
},
['test-preprocess-error'] = {
GET = {
PREPROCESS = function(params, jwt)
error('Invalid input parameters provided')
end,
},
},
['test-postprocess-error'] = {
GET = {
POSTPROCESS = function(obj, jwt)
error('Failed to format response data')
end,
},
},
['test-setjwt-error'] = {
GET = {
SETJWT = function(obj)
error('Authentication failed: invalid credentials')
end,
},
},
},
}