Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Split core in models and services #47

Merged
merged 2 commits into from
Dec 3, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/auth/FacebookAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OAuth2Client from "./OAuth2Client";
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Logger from "../services/Logger";
import Storage from "../services/Storage";

export default class FacebookAuth extends OAuth2Client {
GRAPH_API_VERSION: string = "v18.0";
Expand Down
4 changes: 2 additions & 2 deletions src/auth/InstagramAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FacebookAuth from "./FacebookAuth";
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Logger from "../services/Logger";
import Storage from "../services/Storage";

export default class InstagramAuth extends FacebookAuth {
async setup() {
Expand Down
4 changes: 2 additions & 2 deletions src/auth/LinkedInAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OAuth2Client from "./OAuth2Client";
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Logger from "../services/Logger";
import Storage from "../services/Storage";

export default class LinkedInAuth extends OAuth2Client {
API_VERSION = "v2";
Expand Down
2 changes: 1 addition & 1 deletion src/auth/OAuth2Client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "fs";
import * as http from "http";
import * as url from "url";
import Storage from "../core/Storage";
import Storage from "../services/Storage";

class DeferredResponseQuery {
promise: Promise<{ [key: string]: string | string[] }>;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/RedditAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OAuth2Client from "./OAuth2Client";
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Logger from "../services/Logger";
import Storage from "../services/Storage";

export default class RedditAuth extends OAuth2Client {
API_VERSION = "v1";
Expand Down
4 changes: 2 additions & 2 deletions src/auth/TwitterAuth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TwitterApi } from "twitter-api-v2";

import OAuth2Client from "./OAuth2Client";
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Logger from "../services/Logger";
import Storage from "../services/Storage";

export default class TwitterAuth extends OAuth2Client {
async setup() {
Expand Down
10 changes: 6 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
Fairpost cli handler
*/

import * as path from "path";
import "./bootstrap-cli";
import Fairpost from "./core/Fairpost";
import Logger from "./core/Logger";
import { PostStatus } from "./core/Post";

import * as path from "path";

import Fairpost from "./services/Fairpost";
import Logger from "./services/Logger";
import { PlatformId } from "./platforms";
import { PostStatus } from "./models/Post";

// arguments
const COMMAND = process.argv[2] ?? "help";
Expand Down
9 changes: 5 additions & 4 deletions src/core/Feed.ts → src/models/Feed.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as fs from "fs";
import Logger from "./Logger";
import Storage from "./Storage";
import Platform from "./Platform";

import Folder from "./Folder";
import Logger from "../services/Logger";
import Platform from "./Platform";
import { PlatformId } from "../platforms";
import Post from "./Post";
import { PostStatus } from "./Post";
import { PlatformId } from "../platforms";
import Storage from "../services/Storage";

/**
* Feed - the core handler of fairpost
Expand Down
3 changes: 2 additions & 1 deletion src/core/Folder.ts → src/models/Folder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from "fs";
import * as path from "path";
import Logger from "./Logger";

import Logger from "../services/Logger";

/**
* Folder - a folder within a feed
Expand Down
5 changes: 3 additions & 2 deletions src/core/Platform.ts → src/models/Platform.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as fs from "fs";
import Logger from "./Logger";

import Folder from "./Folder";
import Logger from "../services/Logger";
import { PlatformId } from "../platforms";
import Post from "./Post";
import { PostStatus } from "./Post";
import { PlatformId } from "../platforms";

/**
* Platform base class to extend all platforms on
Expand Down
3 changes: 2 additions & 1 deletion src/core/Post.ts → src/models/Post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from "fs";
import Logger from "./Logger";

import Folder from "./Folder";
import Logger from "../services/Logger";
import Platform from "./Platform";

/**
Expand Down
15 changes: 8 additions & 7 deletions src/platforms/Ayrshare.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import * as fs from "fs";
import * as path from "path";
import { randomUUID } from "crypto";

import Folder from "../models/Folder";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import Platform from "../core/Platform";
import Folder from "../core/Folder";
import Post from "../core/Post";
import { PostStatus } from "../core/Post";
import Post from "../models/Post";
import { PostStatus } from "../models/Post";
import Storage from "../services/Storage";
import { randomUUID } from "crypto";

/**
* Ayrshare base class to extend all ayrshare platforms on
Expand Down
9 changes: 5 additions & 4 deletions src/platforms/Ayrshare/AsFacebook.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Ayrshare from "../Ayrshare";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import * as fs from "fs";
import * as sharp from "sharp";

import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import { PlatformId } from "..";
import Post from "../../models/Post";

/**
* AsFacebook: support for facebook platform through Ayrshare
*/
Expand Down
9 changes: 5 additions & 4 deletions src/platforms/Ayrshare/AsInstagram.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Logger from "../../core/Logger";
import * as sharp from "sharp";

import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import Logger from "../../services/Logger";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import * as sharp from "sharp";
import Post from "../../models/Post";

/**
* AsInstagram: support for instagram platform through Ayrshare
Expand Down
11 changes: 6 additions & 5 deletions src/platforms/Ayrshare/AsLinkedIn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Logger from "../../core/Logger";
import Ayrshare from "../Ayrshare";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import * as fs from "fs";
import * as sharp from "sharp";

import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import Logger from "../../services/Logger";
import { PlatformId } from "..";
import Post from "../../models/Post";

/**
* AsLinkedIn: support for linkedin platform through Ayrshare
*/
Expand Down
6 changes: 3 additions & 3 deletions src/platforms/Ayrshare/AsReddit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import { PlatformId } from "..";
import Storage from "../../core/Storage";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import Post from "../../models/Post";
import Storage from "../../services/Storage";

/**
* AsReddit: support for reddit platform through Ayrshare
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/Ayrshare/AsTikTok.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import Post from "../../models/Post";

/**
* AsTikTok: support for tiktok platform through Ayrshare
Expand Down
11 changes: 6 additions & 5 deletions src/platforms/Ayrshare/AsTwitter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Logger from "../../core/Logger";
import Ayrshare from "../Ayrshare";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import * as fs from "fs";
import * as sharp from "sharp";

import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import Logger from "../../services/Logger";
import { PlatformId } from "..";
import Post from "../../models/Post";

/**
* AsTwitter: support for twitter platform through Ayrshare
*/
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/Ayrshare/AsYouTube.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ayrshare from "../Ayrshare";
import Folder from "../../models/Folder";
import { PlatformId } from "..";
import Folder from "../../core/Folder";
import Post from "../../core/Post";
import Post from "../../models/Post";

/**
* AsYouTube: support for youtube platform through Ayrshare
Expand Down
17 changes: 9 additions & 8 deletions src/platforms/Facebook.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Storage from "../core/Storage";
import Logger from "../core/Logger";
import Platform from "../core/Platform";
import { PlatformId } from ".";
import Folder from "../core/Folder";
import Post from "../core/Post";
import { PostStatus } from "../core/Post";
import FacebookAuth from "../auth/FacebookAuth";
import * as fs from "fs";
import * as path from "path";
import * as sharp from "sharp";

import FacebookAuth from "../auth/FacebookAuth";
import Folder from "../models/Folder";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import Post from "../models/Post";
import { PostStatus } from "../models/Post";
import Storage from "../services/Storage";

/**
* Facebook: support for facebook platform.
*
Expand Down
17 changes: 9 additions & 8 deletions src/platforms/Instagram.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Storage from "../core/Storage";
import Logger from "../core/Logger";
import Platform from "../core/Platform";
import InstagramAuth from "../auth/InstagramAuth";
import { PlatformId } from ".";
import Folder from "../core/Folder";
import Post from "../core/Post";
import { PostStatus } from "../core/Post";
import * as fs from "fs";
import * as path from "path";
import * as sharp from "sharp";

import Folder from "../models/Folder";
import InstagramAuth from "../auth/InstagramAuth";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import Post from "../models/Post";
import { PostStatus } from "../models/Post";
import Storage from "../services/Storage";

/**
* Instagram: support for instagram platform.
*
Expand Down
17 changes: 9 additions & 8 deletions src/platforms/LinkedIn.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Logger from "../core/Logger";
import Storage from "../core/Storage";
import Platform from "../core/Platform";
import { PlatformId } from ".";
import Folder from "../core/Folder";
import Post from "../core/Post";
import LinkedInAuth from "../auth/LinkedInAuth";
import { PostStatus } from "../core/Post";
import * as fs from "fs";
//import * as path from "path";
import * as sharp from "sharp";

import Folder from "../models/Folder";
import LinkedInAuth from "../auth/LinkedInAuth";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import Post from "../models/Post";
import { PostStatus } from "../models/Post";
import Storage from "../services/Storage";

export default class LinkedIn extends Platform {
id: PlatformId = PlatformId.LINKEDIN;
auth: LinkedInAuth;
Expand Down
18 changes: 10 additions & 8 deletions src/platforms/Reddit.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import Storage from "../core/Storage";
import Logger from "../core/Logger";
import RedditAuth from "../auth/RedditAuth";
import { PlatformId } from ".";
import Platform from "../core/Platform";
import Folder from "../core/Folder";
import Post, { PostStatus } from "../core/Post";
import * as fs from "fs";
import * as path from "path";
import { XMLParser } from "fast-xml-parser";
import * as sharp from "sharp";

import Post, { PostStatus } from "../models/Post";

import Folder from "../models/Folder";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import RedditAuth from "../auth/RedditAuth";
import Storage from "../services/Storage";
import { XMLParser } from "fast-xml-parser";

/**
* Reddit: support for reddit platform
*/
Expand Down
18 changes: 10 additions & 8 deletions src/platforms/Twitter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { TwitterApi } from "twitter-api-v2";
import Storage from "../core/Storage";
import Logger from "../core/Logger";
import TwitterAuth from "../auth/TwitterAuth";
import { PlatformId } from ".";
import Platform from "../core/Platform";
import Folder from "../core/Folder";
import Post, { PostStatus } from "../core/Post";
import * as fs from "fs";
import * as sharp from "sharp";

import Post, { PostStatus } from "../models/Post";

import Folder from "../models/Folder";
import Logger from "../services/Logger";
import Platform from "../models/Platform";
import { PlatformId } from ".";
import Storage from "../services/Storage";
import { TwitterApi } from "twitter-api-v2";
import TwitterAuth from "../auth/TwitterAuth";

/**
* Twitter: support for twitter platform
*/
Expand Down
Loading