Skip to content

Commit 2e36c49

Browse files
Initialize
0 parents  commit 2e36c49

19 files changed

+2406
-0
lines changed

.github/workflows/publish.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Publish NPM package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: "20"
20+
registry-url: "https://registry.npmjs.org"
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
# - name: Test
26+
# run: npm test
27+
28+
- name: Check the version
29+
id: check
30+
run: |
31+
CURRENT_VERSION=$(jq -r .version package.json)
32+
echo "Current version: $CURRENT_VERSION"
33+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
34+
echo "Latest tag: $LATEST_TAG"
35+
36+
LATEST_VERSION=${LATEST_TAG#v}
37+
38+
if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ];
39+
then
40+
echo "Version is equal"
41+
echo "version_equal=true" >> $GITHUB_OUTPUT
42+
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
43+
else
44+
echo "Version is not equal"
45+
echo "version_equal=false" >> $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Build
49+
run: npm run build
50+
if: steps.check.outputs.version_equal == 'true'
51+
52+
- name: Publish
53+
if: steps.check.outputs.version_equal == 'true'
54+
run: npm publish --access public --no-git-checks
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
58+
# - name: Git Info Update
59+
# if: steps.check.outputs.version_equal == 'true'
60+
# run: |
61+
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
62+
# git config --local user.name "github-actions[bot]"
63+
- name: Create GitHub release
64+
if: steps.check.outputs.version_equal == 'true'
65+
run: |
66+
gh release create "v${{ steps.check.outputs.new_version }}" --title "v${{ steps.check.outputs.new_version }}"
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package-lock.json
2+
node_modules
3+
dist
4+
tsconfig.tsbuildinfo

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.github
2+
node_modules
3+
src
4+
tsconfig.json
5+
tsconfig.tsbuildinfo

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 discord.https
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Discord.https
2+
3+
[![npm version](https://img.shields.io/npm/v/discord.https.svg)](https://www.npmjs.com/package/discord.https)
4+
[![License](https://img.shields.io/npm/l/discord.https.svg)](LICENSE)
5+
[![Downloads](https://img.shields.io/npm/dm/discord.https.svg)](https://www.npmjs.com/package/discord.https)
6+
7+
**Discord.https** is a robust, modular library for implementing Discord HTTP interactions.
8+
9+
It handles various interactions and organizes them into modular routes, making your bot's code cleaner, easier to understand, and easier to maintain. It works seamlessly in both serverless and persistent server environments.
10+
11+
**Currently in development**
12+
13+
### To do:
14+
15+
- [ ] Build structures → reference: https://www.npmjs.com/package/@discordjs/structures
16+
- [ ] Build a simplified `npx create-app` command [in progress]
17+
- [ ] Implement tests
18+
- [x] HTTP adapters to support all hosting environments. Currently implemented: Node.js adapter for Node.js runtime and Cloudflare adapter for V8 isolates runtime [will be published soon]
19+
- [x] Examples [will be published soon]

package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "discord.https",
3+
"version": "1.0.0",
4+
"description": "Discord.https is a modular library for building and managing Discord HTTP interactions with the Discord API. It provides tools for routing and managing interaction efficiently.",
5+
"main": "./dist/index.js",
6+
"type": "module",
7+
"scripts": {
8+
"build": "tsc --build",
9+
"start": "cd dist && node ."
10+
},
11+
"types": "./dist/index.d.ts",
12+
"files": [
13+
"dist",
14+
"README.md"
15+
],
16+
"exports": {
17+
".": {
18+
"import": "./dist/index.js",
19+
"types": "./dist/index.d.ts"
20+
},
21+
"./router": {
22+
"import": "./dist/interactionRouter/index.js",
23+
"types": "./dist/interactionRouter/index.d.ts"
24+
}
25+
},
26+
"author": "discord.https",
27+
"license": "MIT",
28+
"dependencies": {
29+
"@discordjs/builders": "^1.11.3",
30+
"@discordjs/rest": "^2.6.0",
31+
"@discordjs/util": "^1.1.1",
32+
"@noble/ed25519": "^3.0.0",
33+
"@sapphire/snowflake": "^3.5.5",
34+
"chalk": "^5.6.0",
35+
"discord-api-types": "^0.38.22"
36+
},
37+
"devDependencies": {
38+
"@types/node": "^24.3.1"
39+
},
40+
"keywords": [
41+
"discord",
42+
"discord.js",
43+
"discord-http-interactions",
44+
"discord-interactions",
45+
"http-interactions",
46+
"discord.https",
47+
"discord-api",
48+
"interaction-router",
49+
"discord-commands",
50+
"discord-cloudflare"
51+
]
52+
}

src/adapter/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export interface HttpAdapter {
2+
listen(
3+
endpoint: string,
4+
handler: (req: any, res: any) => Promise<any>,
5+
...args: any[]
6+
): Promise<any> | any;
7+
8+
getRequestBody(req: any): Promise<Uint8Array>;
9+
}
10+
11+
export interface HttpAdapterSererResponse {
12+
headersSent: boolean;
13+
writeHead(status: number, headers?: Record<string, string>): void;
14+
end(chunk?: string | Buffer): void;
15+
}
16+
17+
export interface HttpAdapterRequest {
18+
method: string;
19+
url: string;
20+
headers: Record<string, string | string[]>;
21+
}

0 commit comments

Comments
 (0)