Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODATA V2 support not working HANA-XSA Project #5

Open
saket-sahi opened this issue Jul 20, 2021 · 0 comments
Open

ODATA V2 support not working HANA-XSA Project #5

saket-sahi opened this issue Jul 20, 2021 · 0 comments

Comments

@saket-sahi
Copy link

I am trying to add ODATA V2 support in my HANA -XSA project. I have completed the changes to the package.json and loaded npm odata-v2-proxy on CDS bootstrap. Below is the code.
host:port/odata/v4/catalogservice is working but host:port/odata/v2/catalogservice is not working.
Error:Cannot GET /odata/v2/catalogservice

var https = require("https");
var port = process.env.PORT || 4000;
var express = require("express");
let app = express();
const server = require("https").createServer(app);
const cds = require("@sap/cds");
const xsenv = require("@sap/xsenv");
const xsHDBConn = require("@sap/hdbext");
const xssec = require("@sap/xssec");
const passport = require("passport");
var routerData = require('./router/index');
const proxy = require('@sap/cds-odata-v2-adapter-proxy');

xsenv.loadEnv();
https.globalAgent.options.ca = xsenv.loadCertificates();
global.__base = __dirname + "/";
global.__uaa = process.env.UAA_SERVICE_NAME;
passport.use("JWT", new xssec.JWTStrategy(xsenv.getServices({
uaa: {
tag: "xsuaa"
}
}).uaa));
app.use(passport.initialize());
let hanaOptions = xsenv.getServices({hana:{tag:"hana"}});
hanaOptions.hana.pooling = true;
app.use(
xsHDBConn.middleware(hanaOptions.hana)

);
var options = {
kind: "hana",
logLevel: "error"

};

cds.connect(options);
cds.on('bootstrap',(app)=> app.use(proxy());
var odataURL = "/odata/v4/CatalogService/";
cds.serve("gen/csn.json", {
crashOnError: false
})
.at(odataURL)
.with(require("./lib/handlers/cat"))
.in(app)
.catch((err) => {
console.log(err);
process.exit(1);
});
app.use('/node',routerData);
app.get("/", (req, res) => {
res.redirect(odataURL);
});
app.get("/node", (req, res) => {
res.redirect(odataURL);
});

app.listen(port);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant