@pluto90/n8n-nodes-gate1253 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/README.md +28 -0
- package/credentials/Gate1253Api.credentials.ts +21 -0
- package/dist/credentials/Gate1253Api.credentials.d.ts +6 -0
- package/dist/credentials/Gate1253Api.credentials.js +23 -0
- package/dist/credentials/Gate1253Api.credentials.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/Gate1253/Gate1253.node.d.ts +5 -0
- package/dist/nodes/Gate1253/Gate1253.node.js +182 -0
- package/dist/nodes/Gate1253/Gate1253.node.js.map +1 -0
- package/index.ts +7 -0
- package/nodes/Gate1253/Gate1253.node.ts +190 -0
- package/package.json +33 -0
- package/tsconfig.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @pluto90/n8n-nodes-gate1253
|
|
2
|
+
|
|
3
|
+
This is an n8n community node to use the Gate1253 URL shortener service.
|
|
4
|
+
|
|
5
|
+
- **Homepage**: [https://gate1253.page.dev](https://gate1253.page.dev)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n documentation.
|
|
10
|
+
|
|
11
|
+
Normally, you can install it via the n8n UI or by running:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @pluto90/n8n-nodes-gate1253
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Operations
|
|
18
|
+
|
|
19
|
+
### URL
|
|
20
|
+
- **Shorten**: Create a shortened URL with various redirection types (`r1`, `r2`, `r3`, `r5`).
|
|
21
|
+
|
|
22
|
+
## Credentials
|
|
23
|
+
|
|
24
|
+
Requires a Gate1253 API Key for `r1` type (expiring) or when using custom aliases.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ICredentialType,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
} from 'n8n-workflow';
|
|
5
|
+
|
|
6
|
+
export class Gate1253Api implements ICredentialType {
|
|
7
|
+
name = 'gate1253Api';
|
|
8
|
+
displayName = 'Gate1253 API';
|
|
9
|
+
properties: INodeProperties[] = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
name: 'apiKey',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: {
|
|
15
|
+
password: true,
|
|
16
|
+
},
|
|
17
|
+
default: '',
|
|
18
|
+
description: 'The API Key to use for authentication',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Gate1253Api = void 0;
|
|
4
|
+
class Gate1253Api {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'gate1253Api';
|
|
7
|
+
this.displayName = 'Gate1253 API';
|
|
8
|
+
this.properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'API Key',
|
|
11
|
+
name: 'apiKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: {
|
|
14
|
+
password: true,
|
|
15
|
+
},
|
|
16
|
+
default: '',
|
|
17
|
+
description: 'The API Key to use for authentication',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Gate1253Api = Gate1253Api;
|
|
23
|
+
//# sourceMappingURL=Gate1253Api.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Gate1253Api.credentials.js","sourceRoot":"","sources":["../../credentials/Gate1253Api.credentials.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAAxB;QACI,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,cAAc,CAAC;QAC7B,eAAU,GAAsB;YAC5B;gBACI,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACT,QAAQ,EAAE,IAAI;iBACjB;gBACD,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,uCAAuC;aACvD;SACJ,CAAC;IACN,CAAC;CAAA;AAfD,kCAeC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Gate1253Api = exports.Gate1253 = void 0;
|
|
4
|
+
const Gate1253_node_1 = require("./nodes/Gate1253/Gate1253.node");
|
|
5
|
+
Object.defineProperty(exports, "Gate1253", { enumerable: true, get: function () { return Gate1253_node_1.Gate1253; } });
|
|
6
|
+
const Gate1253Api_credentials_1 = require("./credentials/Gate1253Api.credentials");
|
|
7
|
+
Object.defineProperty(exports, "Gate1253Api", { enumerable: true, get: function () { return Gate1253Api_credentials_1.Gate1253Api; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,kEAA0D;AAItD,yFAJK,wBAAQ,OAIL;AAHZ,mFAAoE;AAIhE,4FAJK,qCAAW,OAIL"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Gate1253 = void 0;
|
|
4
|
+
class Gate1253 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.description = {
|
|
7
|
+
displayName: 'Gate1253',
|
|
8
|
+
name: 'gate1253',
|
|
9
|
+
icon: 'file:gate1253.svg',
|
|
10
|
+
group: ['transform'],
|
|
11
|
+
version: 1,
|
|
12
|
+
description: 'Shorten URLs using Gate1253 service',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: 'Gate1253',
|
|
15
|
+
},
|
|
16
|
+
inputs: ['main'],
|
|
17
|
+
outputs: ['main'],
|
|
18
|
+
credentials: [
|
|
19
|
+
{
|
|
20
|
+
name: 'gate1253Api',
|
|
21
|
+
required: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
properties: [
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Resource',
|
|
27
|
+
name: 'resource',
|
|
28
|
+
type: 'options',
|
|
29
|
+
noDataExpression: true,
|
|
30
|
+
options: [
|
|
31
|
+
{
|
|
32
|
+
name: 'URL',
|
|
33
|
+
value: 'url',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
default: 'url',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Operation',
|
|
40
|
+
name: 'operation',
|
|
41
|
+
type: 'options',
|
|
42
|
+
noDataExpression: true,
|
|
43
|
+
displayOptions: {
|
|
44
|
+
show: {
|
|
45
|
+
resource: [
|
|
46
|
+
'url',
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
options: [
|
|
51
|
+
{
|
|
52
|
+
name: 'Shorten',
|
|
53
|
+
value: 'shorten',
|
|
54
|
+
description: 'Shorten a URL',
|
|
55
|
+
action: 'Shorten a URL',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
default: 'shorten',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
displayName: 'URL to Shorten',
|
|
62
|
+
name: 'url',
|
|
63
|
+
type: 'string',
|
|
64
|
+
required: true,
|
|
65
|
+
displayOptions: {
|
|
66
|
+
show: {
|
|
67
|
+
resource: ['url'],
|
|
68
|
+
operation: ['shorten'],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
default: '',
|
|
72
|
+
description: 'The URL to shorten',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
displayName: 'Type',
|
|
76
|
+
name: 'type',
|
|
77
|
+
type: 'options',
|
|
78
|
+
options: [
|
|
79
|
+
{
|
|
80
|
+
name: 'R1 (Expiring)',
|
|
81
|
+
value: 'r1',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'R2 (Custom Alias Only)',
|
|
85
|
+
value: 'r2',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'R3 (Default)',
|
|
89
|
+
value: 'r3',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'R5 (Large File)',
|
|
93
|
+
value: 'r5',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
default: 'r3',
|
|
97
|
+
description: 'The redirect type',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Custom Alias',
|
|
101
|
+
name: 'alias',
|
|
102
|
+
type: 'string',
|
|
103
|
+
displayOptions: {
|
|
104
|
+
show: {
|
|
105
|
+
type: ['r2', 'r3', 'r5'],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
default: '',
|
|
109
|
+
description: 'Optional custom alias (requires API Key)',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Expires At',
|
|
113
|
+
name: 'expiresAt',
|
|
114
|
+
type: 'dateTime',
|
|
115
|
+
required: true,
|
|
116
|
+
displayOptions: {
|
|
117
|
+
show: {
|
|
118
|
+
type: ['r1'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
default: '',
|
|
122
|
+
description: 'Expiration date (required for R1, requires API Key)',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async execute() {
|
|
128
|
+
const items = this.getInputData();
|
|
129
|
+
const returnData = [];
|
|
130
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
131
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
132
|
+
for (let i = 0; i < items.length; i++) {
|
|
133
|
+
try {
|
|
134
|
+
if (resource === 'url') {
|
|
135
|
+
if (operation === 'shorten') {
|
|
136
|
+
const url = this.getNodeParameter('url', i);
|
|
137
|
+
const type = this.getNodeParameter('type', i);
|
|
138
|
+
const body = {
|
|
139
|
+
url,
|
|
140
|
+
type,
|
|
141
|
+
};
|
|
142
|
+
if (type === 'r1') {
|
|
143
|
+
body.expiresAt = this.getNodeParameter('expiresAt', i);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const alias = this.getNodeParameter('alias', i);
|
|
147
|
+
if (alias) {
|
|
148
|
+
body.alias = alias;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const credentials = await this.getCredentials('gate1253Api');
|
|
152
|
+
const headers = {
|
|
153
|
+
'Content-Type': 'application/json',
|
|
154
|
+
};
|
|
155
|
+
if (credentials === null || credentials === void 0 ? void 0 : credentials.apiKey) {
|
|
156
|
+
headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
|
157
|
+
}
|
|
158
|
+
const options = {
|
|
159
|
+
method: 'POST',
|
|
160
|
+
body,
|
|
161
|
+
headers,
|
|
162
|
+
uri: `https://api.gate1253.workers.dev/api/shorten`,
|
|
163
|
+
json: true,
|
|
164
|
+
};
|
|
165
|
+
const responseData = await this.helpers.request(options);
|
|
166
|
+
returnData.push({ json: responseData });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (this.continueOnFail()) {
|
|
172
|
+
returnData.push({ json: { error: error.message } });
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return [returnData];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.Gate1253 = Gate1253;
|
|
182
|
+
//# sourceMappingURL=Gate1253.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Gate1253.node.js","sourceRoot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4BACZ,MAAM,EAAE,MAA6B;4BACrC,IAAI;4BACJ,OAAO;4BACP,GAAG,EAAE,8CAA8C;4BACnD,IAAI,EAAE,IAAI;yBACb,CAAC;wBAEF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAQ,CAAC,OAAO,CAAC,CAAC;wBAC1D,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBAC5C,CAAC;gBACL,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBACxB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;oBACpD,SAAS;gBACb,CAAC;gBACD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AApLD,4BAoLC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IDataObject,
|
|
3
|
+
IExecuteFunctions,
|
|
4
|
+
IHttpRequestMethods,
|
|
5
|
+
INodeExecutionData,
|
|
6
|
+
INodeType,
|
|
7
|
+
INodeTypeDescription,
|
|
8
|
+
} from 'n8n-workflow';
|
|
9
|
+
|
|
10
|
+
export class Gate1253 implements INodeType {
|
|
11
|
+
description: INodeTypeDescription = {
|
|
12
|
+
displayName: 'Gate1253',
|
|
13
|
+
name: 'gate1253',
|
|
14
|
+
icon: 'file:gate1253.svg',
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
description: 'Shorten URLs using Gate1253 service',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Gate1253',
|
|
20
|
+
},
|
|
21
|
+
inputs: ['main'],
|
|
22
|
+
outputs: ['main'],
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'gate1253Api',
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Resource',
|
|
32
|
+
name: 'resource',
|
|
33
|
+
type: 'options',
|
|
34
|
+
noDataExpression: true,
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
name: 'URL',
|
|
38
|
+
value: 'url',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
default: 'url',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Operation',
|
|
45
|
+
name: 'operation',
|
|
46
|
+
type: 'options',
|
|
47
|
+
noDataExpression: true,
|
|
48
|
+
displayOptions: {
|
|
49
|
+
show: {
|
|
50
|
+
resource: [
|
|
51
|
+
'url',
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
options: [
|
|
56
|
+
{
|
|
57
|
+
name: 'Shorten',
|
|
58
|
+
value: 'shorten',
|
|
59
|
+
description: 'Shorten a URL',
|
|
60
|
+
action: 'Shorten a URL',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
default: 'shorten',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
displayName: 'URL to Shorten',
|
|
67
|
+
name: 'url',
|
|
68
|
+
type: 'string',
|
|
69
|
+
required: true,
|
|
70
|
+
displayOptions: {
|
|
71
|
+
show: {
|
|
72
|
+
resource: ['url'],
|
|
73
|
+
operation: ['shorten'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
default: '',
|
|
77
|
+
description: 'The URL to shorten',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
displayName: 'Type',
|
|
81
|
+
name: 'type',
|
|
82
|
+
type: 'options',
|
|
83
|
+
options: [
|
|
84
|
+
{
|
|
85
|
+
name: 'R1 (Expiring)',
|
|
86
|
+
value: 'r1',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'R2 (Custom Alias Only)',
|
|
90
|
+
value: 'r2',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'R3 (Default)',
|
|
94
|
+
value: 'r3',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'R5 (Large File)',
|
|
98
|
+
value: 'r5',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
default: 'r3',
|
|
102
|
+
description: 'The redirect type',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
displayName: 'Custom Alias',
|
|
106
|
+
name: 'alias',
|
|
107
|
+
type: 'string',
|
|
108
|
+
displayOptions: {
|
|
109
|
+
show: {
|
|
110
|
+
type: ['r2', 'r3', 'r5'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
default: '',
|
|
114
|
+
description: 'Optional custom alias (requires API Key)',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Expires At',
|
|
118
|
+
name: 'expiresAt',
|
|
119
|
+
type: 'dateTime',
|
|
120
|
+
required: true,
|
|
121
|
+
displayOptions: {
|
|
122
|
+
show: {
|
|
123
|
+
type: ['r1'],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
default: '',
|
|
127
|
+
description: 'Expiration date (required for R1, requires API Key)',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
133
|
+
const items = this.getInputData();
|
|
134
|
+
const returnData: INodeExecutionData[] = [];
|
|
135
|
+
const resource = this.getNodeParameter('resource', 0) as string;
|
|
136
|
+
const operation = this.getNodeParameter('operation', 0) as string;
|
|
137
|
+
|
|
138
|
+
for (let i = 0; i < items.length; i++) {
|
|
139
|
+
try {
|
|
140
|
+
if (resource === 'url') {
|
|
141
|
+
if (operation === 'shorten') {
|
|
142
|
+
const url = this.getNodeParameter('url', i) as string;
|
|
143
|
+
const type = this.getNodeParameter('type', i) as string;
|
|
144
|
+
const body: IDataObject = {
|
|
145
|
+
url,
|
|
146
|
+
type,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (type === 'r1') {
|
|
150
|
+
body.expiresAt = this.getNodeParameter('expiresAt', i) as string;
|
|
151
|
+
} else {
|
|
152
|
+
const alias = this.getNodeParameter('alias', i) as string;
|
|
153
|
+
if (alias) {
|
|
154
|
+
body.alias = alias;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const credentials = await this.getCredentials('gate1253Api');
|
|
159
|
+
const headers: IDataObject = {
|
|
160
|
+
'Content-Type': 'application/json',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
if (credentials?.apiKey) {
|
|
164
|
+
headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const options = {
|
|
168
|
+
method: 'POST' as IHttpRequestMethods,
|
|
169
|
+
body,
|
|
170
|
+
headers,
|
|
171
|
+
uri: `https://api.gate1253.workers.dev/api/shorten`,
|
|
172
|
+
json: true,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const responseData = await this.helpers.request!(options);
|
|
176
|
+
returnData.push({ json: responseData });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (this.continueOnFail()) {
|
|
181
|
+
returnData.push({ json: { error: error.message } });
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return [returnData];
|
|
189
|
+
}
|
|
190
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pluto90/n8n-nodes-gate1253",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "n8n node for Gate1253 URL shortener",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"prepublishOnly": "npm run build",
|
|
9
|
+
"lint": "eslint . --ext .ts",
|
|
10
|
+
"lintfix": "eslint . --ext .ts --fix"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"n8n-nodes-module",
|
|
14
|
+
"gate1253",
|
|
15
|
+
"url-shortener"
|
|
16
|
+
],
|
|
17
|
+
"author": "GATE1253",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"n8n": {
|
|
20
|
+
"nodes": [
|
|
21
|
+
"dist/nodes/Gate1253/Gate1253.node.js"
|
|
22
|
+
],
|
|
23
|
+
"credentials": [
|
|
24
|
+
"dist/credentials/Gate1253Api.credentials.js"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^18.0.0",
|
|
29
|
+
"n8n-workflow": "^1.0.0",
|
|
30
|
+
"n8n-core": "^1.0.0",
|
|
31
|
+
"typescript": "^5.2.2"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "es2019",
|
|
5
|
+
"lib": [
|
|
6
|
+
"es2019"
|
|
7
|
+
],
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": "dist",
|
|
11
|
+
"rootDir": ".",
|
|
12
|
+
"strict": false,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"moduleResolution": "node"
|
|
17
|
+
},
|
|
18
|
+
"include": [
|
|
19
|
+
"nodes/**/*.ts",
|
|
20
|
+
"credentials/**/*.ts",
|
|
21
|
+
"index.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist"
|
|
26
|
+
]
|
|
27
|
+
}
|