Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Sep 22, 2024
0 parents commit 463ee4d
Show file tree
Hide file tree
Showing 17 changed files with 1,226 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: dahlia
86 changes: 86 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: main
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- run: deno task test --junit-path=.test-report.xml
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: .test-report.xml
- run: deno task check
- run: deno task dnt
- run: bun run ./test_runner.js
working-directory: ${{ github.workspace }}/npm/

publish:
if: github.event_name == 'push'
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- if: github.ref_type == 'branch'
run: |
jq \
--arg build "$GITHUB_RUN_NUMBER" \
--arg commit "${GITHUB_SHA::8}" \
'.version = .version + "-dev." + $build + "+" + $commit' \
deno.json > deno.json.tmp
mv deno.json.tmp deno.json
- if: github.ref_type == 'tag'
run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]'
- run: 'deno task dnt "$(jq -r .version deno.json)"'
env:
DNT_TEST: false
- run: |
set -ex
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
npm publish --provenance --access public
else
npm publish --provenance --access public --tag dev
fi
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
working-directory: ${{ github.workspace }}/npm/
- run: deno publish --allow-dirty
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dnt-import-map.json
npm/
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"denoland.vscode-deno",
"streetsidesoftware.code-spell-checker"
]
}
32 changes: 32 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"deno.enable": true,
"deno.unstable": [
"temporal"
],
"editor.detectIndentation": false,
"editor.indentSize": 2,
"editor.insertSpaces": true,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.sortImports": "always"
}
},
"cSpell.words": [
"fedify",
"unlisten",
"UNLOGGED"
]
}
30 changes: 30 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"deno": {
"enable": true
},
"ensure_final_newline_on_save": true,
"format_on_save": "on",
"formatter": "language_server",
"languages": {
"TypeScript": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
"!eslint",
"..."
]
},
"TSX": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
"!eslint",
"..."
]
}
},
"show_wrap_guides": true,
"wrap_guides": [80]
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright 2024 Hong Minhee

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!-- deno-fmt-ignore-file -->

@fedify/postgres: PostgreSQL drivers for Fedify
===============================================

[![JSR][JSR badge]][JSR]
[![npm][npm badge]][npm]
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]

This package provides [Fedify]'s [`KvStore`] and [`MessageQueue`]
implementations for PostgreSQL:

- [`PostgresKvStore`]
- [`PostgresMessageQueue`]

~~~~ typescript
import { createFederation } from "@fedify/fedify";
import { PostgresKvStore, PostgresMessageQueue } from "@fedify/postgres";
import postgres from "postgres";

const sql = postgres("postgresql://user:password@localhost/dbname");

const federation = createFederation({
kv: new PostgresKvStore(sql),
queue: new PostgresMessageQueue(sql),
});
~~~~

[JSR]: https://jsr.io/@fedify/postgres
[JSR badge]: https://jsr.io/badges/@fedify/postgres
[npm]: https://www.npmjs.com/package/@fedify/postgres
[npm badge]: https://img.shields.io/npm/v/@fedify/postgres?logo=npm
[GitHub Actions]: https://github.com/dahlia/fedify-postgres/actions/workflows/main.yaml
[GitHub Actions badge]: https://github.com/dahlia/fedify-postgres/actions/workflows/main.yaml/badge.svg
[Fedify]: https://fedify.dev/
[`KvStore`]: https://jsr.io/@fedify/fedify/doc/federation/~/KvStore
[`MessageQueue`]: https://jsr.io/@fedify/fedify/doc/federation/~/MessageQueue
[`PostgresKvStore`]: https://jsr.io/@fedify/postgres/doc/federation/~/PostgresKvStore
[`PostgresMessageQueue`]: https://jsr.io/@fedify/postgres/doc/federation/~/PostgresMessageQueue


Installation
------------

### Deno

~~~~ sh
deno add @fedify/postgres
~~~~

### Node.js

~~~~ sh
npm install @fedify/postgres
~~~~

### Bun

~~~~ sh
bun add @fedify/postgres
~~~~


Changelog
---------

### Version 0.1.0

To be released.
28 changes: 28 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@fedify/postgres",
"version": "0.1.0",
"license": "MIT",
"exports": {
".": "./mod.ts",
"./kv": "./src/kv.ts",
"./mq": "./src/mq.ts"
},
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@fedify/fedify": "jsr:@fedify/fedify@^1.0.0-dev.410+8793b61b",
"@std/assert": "jsr:@std/assert@^0.226.0",
"@std/async": "jsr:@std/async@^1.0.5",
"postgres": "npm:postgres@^3.4.4"
},
"unstable": [
"temporal"
],
"exclude": [
"npm"
],
"tasks": {
"check": "deno fmt --check && deno lint && deno check */*.ts",
"test": "deno test --allow-net --allow-env",
"dnt": "deno run -A dnt.ts"
}
}
Loading

0 comments on commit 463ee4d

Please sign in to comment.