quil.ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +58 -0
- package/lib/cjs/types/index.d.ts +23 -0
- package/lib/cjs/types/index.d.ts.map +1 -0
- package/lib/esm/index.mjs +49 -0
- package/lib/esm/types/index.d.ts +23 -0
- package/lib/esm/types/index.d.ts.map +1 -0
- package/package.json +48 -0
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Quil = void 0;
|
|
13
|
+
class Quil {
|
|
14
|
+
constructor(apiKey, guestbookId, debug = false) {
|
|
15
|
+
this.baseUrl = 'https://quil.punkfairie.net/api';
|
|
16
|
+
this.apiKey = apiKey;
|
|
17
|
+
this.guestbookId = guestbookId;
|
|
18
|
+
this.debug = debug;
|
|
19
|
+
}
|
|
20
|
+
get() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const issueReturn = 'Problem fetching guestbook, please try again later!';
|
|
23
|
+
const response = yield fetch(`${this.baseUrl}/guestbooks/${this.guestbookId}`, {
|
|
24
|
+
headers: {
|
|
25
|
+
'Authorize': `Bearer ${this.apiKey}`,
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
if (this.debug) {
|
|
30
|
+
console.log(response.status + ': ' + response.statusText);
|
|
31
|
+
}
|
|
32
|
+
return issueReturn;
|
|
33
|
+
}
|
|
34
|
+
const result = yield response.json();
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
write(data) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const issueReturn = 'Problem posting message, please try again later!';
|
|
41
|
+
const response = yield fetch(`${this.baseUrl}/guestbooks/${this.guestbookId}/messages`, {
|
|
42
|
+
headers: {
|
|
43
|
+
'Authorize': `Bearer ${this.apiKey}`,
|
|
44
|
+
},
|
|
45
|
+
body: data
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
if (this.debug) {
|
|
49
|
+
console.log(response.status + ': ' + response.statusText);
|
|
50
|
+
}
|
|
51
|
+
return issueReturn;
|
|
52
|
+
}
|
|
53
|
+
const result = yield response.json();
|
|
54
|
+
return result.created;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Quil = Quil;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string | null;
|
|
5
|
+
website: string | null;
|
|
6
|
+
text: string;
|
|
7
|
+
created_at: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Guestbook {
|
|
10
|
+
id: number;
|
|
11
|
+
title: string;
|
|
12
|
+
messages: Message[];
|
|
13
|
+
}
|
|
14
|
+
export declare class Quil {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
apiKey: number;
|
|
17
|
+
guestbookId: number;
|
|
18
|
+
debug: boolean;
|
|
19
|
+
constructor(apiKey: number, guestbookId: number, debug?: boolean);
|
|
20
|
+
get(): Promise<"Problem fetching guestbook, please try again later!" | Guestbook>;
|
|
21
|
+
write(data: FormData): Promise<true | "Problem posting message, please try again later!">;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,qBAAa,IAAI;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe;IAOjE,GAAG,IAAI,OAAO,CAAC,qDAAqD,GAAG,SAAS,CAAC;IAsBjF,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,kDAAkD,CAAC;CAsBhG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Quil = void 0;
|
|
4
|
+
class Quil {
|
|
5
|
+
baseUrl;
|
|
6
|
+
apiKey;
|
|
7
|
+
guestbookId;
|
|
8
|
+
debug;
|
|
9
|
+
constructor(apiKey, guestbookId, debug = false) {
|
|
10
|
+
this.baseUrl = 'https://quil.punkfairie.net/api';
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.guestbookId = guestbookId;
|
|
13
|
+
this.debug = debug;
|
|
14
|
+
}
|
|
15
|
+
async get() {
|
|
16
|
+
const issueReturn = 'Problem fetching guestbook, please try again later!';
|
|
17
|
+
const response = await fetch(`${this.baseUrl}/guestbooks/${this.guestbookId}`, {
|
|
18
|
+
headers: {
|
|
19
|
+
'Authorize': `Bearer ${this.apiKey}`,
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
if (this.debug) {
|
|
24
|
+
console.log(response.status + ': ' + response.statusText);
|
|
25
|
+
}
|
|
26
|
+
return issueReturn;
|
|
27
|
+
}
|
|
28
|
+
const result = await response.json();
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
async write(data) {
|
|
32
|
+
const issueReturn = 'Problem posting message, please try again later!';
|
|
33
|
+
const response = await fetch(`${this.baseUrl}/guestbooks/${this.guestbookId}/messages`, {
|
|
34
|
+
headers: {
|
|
35
|
+
'Authorize': `Bearer ${this.apiKey}`,
|
|
36
|
+
},
|
|
37
|
+
body: data
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
if (this.debug) {
|
|
41
|
+
console.log(response.status + ': ' + response.statusText);
|
|
42
|
+
}
|
|
43
|
+
return issueReturn;
|
|
44
|
+
}
|
|
45
|
+
const result = await response.json();
|
|
46
|
+
return result.created;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.Quil = Quil;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string | null;
|
|
5
|
+
website: string | null;
|
|
6
|
+
text: string;
|
|
7
|
+
created_at: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Guestbook {
|
|
10
|
+
id: number;
|
|
11
|
+
title: string;
|
|
12
|
+
messages: Message[];
|
|
13
|
+
}
|
|
14
|
+
export declare class Quil {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
apiKey: number;
|
|
17
|
+
guestbookId: number;
|
|
18
|
+
debug: boolean;
|
|
19
|
+
constructor(apiKey: number, guestbookId: number, debug?: boolean);
|
|
20
|
+
get(): Promise<"Problem fetching guestbook, please try again later!" | Guestbook>;
|
|
21
|
+
write(data: FormData): Promise<true | "Problem posting message, please try again later!">;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,qBAAa,IAAI;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe;IAOjE,GAAG,IAAI,OAAO,CAAC,qDAAqD,GAAG,SAAS,CAAC;IAsBjF,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,kDAAkD,CAAC;CAsBhG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quil.ts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A small library for working with the Quil API",
|
|
5
|
+
"types": "./lib/cjs/types/index.d.ts",
|
|
6
|
+
"main": "./lib/cjs/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rm -rf ./lib",
|
|
9
|
+
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
|
|
10
|
+
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
|
|
11
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
12
|
+
"prepack": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://codewith.babesonthe.net/punkfairie/quil.ts.git"
|
|
17
|
+
},
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Marley Rae",
|
|
20
|
+
"url": "https://punkfairie.net"
|
|
21
|
+
},
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://codewith.babesonthe.net/punkfairie/quil.ts/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://codewith.babesonthe.net/punkfairie/quil.ts",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"lib/**/*"
|
|
35
|
+
],
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./lib/esm/types/index.d.ts",
|
|
40
|
+
"default": "./lib/esm/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./lib/cjs/types/index.d.ts",
|
|
44
|
+
"default": "./lib/cjs/index.js"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|