Skip to content

Commit 83cbfbd

Browse files
committed
init
0 parents  commit 83cbfbd

File tree

159 files changed

+21240
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+21240
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
41+
- name: Build and push Docker image
42+
id: push
43+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
50+
- name: Generate artifact attestation
51+
uses: actions/attest-build-provenance@v1
52+
with:
53+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
54+
subject-digest: ${{ steps.push.outputs.digest }}
55+
push-to-registry: true
56+

.gitignore

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
132+
# intellij
133+
.idea/
134+
*.iml
135+
136+
db.sqlite
137+
publishing.md

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"trailingComma": "all",
3+
"tabWidth": 2,
4+
"semi": false,
5+
"singleQuote": true,
6+
"overrides": [
7+
{
8+
"files": "*.hbs",
9+
"options": {
10+
"singleQuote": false
11+
}
12+
}
13+
]
14+
}

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM node:22
2+
3+
COPY . .
4+
WORKDIR /app
5+
6+
RUN yarn install && yarn build
7+
8+
RUN mkdir /data/
9+
10+
EXPOSE 3000
11+
12+
ENV FEEDGEN_PORT=3000
13+
14+
# Change this to use a different bind address
15+
ENV FEEDGEN_LISTENHOST="0.0.0.0"
16+
# Set to something like db.sqlite to store persistently
17+
ENV FEEDGEN_SQLITE_LOCATION="/data/db.sqlite"
18+
# FEEDGEN_SQLITE_LOCATION=":memory:"
19+
# Don't change unless you're working in a different environment than the primary Bluesky network
20+
ENV FEEDGEN_SUBSCRIPTION_ENDPOINT="wss://bsky.network"
21+
# Set this to the hostname that you intend to run the service at
22+
ENV FEEDGEN_HOSTNAME="scalafeed.polyvariant.org"
23+
# Set this to the DID of the account you'll use to publish the feed
24+
# You can find your accounts DID by going to
25+
# https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${YOUR_HANDLE}
26+
ENV FEEDGEN_PUBLISHER_DID="did:plc:mvtjzkh3krhnpg6lfzpvonej"
27+
# Only use this if you want a service did different from did:web
28+
# FEEDGEN_SERVICE_DID="did:plc:abcde..."
29+
# Delay between reconnect attempts to the firehose subscription endpoint (in milliseconds)
30+
ENV FEEDGEN_SUBSCRIPTION_RECONNECT_DELAY=3000
31+
32+
CMD ["node", "./index.js"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Polyvariant
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, 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,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Scala feed generator for Bluesky
2+
3+
This repository is a customized fork of https://github.com/bluesky-social/feed-generator
4+
5+
Want to be up to date with Scala news on Bluesky? Just follow the feed at https://bsky.app/profile/michal.pawlik.dev/feed/scala-feed
6+
7+
# Implementation details
8+
9+
## Content collection
10+
11+
The [FirehoseSubscription.ts](src/FirehoseSubscription.ts) is a class that collects selected messages in the database. It also removes them from the feed if they are removed upstream.
12+
13+
## Content filtering
14+
15+
The `isAboutScala` function defined in [src/scala/index.ts](src/scala/index.ts) decides if content should be saved to database.
16+
17+
## Feed generation algorithm
18+
19+
You can find the algorithm generating the feed in [src/algos/scala-feed.ts](src/algos/scala-feed.ts). It simply fetches all known records from database sorted by indexing time, there's no sophisticated logic involved.

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
transform: {'^.+\\.ts?$': 'ts-jest'},
3+
testEnvironment: 'node',
4+
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
5+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
6+
};
7+
8+

package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "scala-feed",
3+
"version": "1.0.0",
4+
"description": "atproto feed for everything related to Scala ecosystem",
5+
"main": "index.js",
6+
"repository": "[email protected]:polyvariant/bsk-scala-feed.git",
7+
"author": "majk-p <[email protected]>",
8+
"license": "MIT",
9+
"scripts": {
10+
"publishFeed": "ts-node scripts/publishFeedGen.ts",
11+
"unpublishFeed": "ts-node scripts/unpublishFeedGen.ts",
12+
"start": "ts-node src/index.ts",
13+
"build": "tsc",
14+
"test": "jest",
15+
"test:watch": "jest --watch",
16+
"test:coverage": "jest --coverage",
17+
"test:lint": "eslint ."
18+
},
19+
"dependencies": {
20+
"@atproto/api": "^0.6.20",
21+
"@atproto/identity": "^0.2.1",
22+
"@atproto/lexicon": "^0.2.2",
23+
"@atproto/repo": "^0.3.2",
24+
"@atproto/syntax": "^0.1.2",
25+
"@atproto/xrpc-server": "^0.6.0",
26+
"better-sqlite3": "^11.3.0",
27+
"dotenv": "^16.0.3",
28+
"express": "^4.18.2",
29+
"kysely": "^0.27.4",
30+
"multiformats": "^9.9.0"
31+
},
32+
"devDependencies": {
33+
"@types/better-sqlite3": "^7.6.11",
34+
"@types/express": "^4.17.17",
35+
"@types/jest": "^29.5.14",
36+
"@types/node": "^20.1.2",
37+
"inquirer": "^12.0.1",
38+
"jest": "^29.7.0",
39+
"ts-jest": "^29.2.5",
40+
"ts-node": "^10.9.1",
41+
"typescript": "^5.0.4"
42+
},
43+
"engines": {
44+
"node": ">= 18",
45+
"yarn": "1"
46+
}
47+
}

0 commit comments

Comments
 (0)