feat: update postiz sdk

This commit is contained in:
Nevo David 2025-07-19 21:37:35 +07:00
parent 0eb75302c5
commit c08f2e6a62
4 changed files with 54 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@postiz/node",
"version": "1.0.5",
"version": "1.0.6",
"description": "The ultimate social media scheduling tool",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -15,9 +15,9 @@
"scheduling tool",
"social media scheduling tool"
],
"author": "Your Name",
"author": "Nevo David",
"license": "AGPL-3.0",
"dependencies": {
"form-data": "4.0.3"
"node-fetch": "^3.3.2"
}
}

View File

@ -1,6 +1,6 @@
import { CreatePostDto } from '@gitroom/nestjs-libraries/dtos/posts/create.post.dto';
import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto';
import FormData from 'form-data';
import fetch, { FormData } from 'node-fetch';
function toQueryString(obj: Record<string, any>): string {
const params = new URLSearchParams();
@ -45,7 +45,19 @@ export default class Postiz {
async upload(file: Buffer, extension: string) {
const formData = new FormData();
formData.append('file', file, extension);
const type =
extension === 'png'
? 'image/png'
: extension === 'jpg'
? 'image/jpeg'
: extension === 'gif'
? 'image/gif'
: extension === 'jpeg'
? 'image/jpeg'
: 'image/jpeg';
const blob = new Blob([file], { type });
formData.append('file', blob, extension);
return (
await fetch(`${this._path}/public/v1/upload`, {
@ -54,7 +66,6 @@ export default class Postiz {
body: formData,
headers: {
Authorization: this._apiKey,
...formData.getHeaders(),
},
})
).json();

View File

@ -162,6 +162,7 @@
"nestjs-real-ip": "^3.0.1",
"next": "^14.2.30",
"next-plausible": "^3.12.0",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"node-telegram-bot-api": "^0.66.0",
"nodemailer": "^6.9.15",

View File

@ -363,6 +363,9 @@ importers:
next-plausible:
specifier: ^3.12.0
version: 3.12.4(next@14.2.30(@babel/core@7.28.0)(@opentelemetry/api@1.9.0)(@playwright/test@1.53.2)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.89.2))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
node-fetch:
specifier: ^3.3.2
version: 3.3.2
node-html-markdown:
specifier: ^1.3.0
version: 1.3.0
@ -7831,6 +7834,10 @@ packages:
resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==}
engines: {node: '>=0.10'}
data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
data-uri-to-buffer@6.0.2:
resolution: {integrity: sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==}
engines: {node: '>= 14'}
@ -8711,6 +8718,10 @@ packages:
picomatch:
optional: true
fetch-blob@3.2.0:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13}
fflate@0.4.8:
resolution: {integrity: sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==}
@ -8882,6 +8893,10 @@ packages:
resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==}
engines: {node: '>= 12.20'}
formdata-polyfill@4.0.10:
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
engines: {node: '>=12.20.0'}
forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
@ -11431,6 +11446,10 @@ packages:
encoding:
optional: true
node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
node-forge@1.3.1:
resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}
engines: {node: '>= 6.13.0'}
@ -24439,6 +24458,8 @@ snapshots:
dependencies:
assert-plus: 1.0.0
data-uri-to-buffer@4.0.1: {}
data-uri-to-buffer@6.0.2: {}
data-urls@3.0.2:
@ -25590,6 +25611,11 @@ snapshots:
optionalDependencies:
picomatch: 4.0.2
fetch-blob@3.2.0:
dependencies:
node-domexception: 1.0.0
web-streams-polyfill: 3.3.3
fflate@0.4.8: {}
fflate@0.8.2: {}
@ -25822,6 +25848,10 @@ snapshots:
node-domexception: 1.0.0
web-streams-polyfill: 4.0.0-beta.3
formdata-polyfill@4.0.10:
dependencies:
fetch-blob: 3.2.0
forwarded@0.2.0: {}
fraction.js@4.3.7: {}
@ -29270,6 +29300,12 @@ snapshots:
dependencies:
whatwg-url: 5.0.0
node-fetch@3.3.2:
dependencies:
data-uri-to-buffer: 4.0.1
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
node-forge@1.3.1: {}
node-gyp-build-optional-packages@5.2.2: