Closed khusamov closed 7 years ago
Hmm are you sure ? I use everyday extdirect and I have no problem with the connexion to /directapi, though I never gave a look to the source code.
Now I had to make these settings:
http://localhost:3000/directapi
{
"url": "http://localhost:3000/app/direct",
"namespace": "Server",
"type": "remoting",
let directConfig = {
rootNamespace: "Server",
apiName: "api",
apiUrl: "/directapi",
classRouteUrl: "/app/direct",
classPath: "/app/direct",
server: "localhost",
port: "3000",
...
};
If I parameter class RouteUrl will set a value:
classRouteUrl: "/direct",
That API will not be available at the URL : http://localhost:3000/direct
FWIW, here is my config that works perfectly :
in app/DirectAPI.js
Ext.define('MyApp.DirectAPI', {
//Require Ext.Direct classes
requires: ['Ext.direct.*']
}, function() {
var Loader = Ext.Loader;
//Loading API
Loader.loadScriptsSync(['http://localhost:8889/directapi']);
//Custom implementation. Works only with node backend and extdirect connector v2
//This feature is part ApiProcessor implementation
//
var ns = Server.API;
if (ns) {
// Check for unexpected problems
// Node backend will set error object
if (ns.error) {
//This is handled later in Application launch method
MyApp.DirectError = ns.error;
} else {
Ext.direct.Manager.addProvider(ns);
}
}
});
in server.js (nodejs main file) :
var directConfig = {
rootNamespace: "Server",
apiName: "API",
apiUrl: "/directapi",
classRouteUrl: "/direct",
classPath: "/direct",
server: "localhost",
port: "8889",
protocol: "http",
timeout: 30000,
cacheAPI: false,
relativeUrl: false,
appendRequestResponseObjects: true,
enableMetadata: true,
responseHelper: true,
enableProcessors: true
};
// ------------------------------------------------
// ROUTES
// ------------------------------------------------
//GET method returns API
app.get(directConfig.apiUrl, function(req, res) {
try {
directApi.getAPI(
function(api) {
res.writeHead(200, {
'Content-Type': 'application/json'
});
res.end(api);
}, req, res
);
} catch (e) {
console.log(e);
}
});
I will take a look over the week
Ah @khusamov is right, I reproduce the pb now : just set two different paths for classPath and classRouteUrl in directConfig.
Wrong url is computed at request
/directapi
he file api.js need to fix the line 52:
to