Compare commits

..

8 Commits

Author SHA1 Message Date
Darius
bf7f3ee77c 1.1.3 2025-11-21 16:22:20 +01:00
Darius
d0e9f28c8c Generic Commit; Most likely a fix or small feature 2025-11-21 16:22:14 +01:00
Darius
5f9b97ca54 1.1.2 2025-11-21 16:07:03 +01:00
Darius
0103f73c39 Generic Commit; Most likely a fix or small feature 2025-11-21 16:07:01 +01:00
Darius
39d45c80b9 1.1.1 2025-11-21 15:57:56 +01:00
Darius
c415912a0a Generic Commit; Most likely a fix or small feature 2025-11-21 15:57:48 +01:00
Darius
868bf0dc53 1.1.0 2025-11-21 15:49:29 +01:00
Darius
94c10f13e9 add fastify service result type 2025-11-21 15:49:24 +01:00
6 changed files with 80 additions and 3 deletions

16
dist/fastify.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
import { AxiosInstance } from "axios";
export type ServiceResult<T = unknown> = {
result: T;
successful: boolean;
};
export declare abstract class Client {
private axiosInstance;
constructor(axiosInstance: AxiosInstance);
}
export declare abstract class Service<T> {
private client;
constructor(client: T);
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>;
getErrorResult(error: string): ServiceResult<string>;
}
//# sourceMappingURL=fastify.d.ts.map

1
dist/fastify.d.ts.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACvC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,8BAAsB,MAAM;IAC1B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;CAGzC;AAED,8BAAsB,OAAO,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;CAMrD"}

24
dist/fastify.js vendored Normal file
View File

@@ -0,0 +1,24 @@
export class Client {
axiosInstance;
constructor(axiosInstance) {
this.axiosInstance = axiosInstance;
}
}
export class Service {
client;
constructor(client) {
this.client = client;
}
getSuccessfulResult(result) {
return {
result,
successful: true,
};
}
getErrorResult(error) {
return {
result: error,
successful: false,
};
}
}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.0.14", "version": "1.1.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.0.14", "version": "1.1.3",
"dependencies": { "dependencies": {
"axios": "^1.7.9", "axios": "^1.7.9",
"chalk": "^5.6.2", "chalk": "^5.6.2",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.0.14", "version": "1.1.3",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

36
src/fastify.ts Normal file
View File

@@ -0,0 +1,36 @@
import { AxiosInstance } from "axios";
export type ServiceResult<T = unknown> = {
result: T;
successful: boolean;
};
export abstract class Client {
private axiosInstance: AxiosInstance;
constructor(axiosInstance: AxiosInstance) {
this.axiosInstance = axiosInstance;
}
}
export abstract class Service<T> {
private client: T;
constructor(client: T) {
this.client = client;
}
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R> {
return {
result,
successful: true,
};
}
getErrorResult(error: string): ServiceResult<string> {
return {
result: error,
successful: false,
};
}
}