Skip to content

Commit

Permalink
Origin
Browse files Browse the repository at this point in the history
  • Loading branch information
SellersEvan committed Mar 27, 2024
1 parent 5b382ab commit d6d07d8
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 1,139 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reedyuk/[email protected]
with:
version: ${{github.event.release.tag_name}}
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
120 changes: 117 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,118 @@
# SherpaJS Module Template
SherpaJS empowers developers to effortlessly construct modular and reusable microservices. This template provides a quick way to build custom SherpaJS Modules.

### See [SherpaJS Documentation](https://github.com/sellersindustry/SherpaJS) for more information.
# SherpaJS Events
![NPM Version](https://img.shields.io/npm/v/sherpajs-events)

Connect to event tracking platforms like PostHog
using [Metadapter Event](https://github.com/sellersindustry/metadapter-event) and create event tracking endpoints for
[SherpaJS](https://github.com/sellersindustry/SherpaJS) an agnostic and
modular serverless platform.



## Features
-[SherpaJS](https://github.com/sellersindustry/SherpaJS) Module, an Agnostic and Modular Serverless Platform
- ✅ Log event using [Metadapter Event](https://github.com/sellersindustry/metadapter-event)
- ✅ Supports PostHog

## Installation
```
npm install sherpajs-events
```

## Example Usage
Services are loaded using [Metadapter Event](https://github.com/sellersindustry/metadapter-event). The `id` is the eventID that is logged with your event platform. The `schema` is optional, but uses [AJV schema](https://ajv.js.org/).
```typescript
// sherpa.server.ts
import { SherpaJS } from "sherpa-core";
import { ContextSchema, Service, ServiceType } from "sherpajs-events";

export default SherpaJS.Load.module<ContextSchema>({
entry: "sherpajs-events",
context: {
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**
```json
{
"foo": true
}
```
**Response**
```
400 Bad Request
Property 'foo': must be integer
```

### Endpoint `POST:/test`
**Body**
```json
Hello World
```
**Response**
```
400 Bad Request
Request body must be in JSON format.
```

### Endpoint `POST:/test`
**Body**
```json
{
"foo": 3,
"bar": "hello world"
}
```
**Response**
```
201 Created
Successfully Logged Event
```


### Endpoint `POST:/test2`
**Body**
```json
{
"test": "hello world",
}
```
**Response**
```
201 Created
Successfully Logged Event
```

### Endpoint `POST:/test2`
**Body**
```json
{
"test": true,
}
```
**Response**
```
201 Created
Successfully Logged Event
```
Loading

0 comments on commit d6d07d8

Please sign in to comment.