Skip to content

Commit 463ee4d

Browse files
committedSep 22, 2024··
Initial commit
0 parents  commit 463ee4d

17 files changed

+1226
-0
lines changed
 

‎.github/FUNDING.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: dahlia

‎.github/workflows/main.yaml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: main
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
checks: write
9+
pull-requests: write
10+
services:
11+
postgres:
12+
image: postgres
13+
env:
14+
POSTGRES_USER: postgres
15+
POSTGRES_PASSWORD: postgres
16+
POSTGRES_DB: postgres
17+
options: >-
18+
--health-cmd pg_isready
19+
--health-interval 10s
20+
--health-timeout 5s
21+
--health-retries 5
22+
ports:
23+
- 5432:5432
24+
env:
25+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: denoland/setup-deno@v1
29+
with:
30+
deno-version: v1.x
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: lts/*
34+
- uses: oven-sh/setup-bun@v1
35+
with:
36+
bun-version: latest
37+
- run: deno task test --junit-path=.test-report.xml
38+
- uses: EnricoMi/publish-unit-test-result-action@v2
39+
if: always()
40+
with:
41+
files: .test-report.xml
42+
- run: deno task check
43+
- run: deno task dnt
44+
- run: bun run ./test_runner.js
45+
working-directory: ${{ github.workspace }}/npm/
46+
47+
publish:
48+
if: github.event_name == 'push'
49+
needs: [test]
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
id-token: write
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: denoland/setup-deno@v1
57+
with:
58+
deno-version: v1.x
59+
- uses: actions/setup-node@v4
60+
with:
61+
node-version: lts/*
62+
- if: github.ref_type == 'branch'
63+
run: |
64+
jq \
65+
--arg build "$GITHUB_RUN_NUMBER" \
66+
--arg commit "${GITHUB_SHA::8}" \
67+
'.version = .version + "-dev." + $build + "+" + $commit' \
68+
deno.json > deno.json.tmp
69+
mv deno.json.tmp deno.json
70+
- if: github.ref_type == 'tag'
71+
run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]'
72+
- run: 'deno task dnt "$(jq -r .version deno.json)"'
73+
env:
74+
DNT_TEST: false
75+
- run: |
76+
set -ex
77+
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
78+
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
79+
npm publish --provenance --access public
80+
else
81+
npm publish --provenance --access public --tag dev
82+
fi
83+
env:
84+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
85+
working-directory: ${{ github.workspace }}/npm/
86+
- run: deno publish --allow-dirty

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.dnt-import-map.json
2+
npm/

‎.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"denoland.vscode-deno",
4+
"streetsidesoftware.code-spell-checker"
5+
]
6+
}

‎.vscode/settings.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"deno.enable": true,
3+
"deno.unstable": [
4+
"temporal"
5+
],
6+
"editor.detectIndentation": false,
7+
"editor.indentSize": 2,
8+
"editor.insertSpaces": true,
9+
"files.eol": "\n",
10+
"files.insertFinalNewline": true,
11+
"files.trimFinalNewlines": true,
12+
"[json]": {
13+
"editor.defaultFormatter": "vscode.json-language-features",
14+
"editor.formatOnSave": true
15+
},
16+
"[jsonc]": {
17+
"editor.defaultFormatter": "vscode.json-language-features",
18+
"editor.formatOnSave": true
19+
},
20+
"[typescript]": {
21+
"editor.defaultFormatter": "denoland.vscode-deno",
22+
"editor.formatOnSave": true,
23+
"editor.codeActionsOnSave": {
24+
"source.sortImports": "always"
25+
}
26+
},
27+
"cSpell.words": [
28+
"fedify",
29+
"unlisten",
30+
"UNLOGGED"
31+
]
32+
}

‎.zed/settings.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"deno": {
3+
"enable": true
4+
},
5+
"ensure_final_newline_on_save": true,
6+
"format_on_save": "on",
7+
"formatter": "language_server",
8+
"languages": {
9+
"TypeScript": {
10+
"language_servers": [
11+
"deno",
12+
"!typescript-language-server",
13+
"!vtsls",
14+
"!eslint",
15+
"..."
16+
]
17+
},
18+
"TSX": {
19+
"language_servers": [
20+
"deno",
21+
"!typescript-language-server",
22+
"!vtsls",
23+
"!eslint",
24+
"..."
25+
]
26+
}
27+
},
28+
"show_wrap_guides": true,
29+
"wrap_guides": [80]
30+
}

‎LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MIT License
2+
3+
Copyright 2024 Hong Minhee
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎README.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!-- deno-fmt-ignore-file -->
2+
3+
@fedify/postgres: PostgreSQL drivers for Fedify
4+
===============================================
5+
6+
[![JSR][JSR badge]][JSR]
7+
[![npm][npm badge]][npm]
8+
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]
9+
10+
This package provides [Fedify]'s [`KvStore`] and [`MessageQueue`]
11+
implementations for PostgreSQL:
12+
13+
- [`PostgresKvStore`]
14+
- [`PostgresMessageQueue`]
15+
16+
~~~~ typescript
17+
import { createFederation } from "@fedify/fedify";
18+
import { PostgresKvStore, PostgresMessageQueue } from "@fedify/postgres";
19+
import postgres from "postgres";
20+
21+
const sql = postgres("postgresql://user:password@localhost/dbname");
22+
23+
const federation = createFederation({
24+
kv: new PostgresKvStore(sql),
25+
queue: new PostgresMessageQueue(sql),
26+
});
27+
~~~~
28+
29+
[JSR]: https://jsr.io/@fedify/postgres
30+
[JSR badge]: https://jsr.io/badges/@fedify/postgres
31+
[npm]: https://www.npmjs.com/package/@fedify/postgres
32+
[npm badge]: https://img.shields.io/npm/v/@fedify/postgres?logo=npm
33+
[GitHub Actions]: https://github.com/dahlia/fedify-postgres/actions/workflows/main.yaml
34+
[GitHub Actions badge]: https://github.com/dahlia/fedify-postgres/actions/workflows/main.yaml/badge.svg
35+
[Fedify]: https://fedify.dev/
36+
[`KvStore`]: https://jsr.io/@fedify/fedify/doc/federation/~/KvStore
37+
[`MessageQueue`]: https://jsr.io/@fedify/fedify/doc/federation/~/MessageQueue
38+
[`PostgresKvStore`]: https://jsr.io/@fedify/postgres/doc/federation/~/PostgresKvStore
39+
[`PostgresMessageQueue`]: https://jsr.io/@fedify/postgres/doc/federation/~/PostgresMessageQueue
40+
41+
42+
Installation
43+
------------
44+
45+
### Deno
46+
47+
~~~~ sh
48+
deno add @fedify/postgres
49+
~~~~
50+
51+
### Node.js
52+
53+
~~~~ sh
54+
npm install @fedify/postgres
55+
~~~~
56+
57+
### Bun
58+
59+
~~~~ sh
60+
bun add @fedify/postgres
61+
~~~~
62+
63+
64+
Changelog
65+
---------
66+
67+
### Version 0.1.0
68+
69+
To be released.

‎deno.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@fedify/postgres",
3+
"version": "0.1.0",
4+
"license": "MIT",
5+
"exports": {
6+
".": "./mod.ts",
7+
"./kv": "./src/kv.ts",
8+
"./mq": "./src/mq.ts"
9+
},
10+
"imports": {
11+
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
12+
"@fedify/fedify": "jsr:@fedify/fedify@^1.0.0-dev.410+8793b61b",
13+
"@std/assert": "jsr:@std/assert@^0.226.0",
14+
"@std/async": "jsr:@std/async@^1.0.5",
15+
"postgres": "npm:postgres@^3.4.4"
16+
},
17+
"unstable": [
18+
"temporal"
19+
],
20+
"exclude": [
21+
"npm"
22+
],
23+
"tasks": {
24+
"check": "deno fmt --check && deno lint && deno check */*.ts",
25+
"test": "deno test --allow-net --allow-env",
26+
"dnt": "deno run -A dnt.ts"
27+
}
28+
}

0 commit comments

Comments
 (0)
Please sign in to comment.