@darco2903/cdn-api 1.0.7-beta.0 → 1.0.7-beta.1
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 +49 -9
- package/dist/client.d.ts +1039 -0
- package/{src/client.ts → dist/client.js} +15 -18
- package/{src/common.ts → dist/common.d.ts} +4 -4
- package/dist/common.js +4 -0
- package/dist/consts.d.ts +5 -0
- package/{src/consts.ts → dist/consts.js} +4 -8
- package/dist/contract/auth.d.ts +35 -0
- package/{src/contract/auth.ts → dist/contract/auth.js} +18 -22
- package/dist/contract/endpoint.d.ts +396 -0
- package/{src/contract/endpoint.ts → dist/contract/endpoint.js} +42 -53
- package/dist/contract/index.d.ts +2039 -0
- package/{src/contract/index.ts → dist/contract/index.js} +22 -27
- package/dist/contract/key.d.ts +15 -0
- package/{src/contract/key.ts → dist/contract/key.js} +15 -19
- package/dist/contract/list.d.ts +134 -0
- package/{src/contract/list.ts → dist/contract/list.js} +28 -30
- package/dist/contract/record.d.ts +412 -0
- package/{src/contract/record.ts → dist/contract/record.js} +71 -82
- package/dist/contract/service.d.ts +240 -0
- package/{src/contract/service.ts → dist/contract/service.js} +33 -44
- package/dist/contract/stats.d.ts +32 -0
- package/{src/contract/stats.ts → dist/contract/stats.js} +34 -36
- package/dist/contract/upload.d.ts +790 -0
- package/{src/contract/upload.ts → dist/contract/upload.js} +78 -82
- package/{src/index.ts → dist/index.d.ts} +2 -2
- package/dist/index.js +2 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +58 -0
- package/{src/socket/index.ts → dist/socket/index.d.ts} +2 -2
- package/dist/socket/index.js +2 -0
- package/dist/socket/interface/index.d.ts +5 -0
- package/dist/socket/interface/index.js +1 -0
- package/{src/socket/interface/template.ts → dist/socket/interface/template.d.ts} +6 -7
- package/dist/socket/interface/template.js +1 -0
- package/dist/socket/types.d.ts +3 -0
- package/dist/socket/types.js +1 -0
- package/dist/types/creds.d.ts +8 -0
- package/{src/types/creds.ts → dist/types/creds.js} +5 -7
- package/dist/types/endpoint.d.ts +25 -0
- package/{src/types/endpoint.ts → dist/types/endpoint.js} +12 -19
- package/{src/types/index.ts → dist/types/index.d.ts} +6 -6
- package/dist/types/index.js +6 -0
- package/dist/types/jwt.d.ts +128 -0
- package/dist/types/jwt.js +33 -0
- package/dist/types/record.d.ts +97 -0
- package/{src/types/record.ts → dist/types/record.js} +25 -35
- package/dist/types/stats.d.ts +15 -0
- package/{src/types/stats.ts → dist/types/stats.js} +6 -9
- package/dist/types/upload.d.ts +45 -0
- package/{src/types/upload.ts → dist/types/upload.js} +12 -18
- package/dist/types.d.ts +32 -0
- package/dist/types.js +27 -0
- package/dist/uploader.d.ts +1044 -0
- package/{src/uploader.ts → dist/uploader.js} +72 -99
- package/package.json +2 -2
- package/.gitattributes +0 -2
- package/.github/workflows/release.yml +0 -116
- package/TODO.md +0 -0
- package/prettier.config.js +0 -24
- package/src/server.ts +0 -89
- package/src/socket/interface/index.ts +0 -12
- package/src/socket/types.ts +0 -7
- package/src/types/jwt.ts +0 -78
- package/src/types.ts +0 -38
- package/tests/keys/private.pem +0 -5
- package/tests/keys/public.pem +0 -4
- package/tests/keys.ts +0 -11
- package/tests/tsconfig.json +0 -12
- package/tests/vitest/jwt.test.ts +0 -38
- package/tsconfig.json +0 -14
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { initContract } from "@ts-rest/core";
|
|
2
|
-
import auth from "./auth.js";
|
|
3
|
-
import endpoint from "./endpoint.js";
|
|
4
|
-
import key from "./key.js";
|
|
5
|
-
import list from "./list.js";
|
|
6
|
-
import record from "./record.js";
|
|
7
|
-
import service from "./service.js";
|
|
8
|
-
import stats from "./stats.js";
|
|
9
|
-
import upload from "./upload.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
pathPrefix: "/api/v2",
|
|
26
|
-
}
|
|
27
|
-
);
|
|
1
|
+
import { initContract } from "@ts-rest/core";
|
|
2
|
+
import auth from "./auth.js";
|
|
3
|
+
import endpoint from "./endpoint.js";
|
|
4
|
+
import key from "./key.js";
|
|
5
|
+
import list from "./list.js";
|
|
6
|
+
import record from "./record.js";
|
|
7
|
+
import service from "./service.js";
|
|
8
|
+
import stats from "./stats.js";
|
|
9
|
+
import upload from "./upload.js";
|
|
10
|
+
const c = initContract();
|
|
11
|
+
export default c.router({
|
|
12
|
+
auth,
|
|
13
|
+
endpoint,
|
|
14
|
+
...key,
|
|
15
|
+
list,
|
|
16
|
+
record,
|
|
17
|
+
service,
|
|
18
|
+
stats,
|
|
19
|
+
upload,
|
|
20
|
+
}, {
|
|
21
|
+
pathPrefix: "/api/v2",
|
|
22
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
publicKey: {
|
|
4
|
+
method: "GET";
|
|
5
|
+
path: "/public-key";
|
|
6
|
+
responses: {
|
|
7
|
+
200: z.ZodType<{
|
|
8
|
+
publicKey: string;
|
|
9
|
+
}, z.ZodTypeDef, {
|
|
10
|
+
publicKey: string;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { initContract } from "@ts-rest/core";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { apiSuccess } from "../types.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
),
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
1
|
+
import { initContract } from "@ts-rest/core";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { apiSuccess } from "../types.js";
|
|
4
|
+
const c = initContract();
|
|
5
|
+
export default c.router({
|
|
6
|
+
publicKey: {
|
|
7
|
+
method: "GET",
|
|
8
|
+
path: "/public-key",
|
|
9
|
+
responses: {
|
|
10
|
+
200: apiSuccess(z.object({
|
|
11
|
+
publicKey: z.string(),
|
|
12
|
+
})),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
public: {
|
|
4
|
+
method: "GET";
|
|
5
|
+
path: "/list";
|
|
6
|
+
headers: z.ZodObject<{
|
|
7
|
+
authorization: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
authorization?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
authorization?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
responses: {
|
|
14
|
+
200: z.ZodType<{
|
|
15
|
+
filename: string;
|
|
16
|
+
size: number;
|
|
17
|
+
storage_id: string;
|
|
18
|
+
mime_type: string;
|
|
19
|
+
endpoints: {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
}[];
|
|
22
|
+
}[], z.ZodTypeDef, {
|
|
23
|
+
filename: string;
|
|
24
|
+
size: number;
|
|
25
|
+
storage_id: string;
|
|
26
|
+
mime_type: string;
|
|
27
|
+
endpoints: {
|
|
28
|
+
endpoint: string;
|
|
29
|
+
}[];
|
|
30
|
+
}[]>;
|
|
31
|
+
500: z.ZodObject<{
|
|
32
|
+
code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
|
|
33
|
+
error: z.ZodType<string, z.ZodTypeDef, string>;
|
|
34
|
+
name: z.ZodLiteral<"APIError">;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
code: "INTERNAL_SERVER_ERROR";
|
|
37
|
+
name: "APIError";
|
|
38
|
+
error: string;
|
|
39
|
+
}, {
|
|
40
|
+
code: "INTERNAL_SERVER_ERROR";
|
|
41
|
+
name: "APIError";
|
|
42
|
+
error: string;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
admin: {
|
|
47
|
+
method: "GET";
|
|
48
|
+
path: "/list/admin";
|
|
49
|
+
headers: z.ZodObject<{
|
|
50
|
+
authorization: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
authorization?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
authorization?: string | undefined;
|
|
55
|
+
}>;
|
|
56
|
+
responses: {
|
|
57
|
+
200: z.ZodType<{
|
|
58
|
+
type: "user" | "service" | "system";
|
|
59
|
+
filename: string;
|
|
60
|
+
active: boolean;
|
|
61
|
+
visible: boolean;
|
|
62
|
+
role: number;
|
|
63
|
+
size: number;
|
|
64
|
+
created_at: Date;
|
|
65
|
+
updated_at: Date;
|
|
66
|
+
storage_id: string;
|
|
67
|
+
mime_type: string;
|
|
68
|
+
endpoints: {
|
|
69
|
+
created_at: Date;
|
|
70
|
+
updated_at: Date;
|
|
71
|
+
endpoint: string;
|
|
72
|
+
}[];
|
|
73
|
+
user_id: string | null;
|
|
74
|
+
}[], z.ZodTypeDef, {
|
|
75
|
+
type: "user" | "service" | "system";
|
|
76
|
+
filename: string;
|
|
77
|
+
active: boolean;
|
|
78
|
+
visible: boolean;
|
|
79
|
+
role: number;
|
|
80
|
+
size: number;
|
|
81
|
+
created_at: Date;
|
|
82
|
+
updated_at: Date;
|
|
83
|
+
storage_id: string;
|
|
84
|
+
mime_type: string;
|
|
85
|
+
endpoints: {
|
|
86
|
+
created_at: Date;
|
|
87
|
+
updated_at: Date;
|
|
88
|
+
endpoint: string;
|
|
89
|
+
}[];
|
|
90
|
+
user_id: string | null;
|
|
91
|
+
}[]>;
|
|
92
|
+
401: z.ZodObject<{
|
|
93
|
+
code: z.ZodType<"UNAUTHORIZED", z.ZodTypeDef, "UNAUTHORIZED">;
|
|
94
|
+
error: z.ZodType<"Unauthorized", z.ZodTypeDef, "Unauthorized">;
|
|
95
|
+
name: z.ZodLiteral<"APIError">;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
code: "UNAUTHORIZED";
|
|
98
|
+
name: "APIError";
|
|
99
|
+
error: "Unauthorized";
|
|
100
|
+
}, {
|
|
101
|
+
code: "UNAUTHORIZED";
|
|
102
|
+
name: "APIError";
|
|
103
|
+
error: "Unauthorized";
|
|
104
|
+
}>;
|
|
105
|
+
403: z.ZodObject<{
|
|
106
|
+
code: z.ZodType<"FORBIDDEN", z.ZodTypeDef, "FORBIDDEN">;
|
|
107
|
+
error: z.ZodType<"Forbidden", z.ZodTypeDef, "Forbidden">;
|
|
108
|
+
name: z.ZodLiteral<"APIError">;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
code: "FORBIDDEN";
|
|
111
|
+
name: "APIError";
|
|
112
|
+
error: "Forbidden";
|
|
113
|
+
}, {
|
|
114
|
+
code: "FORBIDDEN";
|
|
115
|
+
name: "APIError";
|
|
116
|
+
error: "Forbidden";
|
|
117
|
+
}>;
|
|
118
|
+
500: z.ZodObject<{
|
|
119
|
+
code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
|
|
120
|
+
error: z.ZodType<string, z.ZodTypeDef, string>;
|
|
121
|
+
name: z.ZodLiteral<"APIError">;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
code: "INTERNAL_SERVER_ERROR";
|
|
124
|
+
name: "APIError";
|
|
125
|
+
error: string;
|
|
126
|
+
}, {
|
|
127
|
+
code: "INTERNAL_SERVER_ERROR";
|
|
128
|
+
name: "APIError";
|
|
129
|
+
error: string;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export default _default;
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import { initContract } from "@ts-rest/core";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { authHeaderSchema } from "@darco2903/auth-api/client";
|
|
4
|
-
import { apiError, apiSuccess } from "../types.js";
|
|
5
|
-
import { recordSchema, recordPublicSchema } from "../types/index.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
});
|
|
1
|
+
import { initContract } from "@ts-rest/core";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { authHeaderSchema } from "@darco2903/auth-api/client";
|
|
4
|
+
import { apiError, apiSuccess } from "../types.js";
|
|
5
|
+
import { recordSchema, recordPublicSchema } from "../types/index.js";
|
|
6
|
+
const c = initContract();
|
|
7
|
+
export default c.router({
|
|
8
|
+
public: {
|
|
9
|
+
method: "GET",
|
|
10
|
+
path: "/list",
|
|
11
|
+
headers: authHeaderSchema,
|
|
12
|
+
responses: {
|
|
13
|
+
200: apiSuccess(z.array(recordPublicSchema)),
|
|
14
|
+
500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
admin: {
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: "/list/admin",
|
|
20
|
+
headers: authHeaderSchema,
|
|
21
|
+
responses: {
|
|
22
|
+
200: apiSuccess(z.array(recordSchema)),
|
|
23
|
+
401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
|
|
24
|
+
403: apiError(z.literal("FORBIDDEN"), z.literal("Forbidden")),
|
|
25
|
+
500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|