Skip to content

Create event endpoint using Metadatapter Events for SherpaJS modular microservice platform.

License

Notifications You must be signed in to change notification settings

sellersindustry/SherpaJS-events

Repository files navigation

SherpaJS Events

NPM Version

Connect to event tracking platforms like PostHog using Metadapter Event and create event tracking endpoints for SherpaJS an agnostic and modular serverless platform.

Caution

Vercel doesn't support AJV regularly, we are working on a fix, but as of now, validation doesn't work on Vercel.


Features

  • SherpaJS Module, an Agnostic and Modular Serverless Platform
  • ✅ Log event using Metadapter Event
  • ✅ Supports PostHog

Installation

npm install sherpajs-events

Example Usage

Services are loaded using Metadapter Event. The id is the eventID that is logged with your event platform. The schema is optional, but uses AJV schema.

// sherpa.server.ts
import Events, { Service, ServiceType } from "sherpajs-events";


export default Events.load({
    service: Service(ServiceType.Skeleton, undefined),
    events: {
        "test": {
            id: "test",
            schema: {
                type: "object",
                properties: {
                    foo: {type: "integer"},
                    bar: {type: "string"}
                },
                required: ["foo"],
                additionalProperties: false
            }
        },
        "test2": {
            id: "test2"
        }
    }
});

Endpoint POST:/test

Body

{
    "foo": true
}

Response

400 Bad Request
Property 'foo': must be integer

Endpoint POST:/test

Body

Hello World

Response

400 Bad Request
Request body must be in JSON format.

Endpoint POST:/test

Body

{
    "foo": 3,
    "bar": "hello world"
}

Response

201 Created
Successfully Logged Event

Endpoint POST:/test2

Body

{
    "test": "hello world",
}

Response

201 Created
Successfully Logged Event

Endpoint POST:/test2

Body

{
    "test": true,
}

Response

201 Created
Successfully Logged Event

About

Create event endpoint using Metadatapter Events for SherpaJS modular microservice platform.

Resources

License

Stars

Watchers

Forks

Packages

No packages published