Giter VIP home page Giter VIP logo

lemmy.net's Introduction

Nuget GitHub Workflow Status (with event)


A (WIP) DI http client for Lemmy in dotnet

Usage

Run

dotnet add package Lemmy.Net.Client

Add this to you Startup

var services = new ServiceCollection();

services.AddLemmyClient(
    new Uri("<LEMMY INSTANCE URL>"),
    "<USERNAME>",
    "<PASSWORD>",
    //Optionally, add a pair of methods to read and write tokens.
    //This avoid having to reauthenticate on every request
    //WARNING: The file IO below is for demo purposes only!
    //please use something other than files to save your tokens!
    async username => File.Exists($"{username}.txt") ? File.ReadAllText($"{username}.txt") : "",                
    (username, jwtToken) =>  File.WriteAllText($"{username}.txt", jwtToken)                
);
var provider = services.BuildServiceProvider();

Then start the service

var lemmyService = provider.GetRequiredService<ILemmyService>();

or use it in your DI consumers

using Microsoft.AspNetCore.Mvc;
using YourNamespace.Services;

namespace YourNamespace.Controllers
{
    public class YourController : Controller
    {
        private readonly ILemmyService _lemmyService;

        public YourController(ILemmyService lemmyService)
        {
            _lemmyService = lemmyService;
        }

        // Your action methods go here
        public void DoAThing(){
            //Prints the names of all the communities on the instance
            foreach(var c in _lemmyService.Community.List().Communities)
            {
                Console.WriteLine(c.Community.Name);
            }
        }
        
    }
}

Supports

  • CRUD for Communities
  • CRUD for Posts (and voting)
  • CRUD for Comments (and voting)
  • CRUD for Private messages (and reporting)
  • Site actions
  • Reporting and Resolving
  • Modding and Admin actions
  • Captachs, registrations, password resets and email validation
  • Replies, Mentions and Notifications
  • Exponential retry policy

TODO

  • Better querying
  • Test Coverage
  • Model reuse

lemmy.net's People

Contributors

ydinkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ronsijm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.