This repository has been archived by the owner on Oct 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from WerdoxDev/release-0.3
release 0.3
- Loading branch information
Showing
59 changed files
with
1,268 additions
and
784 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 3, | ||
"useTabs": false, | ||
"printWidth": 135 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
export default [ | ||
{ files: ["**/*.{js,mjs,cjs,ts}"] }, | ||
{ languageOptions: { globals: globals.browser } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommendedTypeChecked, | ||
...tseslint.configs.stylisticTypeChecked, | ||
{ | ||
languageOptions: { parserOptions: { project: "tsconfig.json" } }, | ||
rules: { | ||
"@typescript-eslint/consistent-type-definitions": ["error", "type"], | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-misused-promises": "off", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-redundant-type-constituents": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
varsIgnorePattern: "^_[A-Za-z0-9]+$", | ||
argsIgnorePattern: "^_[A-Za-z0-9]+$", | ||
}, | ||
], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
{ | ||
"name": "huginn-api", | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"start": "bun --watch ./src/index.ts" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "latest", | ||
"@typescript-eslint/eslint-plugin": "^6.9.1", | ||
"@typescript-eslint/parser": "^6.9.1", | ||
"eslint": "^8.52.0" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"jose": "^5.1.0" | ||
} | ||
"name": "huginn-api", | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"start": "bun --watch ./src/index.ts" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.6.0", | ||
"@types/bun": "^1.1.6", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"eslint": "^9.6.0", | ||
"globals": "^15.7.0", | ||
"typescript": "^5.5.3", | ||
"typescript-eslint": "^7.15.0" | ||
}, | ||
"dependencies": { | ||
"eventemitter3": "^5.0.1", | ||
"jose": "^5.6.2" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
APIDeleteDMChannelResult, | ||
APIGetChannelByIdResult, | ||
APIGetChannelMessagesResult, | ||
APIGetMessageByIdResult, | ||
APIGetUserChannelsResult, | ||
APIPostDMChannelJSONBody, | ||
APIPostDMChannelResult, | ||
APIPostDefaultMessageJSONBody, | ||
APIPostDefaultMessageResult, | ||
} from "@shared/api-types"; | ||
import { Routes } from "@shared/routes"; | ||
import { Snowflake } from "@shared/snowflake"; | ||
import { REST } from "../rest/rest"; | ||
|
||
export class ChannelAPI { | ||
private readonly rest: REST; | ||
|
||
public constructor(rest: REST) { | ||
this.rest = rest; | ||
} | ||
|
||
public async get(channelId: Snowflake): Promise<APIGetChannelByIdResult> { | ||
return this.rest.get(Routes.channel(channelId), { auth: true }) as Promise<APIGetChannelByIdResult>; | ||
} | ||
|
||
public async getAll(): Promise<APIGetUserChannelsResult> { | ||
return this.rest.get(Routes.userChannels(), { auth: true }) as Promise<APIGetUserChannelsResult>; | ||
} | ||
|
||
public async getMessage(channelId: Snowflake, messageId: Snowflake): Promise<APIGetMessageByIdResult> { | ||
return this.rest.get(Routes.channelMessage(channelId, messageId), { auth: true }) as Promise<APIGetMessageByIdResult>; | ||
} | ||
|
||
public async getMessages(channelId: Snowflake, limit?: number): Promise<APIGetChannelMessagesResult> { | ||
return this.rest.get(Routes.channelMessages(channelId), { | ||
auth: true, | ||
query: new URLSearchParams({ limit: limit?.toString() ?? "" }), | ||
}) as Promise<APIGetChannelMessagesResult>; | ||
} | ||
|
||
public async createDM(body: APIPostDMChannelJSONBody): Promise<APIPostDMChannelResult> { | ||
return this.rest.post(Routes.userChannels(), { body, auth: true }) as Promise<APIPostDMChannelResult>; | ||
} | ||
|
||
public async deleteDM(channelId: Snowflake): Promise<APIDeleteDMChannelResult> { | ||
return this.rest.delete(Routes.channel(channelId), { auth: true }) as Promise<APIDeleteDMChannelResult>; | ||
} | ||
|
||
public async createMessage(channelId: Snowflake, body: APIPostDefaultMessageJSONBody): Promise<APIPostDefaultMessageResult> { | ||
return this.rest.post(Routes.channelMessages(channelId), { body, auth: true }) as Promise<APIPostDefaultMessageResult>; | ||
} | ||
|
||
// public async typing(channelId: Snowflake) { | ||
// return this.rest.post(Routes.channelTyping(channelId), { auth: true }); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { APIGetUserRelationshipByIdResult, APIGetUserRelationshipsResult, APIPostRelationshipJSONBody } from "@shared/api-types"; | ||
import { Routes } from "@shared/routes"; | ||
import { Snowflake } from "@shared/snowflake"; | ||
import { REST } from "../rest/rest"; | ||
|
||
export class RelationshipAPI { | ||
private readonly rest: REST; | ||
|
||
public constructor(rest: REST) { | ||
this.rest = rest; | ||
} | ||
|
||
public async get(userId: Snowflake): Promise<APIGetUserRelationshipByIdResult> { | ||
return this.rest.get(Routes.userRelationship(userId), { auth: true }) as Promise<APIGetUserRelationshipByIdResult>; | ||
} | ||
|
||
public async getAll(): Promise<APIGetUserRelationshipsResult> { | ||
return this.rest.get(Routes.userRelationships(), { auth: true }) as Promise<APIGetUserRelationshipsResult>; | ||
} | ||
|
||
public async createRelationship(body: APIPostRelationshipJSONBody): Promise<unknown> { | ||
return this.rest.post(Routes.userRelationships(), { body, auth: true }); | ||
} | ||
|
||
public async createRelationshipByUserId(userId: Snowflake): Promise<unknown> { | ||
return this.rest.put(Routes.userRelationship(userId), { auth: true }); | ||
} | ||
|
||
public async delete(userId: Snowflake): Promise<unknown> { | ||
return this.rest.delete(Routes.userRelationship(userId), { auth: true }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.