Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Dart (Stable)",
"dockerComposeFile": "../docker/docker-compose.yml",
"service": "dart",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"overrideCommand": true,
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dart-code.dart-code"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "root",
"postCreateCommand": "dart pub get"
}
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.7.0

- uses: actions/checkout@v2

- name: Get dependencies
run: dart pub get

- name: Check formatting
run: dart format --set-exit-if-changed --output none .
run: dart format -l 200 --set-exit-if-changed --output none .

- name: Run lints
run: dart analyze --no-fatal-warnings

# TODO: Set up lemmy server for tests
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

# Contains credentials for tests
test/config.dart

docker/volumes/
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dart.lineLength": 200,
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
200
],
"editor.codeActionsOnSave": {
"source.fixAll": "always",
}
},
"files.exclude": {
"**/.git": false,
}
}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.1.0
## 1.0.0

- Initial version.
- Initial version.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Thunder (@thunder-app), Filip Krawczyk (@krawieck), Marcin Wojnarowski (@shilangyu)
Copyright (c) 2025 Thunder (@thunder-app), 2020 Filip Krawczyk (@krawieck), Marcin Wojnarowski (@shilangyu)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Lemmy Dart API Client

<div align="center">
<img width=200px height=200px src="https://raw.githubusercontent.com/LemmurOrg/lemmy_api_client/master/logo.svg"/>
<img width=200px height=200px src="https://raw.githubusercontent.com/LemmurOrg/lemmy_dart_client/master/logo.svg"/>

A Lemmy API Client built with Dart. Continuation of the original [Lemmy Dart API](https://github.com/LemmurOrg/lemmy_api_client) and [Liftoff Dart API](https://github.com/liftoff-app/lemmy_api_client).
A Lemmy API Client built with Dart. Continuation of the original [Lemmy Dart API](https://github.com/LemmurOrg/lemmy_dart_client) and [Liftoff Dart API](https://github.com/liftoff-app/lemmy_dart_client).

<img alt="Unsupported" src="https://img.shields.io/badge/0.17.x-unsupported-red">
<img alt="Limited support" src="https://img.shields.io/badge/0.18.x-limited_support-yellow">
Expand All @@ -19,7 +19,7 @@ Notice: While efforts are made to keep as much parity as possible with the Lemmy
## Usage

```dart
import 'package:lemmy_api_client/v3.dart';
import 'package:lemmy_dart_client/v3.dart';

Future<void> main() async {
// Initialize the Lemmy API Client with the given instance URI
Expand Down
15 changes: 3 additions & 12 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,14 @@

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types
linter:
rules:
- always_use_package_imports

# analyzer:
# exclude:
# - path/to/excluded/files/**

formatter:
page_width: 200

analyzer:
errors:
invalid_annotation_target: ignore

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

Expand Down
6 changes: 0 additions & 6 deletions build.yaml

This file was deleted.

123 changes: 123 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
x-logging: &default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "4"

services:

dart:
image: dart:3.7.2
volumes:
- ..:/workspaces/${localWorkspaceFolderBasename}
depends_on:
- lemmy
proxy:
image: nginx:1-alpine
ports:
# actual and only port facing any connection from outside
# Note, change the left number if port 1236 is already in use on your system
# You could use port 80 if you won't use a reverse proxy
- "1236:1236"
- "8536:8536"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro,Z
restart: unless-stopped
depends_on:
- pictrs
- lemmy-ui
logging: *default-logging

lemmy:
image: dessalines/lemmy:1.0.0-alpha.5
platform: linux/x86_64 # no arm64 support. uncomment platform if using m1.

# this hostname is used in nginx reverse proxy and also for lemmy ui to connect to the backend, do not change
hostname: lemmy
restart: unless-stopped
environment:
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
- RUST_BACKTRACE=full
ports:
# prometheus metrics can be enabled with the `prometheus` config option. they are available on
# port 10002, path /metrics by default
- "10002:10002"
volumes:
- ./lemmy.hjson:/config/config.hjson:Z
depends_on:
- postgres
- pictrs
logging: *default-logging

lemmy-ui:
# use "image" to pull down an already compiled lemmy-ui. make sure to comment out "build".
image: dessalines/lemmy-ui:0.19.10
platform: linux/x86_64 # no arm64 support. uncomment platform if using m1.

environment:
# this needs to match the hostname defined in the lemmy service
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8536
# set the outside hostname here
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:1236
- LEMMY_UI_HTTPS=false
- LEMMY_UI_DEBUG=true
depends_on:
- lemmy
restart: unless-stopped
logging: *default-logging
init: true

pictrs:
image: asonix/pictrs:0.5.17-pre.9
# this needs to match the pictrs url in lemmy.hjson
hostname: pictrs
# we can set options to pictrs like this, here we set max. image size and forced format for conversion
# entrypoint: /sbin/tini -- /usr/local/bin/pict-rs -p /mnt -m 4 --image-format webp
environment:
- PICTRS_OPENTELEMETRY_URL=http://otel:4137
- PICTRS__API_KEY=API_KEY
- RUST_LOG=debug
- RUST_BACKTRACE=full
- PICTRS__MEDIA__VIDEO_CODEC=vp9
- PICTRS__MEDIA__GIF__MAX_WIDTH=256
- PICTRS__MEDIA__GIF__MAX_HEIGHT=256
- PICTRS__MEDIA__GIF__MAX_AREA=65536
- PICTRS__MEDIA__GIF__MAX_FRAME_COUNT=400
user: 991:991
volumes:
- ./volumes/pictrs:/mnt:Z
restart: unless-stopped
logging: *default-logging

postgres:
image: pgautoupgrade/pgautoupgrade:16-alpine
# this needs to match the database host in lemmy.hson
# Tune your settings via
# https://pgtune.leopard.in.ua/#/
# You can use this technique to add them here
# https://stackoverflow.com/a/30850095/1655478
hostname: postgres
command:
[
"postgres",
"-c",
"session_preload_libraries=auto_explain",
"-c",
"auto_explain.log_min_duration=5ms",
"-c",
"auto_explain.log_analyze=true",
"-c",
"auto_explain.log_triggers=true",
"-c",
"track_activity_query_size=1048576",
]
expose:
- "5432"
environment:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
volumes:
- ./volumes/postgres:/var/lib/postgresql/data:Z
restart: unless-stopped
logging: *default-logging
28 changes: 28 additions & 0 deletions docker/lemmy.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
# for more info about the config, check out the documentation
# https://join-lemmy.org/docs/en/administration/configuration.html

# This is a minimal lemmy config for the dev / main branch. Do not use for a
# release / stable version.

setup: {
admin_username: "lemmy"
admin_password: "lemmylemmy"
site_name: "lemmy-dev"
}
database: {
connection: "postgres://lemmy:password@postgres:5432/lemmy"
}

hostname: "localhost"
bind: "0.0.0.0"
port: 8536

pictrs: {
url: "http://pictrs:8080/"
# api_key: "API_KEY"
image_mode: None
}

#opentelemetry_url: "http://otel:4137"
}
72 changes: 72 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream lemmy {
# this needs to map to the lemmy (server) docker service hostname
server "lemmy:8536";
}
upstream lemmy-ui {
# this needs to map to the lemmy-ui docker service hostname
server "lemmy-ui:1234";
}

server {
# this is the port inside docker, not the public one yet
listen 1236;
listen 8536;
# change if needed, this is facing the public web
server_name localhost;
server_tokens off;

gzip on;
gzip_types text/css application/javascript image/svg+xml;
gzip_vary on;

# Upload limit, relevant for pictrs
client_max_body_size 20M;

add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

# frontend general requests
location / {
# distinguish between ui requests and backend
# don't change lemmy-ui or lemmy here, they refer to the upstream definitions on top
set $proxpass "http://lemmy-ui";

if ($http_accept = "application/activity+json") {
set $proxpass "http://lemmy";
}
if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
set $proxpass "http://lemmy";
}
if ($request_method = POST) {
set $proxpass "http://lemmy";
}
proxy_pass $proxpass;

rewrite ^(.+)/+$ $1 permanent;
# Send actual client IP upstream
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# backend
location ~ ^/(api|pictrs|feeds|nodeinfo|version|.well-known) {
proxy_pass "http://lemmy";
# proxy common stuff
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

# Send actual client IP upstream
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
Loading
Loading