Created
June 27, 2021 13:49
-
-
Save flashvnn/aee8e870fd5be7eeefc57cb05900ecac to your computer and use it in GitHub Desktop.
Total js with aws serverless
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('total4'); | |
ROUTE('GET /test', function () { | |
this.json({'data': 'OK'}); | |
}) | |
NEWSCHEMA('Customers', function(schema) { | |
schema.setQuery(function($) { | |
$.callback({time: NOW.toTimeString()}); | |
}); | |
}); | |
var ACTION_ASYNC = function (url) { | |
return new Promise(function (resolve, reject) { | |
ACTION(url, function(err, response) { | |
!err ? resolve(response) : reject(Error(err)); | |
}); | |
}) | |
} | |
module.exports.handler = async (event, context) => { | |
try { | |
F.routes_sort(); | |
var action = await ACTION_ASYNC('GET /test'); | |
response = { | |
'statusCode': 200, | |
'body': typeof action === 'string' ? action : JSON.stringify(action) | |
} | |
} catch (err) { | |
console.log(err); | |
return err; | |
} | |
return response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment