Skip to content

Commit

Permalink
docs: align with changes in TS starter template
Browse files Browse the repository at this point in the history
  • Loading branch information
kark committed Jun 29, 2022
1 parent deef024 commit 9209412
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors';
import type { ApplicationWindow } from '@commercetools-frontend/constants';

declare const window: typeof Window & {
app: TApplicationContext<{}>['environment'];
};
declare let window: ApplicationWindow;

const EntryPoint = () => (
<ApplicationShell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
withProjectExtensionImageRegex,
ProjectExtensionProviderForImageRegex,
} from '@commercetools-frontend/application-shell-connectors';
import type { TImageRegexContext } from '@commercetools-frontend/application-shell-connectors/dist/declarations/src/components/project-extension-image-regex/project-extension-image-regex';
import type { TImageRegexContext } from '@commercetools-frontend/application-shell-connectors';
import { Component } from 'react';

type TOwnProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const express = require('express');
const {
createSessionMiddleware,
CLOUD_IDENTIFIERS,
} = require('@commercetools-backend/express');

const app = express();
app.use(
createSessionMiddleware({
audience: 'https://33ea-87-183-162-9.eu.ngrok.io',
issuer: CLOUD_IDENTIFIERS.GCP_EU,
})
);
app.post('/echo', (req, res) => {
res.send('It works 🙌');
});

app.listen(6000, () => {
console.log('Running on port 6000.');
});

module.exports = app;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import express, { type Request, type Response } from 'express';
import {
createSessionMiddleware,
CLOUD_IDENTIFIERS,
} from '@commercetools-backend/express';

const app = express();
app.use(
createSessionMiddleware({
audience: 'https://33ea-87-183-162-9.eu.ngrok.io',
issuer: CLOUD_IDENTIFIERS.GCP_EU,
})
);
app.post('/echo', (_req: Request, res: Response) => {
res.send('It works 🙌');
});

app.listen(6000, () => {
console.log('Running on port 6000.');
});

export default app;
6 changes: 2 additions & 4 deletions website/src/code-examples/help-needed/entry-point-uri-path.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Make sure to import the helper functions from the `ssr` entry point.
import { entryPointUriPathToPermissionKeys } from '@commercetools-frontend/application-shell/ssr';
import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors';
import type { ApplicationWindow } from '@commercetools-frontend/constants';

declare const window: typeof Window & {
app: TApplicationContext<{}>['environment'];
};
declare let window: ApplicationWindow;

export const entryPointUriPath =
typeof window === 'undefined'
Expand Down
28 changes: 4 additions & 24 deletions website/src/content/concepts/integrate-with-your-own-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -220,30 +220,10 @@ The URL `https://<identifier>.ngrok.io` can now be used as the URL of the server

This is also the value of the `audience` to be configured in your session middleware when using the `@commercetools-backend/express` package.

```js highlightLines="10"
const express = require("express");
const {
createSessionMiddleware,
CLOUD_IDENTIFIERS,
} = require("@commercetools-backend/express");

const app = express();
app.use(
createSessionMiddleware({
audience: "https://33ea-87-183-162-9.eu.ngrok.io",
issuer: CLOUD_IDENTIFIERS.GCP_EU,
})
);
app.post("/echo", (req, res) => {
res.send("It works 🙌");
});

app.listen(6000, () => {
console.log("Running on port 6000.");
});

module.exports = app;
```
<MultiCodeExample>
<CodeExample path="concepts/integrate-with-your-own-api/local-development.js" highlightLines={[10]} />
<CodeExample path="concepts/integrate-with-your-own-api/local-development.ts" highlightLines={[10]} />
</MultiCodeExample>

We recommend configuring the external API URL using environment variables to be able to define different values for development (using a secure tunnel) and production.
In the Custom Application config you can specify the external API URL as an [`additionalEnv`](/api-reference/application-config#additionalenv) property using a [variable placeholder](/api-reference/application-config#using-variable-placeholders).
Expand Down
2 changes: 1 addition & 1 deletion website/src/content/help-needed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ Therefore, both server-side and client-side logic must be considered when readin

<MultiCodeExample title="Channels">
<CodeExample path="help-needed/entry-point-uri-path.js" highlightLines={[4,5,6,7]} />
<CodeExample path="help-needed/entry-point-uri-path.ts" highlightLines={[9,10,11,12]} />
<CodeExample path="help-needed/entry-point-uri-path.ts" highlightLines={[7,8,9,10]} />
</MultiCodeExample>
</Info>

0 comments on commit 9209412

Please sign in to comment.