Skip to content

Commit

Permalink
feat(core): http-only wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Mar 27, 2023
1 parent b8b852e commit 13c875d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
"module": "./dist/index.mjs",
"typings": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./http-only": {
"import": "./dist/http-only.mjs",
"require": "./dist/http-only.js",
"types": "./dist/http-only.d.ts"
}
},
"directories": {
"lib": "src",
Expand Down Expand Up @@ -59,6 +66,7 @@
"@types/node": "16.18.20",
"@vitest/coverage-c8": "^0.29.7",
"cross-env": "^7.0.3",
"esbuild-plugin-version-injector": "^1.1.0",
"eslint": "^8.36.0",
"eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/http-only.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { REST } from '@discordjs/rest';
import { API } from './api/index.js';
import type { ClientOptions } from './client';

export class Client {
public readonly rest: REST;

public readonly api: API;

public constructor({ rest }: Pick<ClientOptions, 'rest'>) {
this.rest = rest;
this.api = new API(rest);
}
}
7 changes: 7 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ export * from './client.js';
export * from './util/index.js';

export * from 'discord-api-types/v10';

/**
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/core/#readme | @discordjs/core} version
* that you are currently using.
*/
// This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
export const version = '[VI]{{inject}}[/VI]' as string;
9 changes: 8 additions & 1 deletion packages/core/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
import { createTsupConfig } from '../../tsup.config.js';

export default createTsupConfig({});
export default createTsupConfig({
entry: {
index: 'src/index.ts',
'http-only': 'src/http-only.ts',
},
esbuildPlugins: [esbuildPluginVersionInjector()],
});
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,7 @@ __metadata:
"@vladfrangu/async_event_emitter": ^2.1.4
cross-env: ^7.0.3
discord-api-types: ^0.37.37
esbuild-plugin-version-injector: ^1.1.0
eslint: ^8.36.0
eslint-config-neon: ^0.1.41
eslint-formatter-pretty: ^5.0.0
Expand Down

0 comments on commit 13c875d

Please sign in to comment.