Giter Club home page Giter Club logo

coremedia-headless-client-react's Introduction

CoreMedia Labs Logo

CoreMedia Content Cloud Version Status

Spark - The React Example Application

Picture of Spark

This is the workspace of Spark - a React example application based on React, TypeScript and the Headless Server of CoreMedia Content Cloud. It contains a GraphQL schema stitching server, and a commerce mocking server. The stitching server provides a unified GraphQL interface with an optional waiver of the otherwise necessary commerce connection (GraphQL Mocking Server).

CoreMedia customers can use Spark as a quick start for building prototype applications. Note that we do not recommend the use of these prototype apps in production environments.

This CoreMedia Labs project includes two React applications and two server components:

  • spark - Provides guidance for frontend developers that are building websites and other applications based on the CoreMedia Headless server with code examples and documentation on:

    • Preview Driven Editing
    • Time Travel
    • Placement Highlighting
    • Content Search
    • Fragment Preview and many others
  • standalone-fragment - Demonstrates the ability to load fragments from a CoreMedia Content Cloud and render it on an external website. For example, by injecting resources client side through a tag management solution like the Google Tag Manager.

  • stitching-server - Provides a GraphQL Endpoint for the apps.

  • mocking-server - Provides generic commerce data for the stitching server.

Although we chose React with which to build Spark, the principles can easily be transferred to other component libraries and frameworks such as Vue and Angular.

This project will be updated with enhancements and fixes on a regular basis. Please refer to the changelog for more details.

Quickstart

You need at least Node.js 20 (LTS), pnpm 9 and a running instance of the CoreMedia Content Cloud. Define your environment variables in .env file for the stitching server:

servers/stitching/.env

COREMEDIA_ENDPOINT=https://<headless-server.example.com>/graphql

Install and build local environment once:

pnpm install
pnpm build

You can now start the workspace including the spark app in watch mode:

pnpm start

This will start both servers and the app concurrently. If you want to start just one of the apps or servers, navigate to the according folder and run pnpm start.

Documentation

Read the documentation or on GitHub Pages for more information on development, deployment and the concepts of the app.

Contributing

Read our contributing guide to learn about how to propose bugfixes and improvements.

License

This project is licensed under the terms of the CoreMedia Open Source License.

The mocking server that is a fork of the project smoke is licensed under the terms of the MIT License.

CoreMedia Labs

Welcome to CoreMedia Labs! This repository is part of a platform for developers who want to have a look under the hood or get some hands-on understanding of the vast and compelling capabilities of CoreMedia. Whatever your experience level with CoreMedia is, we've got something for you.

Each project in our Labs platform is an extra feature to be used with CoreMedia, including extensions, tools and 3rd party integrations. We provide some test data and explanatory videos for non-customers and for insiders there is open-source code and instructions on integrating the feature into your CoreMedia workspace.

The code we provide is meant to be example code, illustrating a set of features that could be used to enhance your CoreMedia experience. We'd love to hear your feedback on use-cases and further developments! If you're having problems with our code, please refer to our issues section. If you already have a solution to an issue, we love to review and integrate your pull requests.

coremedia-headless-client-react's People

Contributors

pitgrap avatar uwilken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coremedia-headless-client-react's Issues

Fails with coremedia.training

Describe the bug
The client does not work with https://headless-server-preview.cm95.coremedia.training/graphql

To Reproduce
Steps to reproduce the behavior:

  1. Create '.env' file
  2. Put 'COREMEDIA_ENDPOINT=https://headless-server-preview.cm95.coremedia.training/graphql.'
  3. 'pnpm build'
  4. 'pnpm start'
  5. Go 'http://localhost:5173/'
  6. See error '400 - Apollo Client Error'

Expected behavior
The application should work as expected.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser FireFox

Building docker image failed: "/spark/storybook-static" not found

Describe the bug

I am trying to build the Spark-App in version 2204.0.0 on Windows WSL2 (Ubuntu) using the following commands

pnpm install
pnpm run build

DOCKER_BUILDKIT=1 docker build -t "coremedia/spark-client:latest" ./apps

The “pnpm install” and “pmpn build” works fine, but when I am trying to create the docker images (vor spark app and stitching) I receive the following error:

[+] Building 1.5s (7/9)
=> [internal] load build definition from Dockerfile                                                                                                                0.0s
=> => transferring dockerfile: 38B                                                                                                                                 0.0s
=> [internal] load .dockerignore                                                                                                                                   0.0s
=> => transferring context: 2B                                                                                                                                     0.0s
=> [internal] load metadata for docker.io/library/nginx:1.21-alpine                                                                                                1.2s
=> CANCELED [1/5] FROM docker.io/library/nginx:1.21- alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989                                 0.2s
=> => resolve docker.io/library/nginx:1.21-alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989                                          0.0s
=> => sha256:e00351ea626cd356c69e58d33181233b47a904d3b6ee508948d6cc221d7b9cfa 0B / 603B                                                                            0.2s
=> => sha256:a285f0f83eed13cf71ccb560c31dd31b5eb7be0cadb4f43319d6de59aa4e3c70 0B / 7.34MB                                                                          0.2s
=> => sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989 1.65kB / 1.65kB                                                                      0.0s
=> => sha256:529db430e042ecef071f2e88267cee6da18f8ab44d66a0c44348886fdc2e60fc 1.57kB / 1.57kB                                                                      0.0s
=> => sha256:b1c3acb28882519cf6d3a4d7fe2b21d0ae20bde9cfd2c08a7de057f8cfccff15 8.75kB / 8.75kB                                                                      0.0s
=> => sha256:df9b9388f04ad6279a7410b85cedfdcb2208c0a003da7ab5613af71079148139 0B / 2.81MB                                                                          0.2s
=> [internal] load build context                                                                                                                                   0.2s
=> => transferring context: 13.73MB                                                                                                                                0.2s
=> CACHED [2/5] COPY spark/build /usr/share/nginx/html                                                                                                             0.0s
=> ERROR [3/5] COPY spark/storybook-static /usr/share/nginx/html/storybook        0.0s
------
> [3/5] COPY spark/storybook-static /usr/share/nginx/html/storybook:
------
failed to compute cache key: "/spark/storybook-static" not found: not found

I had a look at the Dockerfile at /apps/Dockerfile, and it contains the line

COPY spark/storybook-static /usr/share/nginx/html/storybook

, but the folder spark/storybook-static is not part of the workspace.

To Reproduce
Steps to reproduce the behavior:

  1. Check out v2204.0.0 and build the docker image
  2. See error

Expected behavior
No build error.

Desktop (please complete the following information):

  • OS: Windows 10, WSL2 (Ubuntu)

Failed to resolve entry for package "@coremedia-labs/preview-integration"

Describe the bug
unable to start spark application due to bug in package

To Reproduce
Steps to reproduce the behavior:

  1. navigate to spark folder
  2. pnpm install
  3. pnpm build
    error is thrown
    Failed to resolve entry for package "@coremedia-labs/preview-integration

Expected behavior
spark application should open with
http://localhost:5173/

Screenshots
5173

Detailed Log :
[plugin:vite:import-analysis] Failed to resolve entry for package "@coremedia-labs/preview-integration". The package may have incorrect main/module/exports specified in its package.json.
/Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/apps/spark/src/index.tsx
at packageEntryFailure (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28725:11)
at resolvePackageEntry (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28722:5)
at tryNodeResolve (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28453:20)
at Context.resolveId (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28212:28)
at async Object.resolveId (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44276:32)
at async TransformContext.resolve (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:43992:23)
at async normalizeUrl (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41836:34)
at async file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41998:47
at async Promise.all (index 5)
at async TransformContext.transform (file:///Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/node_modules/.pnpm/vite@4.5.0_@types[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41914:13

Desktop (please complete the following information):

  • OS: [MAC os M1]
  • Browser [e.g. chrome]
  • Version [cm 11, 2307.1]

Additional context
stitching and mocking both servers are up and running
stitching server log:
2023-11-28 16:48:04 [INFO] Fetching schemas from GraphQL endpoints
2023-11-28 16:48:04 [INFO] Loading schema from http://localhost:41180/graphql (Headless Server).
2023-11-28 16:48:08 [INFO] Successfully loaded schema from coreMediaHeadlessServerEndpoint.
2023-11-28 16:48:08 [INFO] Loading schema from http://localhost:43180/graphql (Headless Commerce Server).
2023-11-28 16:48:08 [INFO] Successfully loaded schema from commerceCatalogEndpoint.
2023-11-28 16:48:08 [INFO] Campaign Service not configured.
2023-11-28 16:48:08 [INFO] Stitching server started on: http://localhost:4000/graphql

mocking server log:

@coremedia-labs/[email protected] start /Users/spalakal/Documents/Projects/spark-ws-11/coremedia-headless-client-react/servers/mocking
node ./bin/smoke -o all -d 10 mocks

2023-11-28 16:48:15 [INFO] Mocking server started on: http://localhost:5000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.