Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Fix compass ce url and parser (#303)
Browse files Browse the repository at this point in the history
* Fix compass ce url

* Correct the parser
  • Loading branch information
grischperl authored Dec 22, 2021
1 parent 8b5571a commit 952986b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/kyma-mock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function customizeMock(app) {
urls:
{
eventsUrl: localDomain + "/events/v1/events",
cloudeventsUrl: localDomain + "events/events",
cloudeventsUrl: localDomain + "/events/events",
metadataUrl:
localDomain + "/metadata/v1/metadata/services",
renewCertUrl:
Expand Down
7 changes: 4 additions & 3 deletions modules/api-server/src/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ const LOGGER = config.logger("api-server")
async function init(config: config.Config) {
let app = express()
app.use(express.json({
type: function (req) {
return req.headers['content-type']
}
type: [
"application/cloudevents+json",
"application/json"
]
}))
app.use(cors())
app.options('*', cors())
Expand Down
11 changes: 10 additions & 1 deletion modules/app-connector/src/server/compass/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function signCertificateSigningRequestBase(connectorClientFn: Function, ur
return Buffer.from(encodedCert, "base64");
}

export async function eventsUrl(): Promise<string> {
export async function legacyEventsUrl(): Promise<string> {
const query = gql`
query($appId: ID!) {
application(id: $appId) {
Expand Down Expand Up @@ -165,9 +165,18 @@ export async function eventsUrl(): Promise<string> {
: " application not found"
}`
);
LOGGER.debug("Legacy events URL: %s", result.data.application.eventingConfiguration.defaultURL)
return result.data.application.eventingConfiguration.defaultURL;
}

export async function cloudEventsUrl(): Promise<string> {
let legacyUrl = await legacyEventsUrl();

let cloudeventsUrl = legacyUrl.replace("/v1/events", "/events");
LOGGER.debug("Cloud events URL: %s", cloudeventsUrl)
return cloudeventsUrl;
}

async function queryAppID(connectionInfo: connection.Info, certificate: Buffer): Promise<string> {
const query = gql`
query {
Expand Down
4 changes: 2 additions & 2 deletions modules/app-connector/src/server/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ export async function connect(token: string, persistFiles: boolean = true, insec

export async function legacyEventsUrl(): Promise<string> {
if (connection!.type === Type.Kyma) return kymaConnector.legacyEventsUrl();
else return compassConnector.eventsUrl();
else return compassConnector.legacyEventsUrl();
}

export async function cloudEventsUrl(): Promise<string> {
if (connection!.type === Type.Kyma) return kymaConnector.cloudEventsUrl();
else return compassConnector.eventsUrl();
else return compassConnector.cloudEventsUrl();
}

export type Info = {
Expand Down

0 comments on commit 952986b

Please sign in to comment.