@avleon/core 0.0.7 → 0.0.10
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/dist/authentication.d.ts +6 -0
- package/dist/authentication.js +7 -2
- package/dist/collection.js +7 -0
- package/dist/config.d.ts +14 -27
- package/dist/config.js +21 -9
- package/dist/container.d.ts +8 -0
- package/dist/container.js +9 -1
- package/dist/controller.js +6 -0
- package/dist/decorators.d.ts +6 -0
- package/dist/decorators.js +6 -0
- package/dist/environment-variables.d.ts +12 -3
- package/dist/environment-variables.js +46 -23
- package/dist/exceptions/http-exceptions.d.ts +6 -0
- package/dist/exceptions/http-exceptions.js +6 -0
- package/dist/exceptions/system-exception.d.ts +9 -0
- package/dist/exceptions/system-exception.js +7 -1
- package/dist/file-storage.d.ts +17 -0
- package/dist/file-storage.js +153 -0
- package/dist/helpers.js +7 -1
- package/dist/icore.d.ts +108 -8
- package/dist/icore.js +208 -46
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -1
- package/dist/map-types.d.ts +6 -1
- package/dist/map-types.js +6 -1
- package/dist/middleware.js +6 -0
- package/dist/multipart.d.ts +17 -0
- package/dist/multipart.js +62 -0
- package/dist/openapi.d.ts +6 -0
- package/dist/params.js +6 -0
- package/dist/queue.d.ts +6 -0
- package/dist/queue.js +6 -0
- package/dist/response.d.ts +6 -0
- package/dist/response.js +8 -1
- package/dist/security.d.ts +4 -0
- package/dist/security.js +15 -0
- package/dist/swagger-schema.d.ts +6 -0
- package/dist/swagger-schema.js +6 -0
- package/dist/types/app-builder.interface.d.ts +6 -0
- package/dist/types/app-builder.interface.js +6 -0
- package/dist/types/application.interface.d.ts +6 -0
- package/dist/validation.d.ts +6 -0
- package/dist/validation.js +6 -0
- package/dist/validator-extend.d.ts +6 -0
- package/dist/validator-extend.js +6 -0
- package/package.json +15 -8
package/dist/middleware.js
CHANGED
|
@@ -5,6 +5,12 @@ exports.Authorize = Authorize;
|
|
|
5
5
|
exports.Authorized = Authorized;
|
|
6
6
|
exports.Middleware = Middleware;
|
|
7
7
|
exports.UseMiddleware = UseMiddleware;
|
|
8
|
+
/**
|
|
9
|
+
* @copyright 2024
|
|
10
|
+
* @author Tareq Hossain
|
|
11
|
+
* @email xtrinsic96@gmail.com
|
|
12
|
+
* @url https://github.com/xtareq
|
|
13
|
+
*/
|
|
8
14
|
const typedi_1 = require("typedi");
|
|
9
15
|
const container_1 = require("./container");
|
|
10
16
|
class AppMiddleware {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2024
|
|
3
|
+
* @author Tareq Hossain
|
|
4
|
+
* @email xtrinsic96@gmail.com
|
|
5
|
+
* @url https://github.com/xtareq
|
|
6
|
+
*/
|
|
7
|
+
import { MultipartFile as FsM } from "@fastify/multipart";
|
|
8
|
+
import { IRequest } from "./icore";
|
|
9
|
+
export declare function UploadFile(fieldName: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
10
|
+
export declare function UploadFiles(fieldName: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
11
|
+
type Foptions = {
|
|
12
|
+
saveAs?: string;
|
|
13
|
+
dest?: true;
|
|
14
|
+
};
|
|
15
|
+
export type MultipartFile = FsM;
|
|
16
|
+
export declare function UploadFileFromRequest(req: IRequest, options?: Foptions): Promise<FsM | undefined>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright 2024
|
|
4
|
+
* @author Tareq Hossain
|
|
5
|
+
* @email xtrinsic96@gmail.com
|
|
6
|
+
* @url https://github.com/xtareq
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UploadFile = UploadFile;
|
|
13
|
+
exports.UploadFiles = UploadFiles;
|
|
14
|
+
exports.UploadFileFromRequest = UploadFileFromRequest;
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const promises_1 = require("stream/promises");
|
|
18
|
+
const exceptions_1 = require("./exceptions");
|
|
19
|
+
const container_1 = require("./container");
|
|
20
|
+
function UploadFile(fieldName) {
|
|
21
|
+
return function (target, propertyKey, parameterIndex) {
|
|
22
|
+
if (!Reflect.hasMetadata(container_1.REQUEST_BODY_FILE_KEY, target, propertyKey)) {
|
|
23
|
+
Reflect.defineMetadata(container_1.REQUEST_BODY_FILE_KEY, [], target, propertyKey);
|
|
24
|
+
}
|
|
25
|
+
const existingMetadata = Reflect.getMetadata(container_1.REQUEST_BODY_FILE_KEY, target, propertyKey);
|
|
26
|
+
existingMetadata.push({ fieldName, index: parameterIndex });
|
|
27
|
+
Reflect.defineMetadata(container_1.REQUEST_BODY_FILE_KEY, existingMetadata, target, propertyKey);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function UploadFiles(fieldName) {
|
|
31
|
+
return function (target, propertyKey, parameterIndex) {
|
|
32
|
+
if (!Reflect.hasMetadata(container_1.REQUEST_BODY_FILES_KEY, target, propertyKey)) {
|
|
33
|
+
Reflect.defineMetadata(container_1.REQUEST_BODY_FILES_KEY, [], target, propertyKey);
|
|
34
|
+
}
|
|
35
|
+
const existingMetadata = Reflect.getMetadata(container_1.REQUEST_BODY_FILES_KEY, target, propertyKey);
|
|
36
|
+
existingMetadata.push({ fieldName, index: parameterIndex });
|
|
37
|
+
Reflect.defineMetadata(container_1.REQUEST_BODY_FILES_KEY, existingMetadata, target, propertyKey);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function UploadFileFromRequest(req, options) {
|
|
41
|
+
return Promise.resolve(req.file().then(async (f) => {
|
|
42
|
+
if (f && f.file) {
|
|
43
|
+
let fname = f.filename;
|
|
44
|
+
if (options) {
|
|
45
|
+
if (options.dest) {
|
|
46
|
+
fname = options.saveAs ? options.dest + '/' + options.saveAs : options.dest + '/' + f.filename;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
fname = path_1.default.join(process.cwd(), `public/${options.saveAs ? options.saveAs : f.filename}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
fname = path_1.default.join(process.cwd(), `public/${f.filename}`);
|
|
54
|
+
}
|
|
55
|
+
if (fs_1.default.existsSync(fname)) {
|
|
56
|
+
throw new exceptions_1.InternalErrorException("File already exists.");
|
|
57
|
+
}
|
|
58
|
+
await (0, promises_1.pipeline)(f.file, fs_1.default.createWriteStream(fname));
|
|
59
|
+
return Object.assign(Object.assign({}, f), { filename: (options === null || options === void 0 ? void 0 : options.saveAs) ? options.saveAs : f.filename });
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
}
|
package/dist/openapi.d.ts
CHANGED
package/dist/params.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright 2024
|
|
4
|
+
* @author Tareq Hossain
|
|
5
|
+
* @email xtrinsic96@gmail.com
|
|
6
|
+
* @url https://github.com/xtareq
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.AuthUser = exports.Header = exports.Body = exports.Query = exports.Param = void 0;
|
|
4
10
|
const container_1 = require("./container");
|
package/dist/queue.d.ts
CHANGED
package/dist/queue.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright 2024
|
|
4
|
+
* @author Tareq Hossain
|
|
5
|
+
* @email xtrinsic96@gmail.com
|
|
6
|
+
* @url https://github.com/xtareq
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.QueueManager = exports.FileQueueAdapter = void 0;
|
|
4
10
|
const fs_1 = require("fs");
|
package/dist/response.d.ts
CHANGED
package/dist/response.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright 2024
|
|
4
|
+
* @author Tareq Hossain
|
|
5
|
+
* @email xtrinsic96@gmail.com
|
|
6
|
+
* @url https://github.com/xtareq
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.HttpResponse = void 0;
|
|
4
10
|
require("reflect-metadata");
|
|
@@ -21,7 +27,8 @@ class HttpResponse {
|
|
|
21
27
|
enableImplicitConversion: true,
|
|
22
28
|
excludeExtraneousValues: true, // Ensures only @Expose() properties are included
|
|
23
29
|
});
|
|
24
|
-
return Object.assign({ message: "success" }, (isPaginated
|
|
30
|
+
return Object.assign({ message: "success" }, (isPaginated
|
|
31
|
+
? Object.assign(Object.assign({}, obj), { data: (0, class_transformer_1.instanceToPlain)(transformedData) }) : { data: (0, class_transformer_1.instanceToPlain)(transformedData) }));
|
|
25
32
|
}
|
|
26
33
|
return { message: "success", data: obj };
|
|
27
34
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const hashPasswordSync: (password: string) => string;
|
|
2
|
+
export declare const matchPasswordSync: (password: string, hash: string) => boolean;
|
|
3
|
+
export declare const hashPassword: (password: string) => Promise<string>;
|
|
4
|
+
export declare const matchPassword: (password: string, hash: string) => Promise<boolean>;
|
package/dist/security.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.matchPassword = exports.hashPassword = exports.matchPasswordSync = exports.hashPasswordSync = void 0;
|
|
7
|
+
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
8
|
+
const hashPasswordSync = (password) => bcryptjs_1.default.hashSync(password, 12);
|
|
9
|
+
exports.hashPasswordSync = hashPasswordSync;
|
|
10
|
+
const matchPasswordSync = (password, hash) => bcryptjs_1.default.compareSync(password, hash);
|
|
11
|
+
exports.matchPasswordSync = matchPasswordSync;
|
|
12
|
+
const hashPassword = (password) => bcryptjs_1.default.hash(password, 12);
|
|
13
|
+
exports.hashPassword = hashPassword;
|
|
14
|
+
const matchPassword = (password, hash) => bcryptjs_1.default.compare(password, hash);
|
|
15
|
+
exports.matchPassword = matchPassword;
|
package/dist/swagger-schema.d.ts
CHANGED
package/dist/swagger-schema.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateSwaggerSchema = generateSwaggerSchema;
|
|
4
|
+
/**
|
|
5
|
+
* @copyright 2024
|
|
6
|
+
* @author Tareq Hossain
|
|
7
|
+
* @email xtrinsic96@gmail.com
|
|
8
|
+
* @url https://github.com/xtareq
|
|
9
|
+
*/
|
|
4
10
|
function generateSwaggerSchema(classType) {
|
|
5
11
|
const { getMetadataStorage } = require("class-validator");
|
|
6
12
|
const { plainToInstance } = require("class-transformer");
|
package/dist/validation.d.ts
CHANGED
package/dist/validation.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright 2024
|
|
4
|
+
* @author Tareq Hossain
|
|
5
|
+
* @email xtrinsic96@gmail.com
|
|
6
|
+
* @url https://github.com/xtareq
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.validateOrThrow = validateOrThrow;
|
|
4
10
|
const exceptions_1 = require("./exceptions");
|
package/dist/validator-extend.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IsArrayNotEmpty = IsArrayNotEmpty;
|
|
4
|
+
/**
|
|
5
|
+
* @copyright 2024
|
|
6
|
+
* @author Tareq Hossain
|
|
7
|
+
* @email xtrinsic96@gmail.com
|
|
8
|
+
* @url https://github.com/xtareq
|
|
9
|
+
*/
|
|
4
10
|
function IsArrayNotEmpty(validationOptions) {
|
|
5
11
|
const { registerDecorator, ValidationArguments } = require("class-validator");
|
|
6
12
|
return function (object, propertyName) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avleon/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
|
-
"types":
|
|
5
|
+
"types": [
|
|
6
|
+
"./dist/index.d.ts",
|
|
7
|
+
"./exceptions/index.d.ts"
|
|
8
|
+
],
|
|
6
9
|
"scripts": {
|
|
7
10
|
"build": "rimraf dist && tsc",
|
|
8
11
|
"watch": "tsc-watch",
|
|
@@ -14,27 +17,31 @@
|
|
|
14
17
|
"license": "ISC",
|
|
15
18
|
"devDependencies": {
|
|
16
19
|
"@types/jest": "^29.5.14",
|
|
20
|
+
"class-transformer": "^0.5.1",
|
|
21
|
+
"class-validator": "^0.14.1",
|
|
17
22
|
"jest": "^29.7.0",
|
|
18
23
|
"nodemon": "^3.1.7",
|
|
24
|
+
"sharp": "^0.33.5",
|
|
19
25
|
"ts-jest": "^29.2.5",
|
|
20
26
|
"ts-node": "^10.9.2",
|
|
21
27
|
"tsc-watch": "^6.2.1",
|
|
28
|
+
"typeorm": "^0.3.20",
|
|
22
29
|
"typescript": "^5.7.2"
|
|
23
30
|
},
|
|
24
31
|
"dependencies": {
|
|
32
|
+
"@fastify/cors": "^11.0.0",
|
|
33
|
+
"@fastify/multipart": "^9.0.3",
|
|
25
34
|
"@fastify/static": "^8.1.1",
|
|
26
35
|
"@fastify/swagger": "^9.4.0",
|
|
27
36
|
"@fastify/swagger-ui": "^5.1.0",
|
|
28
|
-
"
|
|
29
|
-
"class-validator": "^0.14.1",
|
|
37
|
+
"bcryptjs": "^3.0.2",
|
|
30
38
|
"dotenv": "^16.4.7",
|
|
31
39
|
"fastify": "^5.1.0",
|
|
32
40
|
"reflect-metadata": "^0.2.2",
|
|
33
|
-
"typedi": "^0.10.0"
|
|
34
|
-
"typeorm": "^0.3.20"
|
|
41
|
+
"typedi": "^0.10.0"
|
|
35
42
|
},
|
|
36
43
|
"peerDependencies": {
|
|
37
|
-
"
|
|
44
|
+
"typeorm": "^0.3.20"
|
|
38
45
|
},
|
|
39
46
|
"directories": {
|
|
40
47
|
"test": "tests"
|
|
@@ -44,4 +51,4 @@
|
|
|
44
51
|
"type": "git",
|
|
45
52
|
"url": "git+https://github.com/avleonjs/avleon-core"
|
|
46
53
|
}
|
|
47
|
-
}
|
|
54
|
+
}
|