mirror of
https://codeberg.org/reflect/reflect-client-js.git
synced 2025-09-13 23:43:41 +02:00
fix: ESM exports (#2)
* wip: 2023-09-20T13:43:23+0200 (1695210203) * wip: 2023-09-20T12:53:34+0200 (1695207214) * wip: 2023-09-20T12:53:34+0200 (1695207214) * wip: 2023-11-07T14:37:18+0100 (1699364238)
This commit is contained in:
parent
e7810249aa
commit
278868984d
4 changed files with 75 additions and 8 deletions
52
.npmignore
Normal file
52
.npmignore
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/src
|
||||||
|
|
||||||
|
# Bootstrapping #
|
||||||
|
#################
|
||||||
|
/node_modules
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.ini
|
||||||
|
.env.backup
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
public/robots.txt
|
||||||
|
|
||||||
|
# OS generated files #
|
||||||
|
######################
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
Icon?
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Tool specific files #
|
||||||
|
#######################
|
||||||
|
# vim
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
# sublime text & textmate
|
||||||
|
*.sublime-*
|
||||||
|
*.stTheme.cache
|
||||||
|
*.tmlanguage.cache
|
||||||
|
*.tmPreferences.cache
|
||||||
|
# Eclipse
|
||||||
|
.settings/*
|
||||||
|
# JetBrains, aka PHPStorm, IntelliJ IDEA
|
||||||
|
.idea/*
|
||||||
|
# NetBeans
|
||||||
|
nbproject/*
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
# Sass preprocessor
|
||||||
|
.sass-cache/
|
11
package.json
11
package.json
|
@ -1,7 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "reflect-client",
|
"name": "reflect-client",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"main": "build/Reflect.js",
|
"main": "build/Reflect.js",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": {
|
||||||
|
"types": "./src/Reflect.ts",
|
||||||
|
"default": "./build/Reflect.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { Method } from "./Method";
|
import { Method } from "./Method.js";
|
||||||
|
|
||||||
|
// Export Method as importable directly from the Reflect.js ESM
|
||||||
|
export { Method };
|
||||||
|
|
||||||
// Connect to a Reflect API instance over HTTP
|
// Connect to a Reflect API instance over HTTP
|
||||||
export default class Client {
|
export default class Client {
|
||||||
|
@ -16,7 +19,12 @@ export default class Client {
|
||||||
|
|
||||||
// Set API key to use for all requests
|
// Set API key to use for all requests
|
||||||
private setApiKey(key: string): void {
|
private setApiKey(key: string): void {
|
||||||
this.headers["Authentication"] = `Bearer ${key}`;
|
this.headers["Authorization"] = `Bearer ${key}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get fully qualified URL to endpoint
|
||||||
|
private getEndpoint(endpoint: string): string {
|
||||||
|
return this.url + endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call a Reflect API endpoint with method and optional payload
|
// Call a Reflect API endpoint with method and optional payload
|
||||||
|
@ -32,6 +40,6 @@ export default class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch and return Response object
|
// Fetch and return Response object
|
||||||
return await fetch(endpoint, options);
|
return await fetch(this.getEndpoint(endpoint), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,9 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"module": "amd",
|
"module": "NodeNext",
|
||||||
"target": "ES6",
|
"outDir": "./build"
|
||||||
"rootDir": "./src",
|
|
||||||
"outFile": "./build/Reflect.js"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue