biz-slide-core 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/entity/image.entity.ts +26 -28
- package/entity/index.ts +10 -0
- package/entity/png-svg.entity.ts +1 -3
- package/entity/ppt-event.entity.ts +1 -3
- package/entity/ppt-slide.entity.ts +1 -5
- package/entity/ppt.entity.ts +1 -3
- package/entity/slide-layout.entity.ts +1 -3
- package/entity/slide.entity.ts +1 -3
- package/entity/socket.entity.ts +1 -3
- package/entity/template.entity.ts +1 -3
- package/entity/user.entity.ts +1 -3
- package/middleware/index.ts +3 -0
- package/middleware/role.ts +5 -5
- package/package.json +1 -1
- package/types/index.ts +11 -0
- package/utilities/index.ts +4 -0
- package/utilities/aws-s3.ts +0 -29
package/entity/image.entity.ts
CHANGED
@@ -1,34 +1,32 @@
|
|
1
1
|
import { Schema, model, Types } from "mongoose";
|
2
2
|
|
3
|
-
interface
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
export interface IImageSchema {
|
4
|
+
focusPoint: { x: number, y: number };
|
5
|
+
url: string;
|
6
|
+
radius: string;
|
7
|
+
keywords: [string] | null;
|
8
|
+
title: string;
|
9
|
+
userId: Types.ObjectId;
|
10
|
+
createdAt: Date;
|
11
|
+
updatedAt: Date;
|
12
|
+
deletedAt: Date;
|
13
13
|
}
|
14
14
|
|
15
|
-
const ImageSchema = new Schema<
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
const ImageSchema = new Schema<IImageSchema>(
|
16
|
+
{
|
17
|
+
focusPoint: { x: Number, y: Number },
|
18
|
+
url: { type: String, required: true },
|
19
|
+
radius: { type: String, required: true },
|
20
|
+
keywords: { type: [String], default: [] },
|
21
|
+
title: { type: String, required: true },
|
22
|
+
userId: { type: Schema.Types.ObjectId, ref: "user" },
|
23
|
+
createdAt: { type: Date, default: Date.now() },
|
24
|
+
updatedAt: { type: Date, default: Date.now() },
|
25
|
+
deletedAt: { type: Date, default: null },
|
26
|
+
},
|
27
|
+
{
|
28
|
+
timestamps: true,
|
29
|
+
}
|
30
30
|
);
|
31
31
|
|
32
|
-
const ImageModel = model<
|
33
|
-
|
34
|
-
export default ImageModel;
|
32
|
+
export const ImageModel = model<IImageSchema>("image", ImageSchema);
|
package/entity/index.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
export * from "./image.entity";
|
2
|
+
export * from "./png-svg.entity";
|
3
|
+
export * from "./ppt-event.entity";
|
4
|
+
export * from "./ppt-slide.entity";
|
5
|
+
export * from "./ppt.entity";
|
6
|
+
export * from "./slide-layout.entity";
|
7
|
+
export * from "./slide.entity";
|
8
|
+
export * from "./socket.entity";
|
9
|
+
export * from "./template.entity";
|
10
|
+
export * from "./user.entity";
|
package/entity/png-svg.entity.ts
CHANGED
@@ -20,6 +20,4 @@ const PPTEventSchema = new Schema<IPPTEventSchema>(
|
|
20
20
|
}
|
21
21
|
);
|
22
22
|
|
23
|
-
const PPTSlideEventModel = model<IPPTEventSchema>("ppt-event", PPTEventSchema);
|
24
|
-
|
25
|
-
export default PPTSlideEventModel;
|
23
|
+
export const PPTSlideEventModel = model<IPPTEventSchema>("ppt-event", PPTEventSchema);
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import { Schema, model, Types, Document } from "mongoose";
|
2
|
-
|
3
|
-
|
4
2
|
export interface IPPTSlideSchema extends Document {
|
5
3
|
pptRef: Types.ObjectId;
|
6
4
|
slideRef: Types.ObjectId;
|
@@ -30,6 +28,4 @@ const PPTSlideSchema = new Schema<IPPTSlideSchema>(
|
|
30
28
|
}
|
31
29
|
);
|
32
30
|
|
33
|
-
const PPTSlideModel = model<IPPTSlideSchema>("ppt-slide", PPTSlideSchema);
|
34
|
-
|
35
|
-
export default PPTSlideModel;
|
31
|
+
export const PPTSlideModel = model<IPPTSlideSchema>("ppt-slide", PPTSlideSchema);
|
package/entity/ppt.entity.ts
CHANGED
@@ -21,6 +21,4 @@ const SlideLayoutSchema = new Schema<ISlideLayoutSchema>(
|
|
21
21
|
}
|
22
22
|
);
|
23
23
|
|
24
|
-
const SlideLayoutModel = model<ISlideLayoutSchema>("slide-layout", SlideLayoutSchema);
|
25
|
-
|
26
|
-
export default SlideLayoutModel;
|
24
|
+
export const SlideLayoutModel = model<ISlideLayoutSchema>("slide-layout", SlideLayoutSchema);
|
package/entity/slide.entity.ts
CHANGED
package/entity/socket.entity.ts
CHANGED
package/entity/user.entity.ts
CHANGED
package/middleware/role.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
export
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
export const ROLES = {
|
2
|
+
User: 'User',
|
3
|
+
Admin: 'Admin',
|
4
|
+
SuperAdmin: 'SuperAdmin'
|
5
|
+
}
|
package/package.json
CHANGED
package/types/index.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from "./IController";
|
2
|
+
export * from "./IRequest";
|
3
|
+
|
4
|
+
export enum QUEUES {
|
5
|
+
IMAGE_MODEL_BULK = "image-model-bulk", // Will be used for bulk training model
|
6
|
+
IMAGE_MODEL_SINGLE = "image-model-single", // Will be used for single image training
|
7
|
+
NOTIFICATION = "notification", // Notify to user
|
8
|
+
THUMBNAIL = "thumbnail", // To create thubmnail
|
9
|
+
PPT = "ppt", // to call PPT Service
|
10
|
+
PNG_SVG = "png-svg" // to convert raster to vector image
|
11
|
+
}
|
package/utilities/aws-s3.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
|
3
|
-
export async function getPreSignedUrl(s3: any, bucketName: string, filepath: string): Promise<string> {
|
4
|
-
const params =
|
5
|
-
{
|
6
|
-
Bucket: bucketName,
|
7
|
-
Key: filepath,
|
8
|
-
Expires: 24 * 60 * 60
|
9
|
-
};
|
10
|
-
const url = await s3.getSignedUrl('getObject', params);
|
11
|
-
return url;
|
12
|
-
}
|
13
|
-
|
14
|
-
export async function uploadFileToS3(s3: any, bucketName: string, cloudPath: string, filepath: string) {
|
15
|
-
const fileContent = fs.createReadStream(filepath);
|
16
|
-
const params = {
|
17
|
-
Bucket: bucketName,
|
18
|
-
Key: cloudPath,
|
19
|
-
Body: fileContent,
|
20
|
-
};
|
21
|
-
|
22
|
-
try {
|
23
|
-
await s3.upload(params).promise();
|
24
|
-
console.log('File uploaded successfully');
|
25
|
-
} catch (error) {
|
26
|
-
console.log(error);
|
27
|
-
throw error;
|
28
|
-
}
|
29
|
-
}
|