Skip to content

Instantly share code, notes, and snippets.

@flashvnn
Created June 27, 2021 13:49
Show Gist options
  • Save flashvnn/aee8e870fd5be7eeefc57cb05900ecac to your computer and use it in GitHub Desktop.
Save flashvnn/aee8e870fd5be7eeefc57cb05900ecac to your computer and use it in GitHub Desktop.
Total js with aws serverless
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