I was wondering if anyone has used ext-direct with sailsjs. If you have or anyone with the know how, please can you direct me.
Thank you.
Here are some examples
In regular nodejs/express app, I would normaly do this in my app.js file
app.get(ExtDirectConfig.apiPath, function (request, response) {
try {
var api = extdirect.getAPI(ExtDirectConfig);
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(api);
} catch (e) {
console.log(e);
}
});
// Ignoring any GET requests on class path
app.get(ExtDirectConfig.classPath, function (request, response) {
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify({success: false, msg: 'Unsupported method. Use POST instead.'}));
});
// POST Request process route and calls class
app.post(ExtDirectConfig.classPath, db, function (request, response) {
extdirect.processRoute(request, response, ExtDirectConfig);
});
How would i do this in sails.js
Edit: Thank you @Scott Gress. After looking over my code, there was no need to pass the db object (yes it is a middleware) as it has already attached itself to the request object. Thank you.
Thank you.