Code Monkey home page Code Monkey logo

adelite's People

Contributors

aldy505 avatar elianiva avatar

Watchers

 avatar  avatar

adelite's Issues

Implement GiteaProvider as GitProvider to fetch repository releases

The GitProvider interface provides a function to call the Gitea API for getting a specific repository's release data. With undici installed and since we're not using any Gitea API SDK (because we only need this single endpoint), implement the getReleases function to do that.

export class GiteaProvider implements BaseGitProvider {
getReleases(owner: string, repo: string): Promise<Release[]> {
// See https://docs.gitea.com/api/1.20/#tag/repository/operation/repoListReleases
throw new Error("Method not implemented.");
}

Implement TelegramProvider as NotificationProvider to send releases notification

The NotificationProvider interface provides a function abstraction to send a notification through a certain provider, for this issue, it's via Telegram. Using grammy, implement message sending to a specific chatId.

Since there is no constructor, you should create one that bridge the gap between the configuration (in which where we would store the botToken and chatId) and what's needed by grammy.

export class TelegramProvider implements BaseNotificationProvider {
notify(releases: Release[], abortSignal?: AbortSignal | undefined): Promise<void> {
throw new Error("Method not implemented.");
}

You can see the configuration for Telegram here:

adelite/src/config.ts

Lines 21 to 24 in dff5d23

telegram: z.object({
bot_token: z.string(),
chat_id: z.string()
}).optional(),

Implement GithubAdapter as GitProvider to fetch repository release

The GitProvider interface provides a function to call the Github API for getting a specific repository's release data. With undici installed and since we're not using any Github API SDK (because we only need this single endpoint), implement the getReleases function to do that.

export class GithubAdapter implements BaseGitProvider {
public getReleases(owner: string, repo: string): Promise<Release[]> {
// See https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases
throw new Error("unimplemented");
}
}

Implement ForgejoProvider as GitProvider to fetch repository releases

The GitProvider interface provides a function to call the Forgejo API for getting a specific repository's release data. With undici installed and since we're not using any Forgejo API SDK (because we only need this single endpoint), implement the getReleases function to do that.

As a side note: Yes, I understand that Forgejo and Gitea has similar API. We might benefit from a code reuse, yet I'm seeing a pattern that Forgejo is going to a separate way from Gitea, resulting in a probable API incompatibilities between the two.

export class ForgejoProvider implements BaseGitProvider {
getReleases(owner: string, repo: string): Promise<Release[]> {
// See https://codeberg.org/api/swagger#/repository/repoListReleases
// Also see https://forgejo.org/docs/latest/user/api-usage/#authentication
throw new Error("Method not implemented.");
}

Implement GogsProvider as GitProvider to fetch repository releases

The GitProvider interface provides a function to call the Gogs API for getting a specific repository's release data. With undici installed and since we're not using any Gogs API SDK (because we only need this single endpoint), implement the getReleases function to do that.

export class GogsProvider implements BaseGitProvider {
getReleases(owner: string, repo: string): Promise<Release[]> {
// See https://github.com/gogs/docs-api/blob/master/Repositories/Releases.md
throw new Error("Method not implemented.");
}

Implement WebhookProvider as NotificationProvider to send releases notification

The NotificationProvider interface provides a function abstraction to send a notification through a certain provider, for this issue, it's via Webhook (you can learn about what is webhook here). Using undici, implement notification through webhook.

Since the class don't have a constructor yet, it's your opportunity to also create the constructor. An extra feature would be to implement a retry mechanism in case the receiving party (the server in which we're hitting on) didn't response with 2xx or 4xx status code. We should retry at most 5 times using exponential backoff -- but again, this retry feature is a nice to have one, it's not required from the start.

export class WebhookProvider implements BaseNotificationProvider {
notify(releases: Release[], abortSignal?: AbortSignal | undefined): Promise<void> {
throw new Error("Method not implemented.");
}

The configuration for webhook provider can be found here, you can add more configuration if you feel like this can be configured more.

adelite/src/config.ts

Lines 25 to 28 in dff5d23

webhook: z.object({
url: z.string(),
skip_tls_verify: z.boolean().default(false)
})

Implement GitlabProvider as GitProvider to fetch repository releases

The GitProvider interface provides a function to call the Gitlab API for getting a specific repository's release data. With undici installed and since we're not using any Gitlab API SDK (because we only need this single endpoint), implement the getReleases function to do that.

export class GitlabProvider implements BaseGitProvider {
getReleases(owner: string, repo: string): Promise<Release[]> {
// See https://docs.gitlab.com/ee/api/releases/#list-releases
throw new Error("Method not implemented.");
}

Implement SMTPProvider as NotificationProvider to send releases notification

The NotificationProvider interface provides a function abstraction to send a notification through a certain provider, for this issue, it's via SMTP (email). Using emailjs, implement mail sending mechanism through SMTP.

If you're not sure about the message content, just send a normal text. I'm sure that we can address the correct and proper email message in a separate issue.

export class SMTPProvider implements BaseNotificationProvider {
private readonly client: SMTPClient;
constructor(config: SMTPConfig) {
this.client = new SMTPClient({
user: config.user,
password: config.password,
host: config.host,
port: config.port,
});
}
notify(releases: Release[], abortSignal?: AbortSignal | undefined): Promise<void> {
throw new Error("Method not implemented.");
}

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.