Skip to content

Cloudevent SDK for Angular #490

Closed
Closed

Description

@shaheer-k

I want to use standard cloudevent format for sending events from frontend applications to the backend API.

I came to know about the following package which conform to the standard cloudevent format.

https://github.com/cloudevents/sdk-javascript

But I want to use it in angular application. Are there any cloudevent package exists for angular 12.

Activity

  1. lholmquist commented on May 27, 2022

    @lholmquist
    Contributor

    @shaheer-k there aren't any packages that i know of that wrap this sdk in an angular component(or whatever it is called in Angular land).

    But this is just a regular javascript library that should be able to be integrated into any JS framework

  2. shaheer-k commented on May 30, 2022

    @shaheer-k
    Author

    @lholmquist
    thank you for the response.

    I installed cloudevent sdk in Angular 12.0.0 application.
    npm install cloudevents

    Installation completed successfully.

    I tried the following code in my .ts file

    import { CloudEvent, CloudEventV1, CloudEventV1Attributes } from "cloudevents";
    
    const ce: CloudEventV1<string> = {
      specversion: "1.0",
      source: "/some/source",
      type: "example",
      id: "1234"
    };
    const event = new CloudEvent(ce);
    

    The line const event = new CloudEvent(ce); is causing the following error

    ./node_modules/cloudevents/dist/transport/http/index.js:11:31-46 - Error: Module not found: Error: Can't resolve 'http' in '\node_modules\cloudevents\dist\transport\http'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
            - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
            - install 'stream-http'
    If you don't want to include a polyfill, you can use an empty module like this:
            resolve.fallback: { "http": false }
    
    ./node_modules/cloudevents/dist/transport/http/index.js:12:32-48 - Error: Module not found: Error: Can't resolve 'https' in '\node_modules\cloudevents\dist\transport\http'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
            - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
            - install 'https-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
            resolve.fallback: { "https": false }
    

    Could you please help me in solving the above error.

  3. lance commented on May 31, 2022

    @lance
    Member

    @shaheer-k hi - you need to configure webpack to handle the fact that we do not ship polyfills for the https and http modules. The most straightforward way to do this is with the suggestion provided by the error message. Add this to your webpack config.

    resolve: {
      fallback: {
        https: false,
        http: false
      }
    }
    
  4. github-actions commented on Jul 1, 2022

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity.

  5. lance commented on Jul 5, 2022

    @lance
    Member

    @shaheer-k I am going to close this, assuming you've had some success. If you have not been able to get this to work, please re-open this issue or create a new one. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions