@mini-yt/svc 0.0.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.
@@ -0,0 +1,4 @@
1
+ import S3Service from "./s3-service";
2
+ import SqsService from "./sqs-service";
3
+ export { S3Service, SqsService };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import S3Service from "./s3-service";
2
+ import SqsService from "./sqs-service";
3
+ export { S3Service, SqsService };
@@ -0,0 +1,27 @@
1
+ declare class S3Service {
2
+ private S3Config;
3
+ private S3Client;
4
+ constructor();
5
+ createBucket(name: string): Promise<string | undefined>;
6
+ getSignedUploadUrl({ key, contentType, expiresIn, bucket, }: {
7
+ key: string;
8
+ contentType: string;
9
+ expiresIn?: number;
10
+ bucket?: string;
11
+ }): Promise<string>;
12
+ assetExists(key: string, bucket?: string): Promise<boolean>;
13
+ download({ key, outputPath, bucket, }: {
14
+ key: string;
15
+ outputPath: string;
16
+ bucket?: string;
17
+ }): Promise<void>;
18
+ upload({ key, inputFilePath, bucket, contentType, }: {
19
+ key: string;
20
+ inputFilePath: string;
21
+ bucket?: string;
22
+ contentType?: string;
23
+ }): Promise<void>;
24
+ }
25
+ declare const _default: S3Service;
26
+ export default _default;
27
+ //# sourceMappingURL=s3-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-service.d.ts","sourceRoot":"","sources":["../../src/aws/s3-service.ts"],"names":[],"mappings":"AAcA,cAAM,SAAS;IACb,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAW;;IAerB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgBvD,kBAAkB,CAAC,EACvB,GAAG,EACH,WAAW,EACX,SAAgB,EAChB,MAA0B,GAC3B,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBb,WAAW,CACf,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,MAA0B,GACjC,OAAO,CAAC,OAAO,CAAC;IAuBb,QAAQ,CAAC,EACb,GAAG,EACH,UAAU,EACV,MAA0B,GAC3B,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAaK,MAAM,CAAC,EACX,GAAG,EACH,aAAa,EACb,MAAgC,EAChC,WAAW,GACZ,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;CAUF;;AAED,wBAA+B"}
@@ -0,0 +1,86 @@
1
+ import { CreateBucketCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, } from "@aws-sdk/client-s3";
2
+ import { ENV, logger } from "@mini-yt/shared";
3
+ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
4
+ import { inspect } from "util";
5
+ import { pipeline } from "stream/promises";
6
+ import fs from "fs";
7
+ class S3Service {
8
+ S3Config;
9
+ S3Client;
10
+ constructor() {
11
+ this.S3Config = {
12
+ region: ENV.AWS_REGION,
13
+ endpoint: ENV.AWS_ENDPOINT,
14
+ forcePathStyle: true,
15
+ credentials: {
16
+ accessKeyId: ENV.AWS_ACCESS_KEY_ID,
17
+ secretAccessKey: ENV.AWS_SECRET_ACCESS_KEY,
18
+ },
19
+ };
20
+ this.S3Client = new S3Client(this.S3Config);
21
+ }
22
+ async createBucket(name) {
23
+ try {
24
+ const res = await this.S3Client.send(new CreateBucketCommand({ Bucket: name }));
25
+ return res.Location;
26
+ }
27
+ catch (error) {
28
+ if (error.name === "BucketAlreadyOwnedByYou") {
29
+ console.log("Bucket already exists!");
30
+ return;
31
+ }
32
+ console.error("Error creating in bucket", error);
33
+ }
34
+ }
35
+ async getSignedUploadUrl({ key, contentType, expiresIn = 3600, bucket = ENV.S3_RAW_BUCKET, }) {
36
+ try {
37
+ logger.info("S3Service.getSignedUploadUrl called::");
38
+ const command = new PutObjectCommand({
39
+ Bucket: bucket,
40
+ Key: key,
41
+ ContentType: contentType,
42
+ });
43
+ return await getSignedUrl(this.S3Client, command, { expiresIn });
44
+ }
45
+ catch (error) {
46
+ logger.error("S3Service.getSignedUploadUrl error::", inspect(error));
47
+ throw error;
48
+ }
49
+ }
50
+ async assetExists(key, bucket = ENV.S3_RAW_BUCKET) {
51
+ try {
52
+ logger.info("S3Service.assetExists called::");
53
+ await this.S3Client.send(new HeadObjectCommand({
54
+ Bucket: bucket,
55
+ Key: key,
56
+ }));
57
+ return true;
58
+ }
59
+ catch (error) {
60
+ if (error?.name === "NotFound" ||
61
+ error?.$metadata?.httpStatusCode === 404) {
62
+ return false;
63
+ }
64
+ logger.error("S3Service.assetExists error::", inspect(error));
65
+ throw error;
66
+ }
67
+ }
68
+ async download({ key, outputPath, bucket = ENV.S3_RAW_BUCKET, }) {
69
+ const res = await this.S3Client.send(new GetObjectCommand({
70
+ Bucket: bucket,
71
+ Key: key,
72
+ }));
73
+ if (!res.Body)
74
+ throw new Error("Missing S3 Body");
75
+ await pipeline(res.Body, fs.createWriteStream(outputPath));
76
+ }
77
+ async upload({ key, inputFilePath, bucket = ENV.S3_PROCESSED_BUCKET, contentType, }) {
78
+ await this.S3Client.send(new PutObjectCommand({
79
+ Bucket: bucket,
80
+ Key: key,
81
+ Body: fs.createReadStream(inputFilePath),
82
+ ContentType: contentType,
83
+ }));
84
+ }
85
+ }
86
+ export default new S3Service();
@@ -0,0 +1,13 @@
1
+ declare class SqsService {
2
+ private sqsConfig;
3
+ private sqsClient;
4
+ constructor();
5
+ createQueue(name: string): Promise<String | undefined>;
6
+ sendEvent({ payload, queueUrl, }: {
7
+ payload: any;
8
+ queueUrl: string;
9
+ }): Promise<void>;
10
+ }
11
+ declare const _default: SqsService;
12
+ export default _default;
13
+ //# sourceMappingURL=sqs-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqs-service.d.ts","sourceRoot":"","sources":["../../src/aws/sqs-service.ts"],"names":[],"mappings":"AAQA,cAAM,UAAU;IACd,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,SAAS,CAAY;;IAcvB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA6BtD,SAAS,CAAC,EACd,OAAO,EACP,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;CAalB;;AAED,wBAAgC"}
@@ -0,0 +1,58 @@
1
+ import { CreateQueueCommand, SQSClient, SendMessageCommand, } from "@aws-sdk/client-sqs";
2
+ import { ENV, logger } from "@mini-yt/shared";
3
+ class SqsService {
4
+ sqsConfig;
5
+ sqsClient;
6
+ constructor() {
7
+ this.sqsConfig = {
8
+ region: ENV.AWS_REGION,
9
+ endpoint: ENV.AWS_ENDPOINT,
10
+ credentials: {
11
+ accessKeyId: ENV.AWS_ACCESS_KEY_ID,
12
+ secretAccessKey: ENV.AWS_SECRET_ACCESS_KEY,
13
+ },
14
+ };
15
+ this.sqsClient = new SQSClient(this.sqsConfig);
16
+ }
17
+ async createQueue(name) {
18
+ try {
19
+ logger.info("SqsService.createQueue called::");
20
+ const isFifo = name.endsWith(".fifo");
21
+ const inputData = {
22
+ QueueName: name,
23
+ Attributes: {
24
+ ...(isFifo && {
25
+ FifoQueue: "true",
26
+ ContentBasedDeduplication: "true",
27
+ }),
28
+ },
29
+ };
30
+ const res = await this.sqsClient.send(new CreateQueueCommand(inputData));
31
+ if (!res.QueueUrl)
32
+ throw new Error("Queue URL not returned by SQS");
33
+ return res.QueueUrl;
34
+ }
35
+ catch (error) {
36
+ if (error.name === "QueueAlreadyExists") {
37
+ // attributes mismatch
38
+ console.warn(`Queue "${name}" already exists with different attributes`);
39
+ return;
40
+ }
41
+ logger.error("SqsService.createQueue error::", error);
42
+ throw error;
43
+ }
44
+ }
45
+ async sendEvent({ payload, queueUrl, }) {
46
+ try {
47
+ logger.info("SqsService.sendEvent called::");
48
+ await this.sqsClient.send(new SendMessageCommand({
49
+ QueueUrl: queueUrl,
50
+ MessageBody: JSON.stringify(payload),
51
+ }));
52
+ }
53
+ catch (error) {
54
+ logger.error("SqsService.error called:::");
55
+ }
56
+ }
57
+ }
58
+ export default new SqsService();
@@ -0,0 +1,3 @@
1
+ export * as Repository from "./repository";
2
+ export * as AWS from "./aws";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import * as Repository_1 from "./repository";
2
+ export { Repository_1 as Repository };
3
+ import * as AWS_1 from "./aws";
4
+ export { AWS_1 as AWS };
@@ -0,0 +1,28 @@
1
+ import { Knex as Iknex } from "knex";
2
+ import { types } from "@mini-yt/shared";
3
+ declare class ChannelRepository {
4
+ private db;
5
+ private tbChannel;
6
+ private returningFields;
7
+ constructor(db: Iknex);
8
+ createChannel(channelBody: types.schema.channel.IChannel): Iknex.QueryBuilder<any, {
9
+ _base: any;
10
+ _hasSelection: true;
11
+ _keys: string;
12
+ _aliases: {};
13
+ _single: false;
14
+ _intersectProps: {};
15
+ _unionProps: never;
16
+ }[]>;
17
+ getChannel(conditions: types.schema.channel.IGetChannel): Iknex.QueryBuilder<any, {
18
+ _base: any;
19
+ _hasSelection: false;
20
+ _keys: never;
21
+ _aliases: {};
22
+ _single: false;
23
+ _intersectProps: {};
24
+ _unionProps: undefined;
25
+ }>;
26
+ }
27
+ export default ChannelRepository;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/channel-repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAa,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGnD,cAAM,iBAAiB;IACrB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,SAAS,CAAqD;IACtE,OAAO,CAAC,eAAe,CAAmD;gBAC9D,EAAE,EAAE,KAAK;IAIrB,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ;;;;;;;;;IAKxD,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW;;;;;;;;;CAKxD;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { CONSTANTS } from "@mini-yt/shared";
2
+ const { DEFAULTS, TABLES } = CONSTANTS.DATABASE;
3
+ class ChannelRepository {
4
+ db;
5
+ tbChannel = `${DEFAULTS.SCHEMA}.${TABLES.TB_CHANNEL}`;
6
+ returningFields = ["name", "owner", "handle", "id", "created_at"];
7
+ constructor(db) {
8
+ this.db = db;
9
+ }
10
+ createChannel(channelBody) {
11
+ return this.db(this.tbChannel)
12
+ .insert(channelBody)
13
+ .returning(this.returningFields);
14
+ }
15
+ getChannel(conditions) {
16
+ return this.db(this.tbChannel)
17
+ .where({ ...conditions })
18
+ .first();
19
+ }
20
+ }
21
+ export default ChannelRepository;
@@ -0,0 +1,6 @@
1
+ import UserRepository from "./user-reposistory";
2
+ import ChannelRepository from "./channel-repository";
3
+ import RefreshTokenRepository from "./refresh-token-repository";
4
+ import VideoRepository from "./video-repository";
5
+ export { VideoRepository, UserRepository, ChannelRepository, RefreshTokenRepository, };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,sBAAsB,MAAM,4BAA4B,CAAC;AAChE,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import UserRepository from "./user-reposistory";
2
+ import ChannelRepository from "./channel-repository";
3
+ import RefreshTokenRepository from "./refresh-token-repository";
4
+ import VideoRepository from "./video-repository";
5
+ export { VideoRepository, UserRepository, ChannelRepository, RefreshTokenRepository, };
@@ -0,0 +1,28 @@
1
+ import { Knex as Iknex } from "knex";
2
+ declare class RefreshTokenRepository {
3
+ private db;
4
+ private TB_REFRESH_TOKEN;
5
+ private returningFields;
6
+ constructor(db: Iknex);
7
+ createRefreshToken(body: {}): Iknex.QueryBuilder<any, {
8
+ _base: any;
9
+ _hasSelection: true;
10
+ _keys: string;
11
+ _aliases: {};
12
+ _single: false;
13
+ _intersectProps: {};
14
+ _unionProps: never;
15
+ }[]>;
16
+ getValidRefreshTokens(): Iknex.QueryBuilder<any, {
17
+ _base: any;
18
+ _hasSelection: false;
19
+ _keys: never;
20
+ _aliases: {};
21
+ _single: false;
22
+ _intersectProps: {};
23
+ _unionProps: never;
24
+ }[]>;
25
+ deleteRefrehToken(deleteCondition: {}): Iknex.QueryBuilder<any, number>;
26
+ }
27
+ export default RefreshTokenRepository;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/refresh-token-repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAOrC,cAAM,sBAAsB;IAC1B,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,gBAAgB,CAAmD;IAC3E,OAAO,CAAC,eAAe,CAAS;gBACpB,EAAE,EAAE,KAAK;IAIrB,kBAAkB,CAAC,IAAI,EAAE,EAAE;;;;;;;;;IAK3B,qBAAqB;;;;;;;;;IAOrB,iBAAiB,CAAC,eAAe,EAAE,EAAE;CAKtC;AACD,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { CONSTANTS } from "@mini-yt/shared";
2
+ const { DATABASE: { DEFAULTS, TABLES }, } = CONSTANTS;
3
+ class RefreshTokenRepository {
4
+ db;
5
+ TB_REFRESH_TOKEN = `${DEFAULTS.SCHEMA}.${TABLES.TB_REFRESH_TOKEN}`;
6
+ returningFields = ["*"];
7
+ constructor(db) {
8
+ this.db = db;
9
+ }
10
+ createRefreshToken(body) {
11
+ return this.db(this.TB_REFRESH_TOKEN)
12
+ .insert(body)
13
+ .returning(this.returningFields);
14
+ }
15
+ getValidRefreshTokens() {
16
+ return this.db(this.TB_REFRESH_TOKEN).where("expires_at", ">", this.db.fn.now());
17
+ }
18
+ deleteRefrehToken(deleteCondition) {
19
+ return this.db(this.TB_REFRESH_TOKEN)
20
+ .where({ ...deleteCondition })
21
+ .delete();
22
+ }
23
+ }
24
+ export default RefreshTokenRepository;
@@ -0,0 +1,27 @@
1
+ import { Knex as Iknex } from "knex";
2
+ declare class UserRepository {
3
+ private db;
4
+ private returningObject;
5
+ private TB_USER;
6
+ constructor(db: Iknex);
7
+ getUserByConditions(conditionObject: {}): Iknex.QueryBuilder<any, {
8
+ _base: any;
9
+ _hasSelection: true;
10
+ _keys: string;
11
+ _aliases: {};
12
+ _single: false;
13
+ _intersectProps: {};
14
+ _unionProps: undefined;
15
+ }>;
16
+ createUser(userBody: {}): Iknex.QueryBuilder<any, {
17
+ _base: any;
18
+ _hasSelection: true;
19
+ _keys: string;
20
+ _aliases: {};
21
+ _single: false;
22
+ _intersectProps: {};
23
+ _unionProps: never;
24
+ }[]>;
25
+ }
26
+ export default UserRepository;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/user-reposistory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAOrC,cAAM,cAAc;IAClB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,OAAO,CAA0C;gBAE7C,EAAE,EAAE,KAAK;IAGrB,mBAAmB,CAAC,eAAe,EAAE,EAAE;;;;;;;;;IAMvC,UAAU,CAAC,QAAQ,EAAE,EAAE;;;;;;;;;CAKxB;AACD,eAAe,cAAc,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { CONSTANTS } from "@mini-yt/shared";
2
+ const { DATABASE: { DEFAULTS, TABLES }, } = CONSTANTS;
3
+ class UserRepository {
4
+ db;
5
+ returningObject = ["id", "email"];
6
+ TB_USER = `${DEFAULTS.SCHEMA}.${TABLES.TB_USER}`;
7
+ constructor(db) {
8
+ this.db = db;
9
+ }
10
+ getUserByConditions(conditionObject) {
11
+ return this.db(this.TB_USER)
12
+ .where({ ...conditionObject })
13
+ .returning(this.returningObject)
14
+ .first();
15
+ }
16
+ createUser(userBody) {
17
+ return this.db(this.TB_USER)
18
+ .insert(userBody)
19
+ .returning(this.returningObject);
20
+ }
21
+ }
22
+ export default UserRepository;
@@ -0,0 +1,31 @@
1
+ import { Knex as IKnex } from "knex";
2
+ declare class VideoRepository {
3
+ private db;
4
+ private TB_VIDEOS;
5
+ private returningFields;
6
+ constructor(db: IKnex);
7
+ create(videoBody: {}): IKnex.QueryBuilder<any, {
8
+ _base: any;
9
+ _hasSelection: true;
10
+ _keys: string;
11
+ _aliases: {};
12
+ _single: false;
13
+ _intersectProps: {};
14
+ _unionProps: never;
15
+ }[]>;
16
+ get(conditions: {}): IKnex.QueryBuilder<any, {
17
+ _base: any;
18
+ _hasSelection: true;
19
+ _keys: string;
20
+ _aliases: {};
21
+ _single: false;
22
+ _intersectProps: {};
23
+ _unionProps: undefined;
24
+ }>;
25
+ update({ id, updateBody }: {
26
+ id: string;
27
+ updateBody: {};
28
+ }): IKnex.QueryBuilder<any, number>;
29
+ }
30
+ export default VideoRepository;
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/video-repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAOrC,cAAM,eAAe;IACnB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,SAAS,CAA4C;IAC7D,OAAO,CAAC,eAAe,CAMrB;gBACU,EAAE,EAAE,KAAK;IAIrB,MAAM,CAAC,SAAS,EAAE,EAAE;;;;;;;;;IAKpB,GAAG,CAAC,UAAU,EAAE,EAAE;;;;;;;;;IAMlB,MAAM,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,EAAE,CAAA;KAAE;CAK1D;AACD,eAAe,eAAe,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { CONSTANTS } from "@mini-yt/shared";
2
+ const { DATABASE: { DEFAULTS, TABLES }, } = CONSTANTS;
3
+ class VideoRepository {
4
+ db;
5
+ TB_VIDEOS = `${DEFAULTS.SCHEMA}.${TABLES.TB_VIDEOS}`;
6
+ returningFields = [
7
+ "channel",
8
+ "title",
9
+ "description",
10
+ "status",
11
+ "raw_s3_key",
12
+ ];
13
+ constructor(db) {
14
+ this.db = db;
15
+ }
16
+ create(videoBody) {
17
+ return this.db(this.TB_VIDEOS)
18
+ .insert({ ...videoBody })
19
+ .returning(this.returningFields);
20
+ }
21
+ get(conditions) {
22
+ return this.db(this.TB_VIDEOS)
23
+ .where({ ...conditions })
24
+ .returning(this.returningFields)
25
+ .first();
26
+ }
27
+ update({ id, updateBody }) {
28
+ return this.db(this.TB_VIDEOS)
29
+ .update({ ...updateBody })
30
+ .where({ id });
31
+ }
32
+ }
33
+ export default VideoRepository;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@mini-yt/svc",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "typecheck": "tsc --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@mini-yt/shared": "workspace:*",
22
+ "knex": "^3.1.0",
23
+ "@aws-sdk/client-s3": "^3.700.0",
24
+ "@aws-sdk/client-sqs": "^3.700.0",
25
+ "@aws-sdk/s3-request-presigner": "^3.964.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^25.0.3",
29
+ "tsx": "^4.21.0",
30
+ "typescript": "^5.9.3"
31
+ }
32
+ }