Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
ignore:
- dependency-name: "typescript*"
- dependency-name: "@types/node"
versions: ["15.x"]
68 changes: 34 additions & 34 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: 'CodeQL'
name: "CodeQL"

on:
push:
Expand All @@ -29,43 +29,43 @@ jobs:
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
26 changes: 26 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build
on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- run: yarn build
- run: yarn lint
- run: yarn test
env:
CI: true
- run: npx codecov
37 changes: 0 additions & 37 deletions .github/workflows/pull_request.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/push.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node

- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

- run: yarn install
- run: yarn run test
- run: yarn run build

- if: ${{ steps.release.outputs.release_created }}
run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# PubSub HTTP Handler

![Build & Deploy][build-badge]
[![Total alerts][lgtm-badge]][lgtm-alerts]
![Build & Deploy][build-badge] [![Total alerts][lgtm-badge]][lgtm-alerts]
[![LGTM Grade][lgtm-grade]][lgtm-alerts]
[![Maintainability][codeclimate-badge]][codeclimate]
[![npm bundle size][bundle-size]][npm]

![PubSub HTTP Handler](.github/header.jpg)

PubSub HTTP Handler is a simple Typescript/Javascript package that solves serving an
HTTP endpoint that can consume PubSub messages. It is intended to use with
Google Cloud Functions or Google Cloud Run.
PubSub HTTP Handler is a simple Typescript/Javascript package that solves
serving an HTTP endpoint that can consume PubSub messages. It is intended to use
with Google Cloud Functions or Google Cloud Run.

This package was built so that when creating microservices that subscribes to a
PubSub-topic, we don't have to implement a server or validate the request.
Expand All @@ -26,7 +25,7 @@ The package utilizes [Fastify][] to serve HTTP.
## Example

```typescript
import { pubSubServer, PubSubHandler } from 'pubsub-http-handler';
import { createPubSubServer, PubSubHandler } from 'pubsub-http-handler';

interface MyHandler {
hello: string;
Expand All @@ -37,15 +36,21 @@ const server = async () => {
const handler: PubSubHandler<MyHandler> = ({ message, data }) => {
// `message` contains attributes, data (as string), messageId
// `data` contains a base64 decoded JSON serialized object (type is MyHandler in the example)

...
// ...
};

await pubSubServer(handler);
const { listen } = await createPubSubServer(handler);
await listen();
};
```

Read more about [configuration here][configuration] or check out the [API documentation][docs]
We also support `fastify-plugin` and `cloud-functions`. See [more examples in
the `examples/` folder][examples].

Read more about [configuration here][configuration] or check out the [API
documentation][docs]

[examples]: ./examples

## Contributing

Expand All @@ -69,6 +74,6 @@ We love contributions! 🙏 Bug reports and pull requests are welcome on
https://img.shields.io/bundlephobia/min/@cobraz/pubsub-http-handler?style=flat-square
[semantic-release-badge]:
https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square
[Fastify]: https://www.fastify.io/
[fastify]: https://www.fastify.io/
[configuration]: ./docs/interfaces/pubsubconfig.md
[docs]: ./docs/
[docs]: ./docs/
Loading