@nu-art/ts-short-url-backend 0.401.8 → 0.500.0
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
type Config =
|
|
1
|
+
import { API_ShortUrl, DB_ShortUrl, DatabaseDef_ShortUrl, UI_ShortUrl } from '@nu-art/ts-short-url-shared';
|
|
2
|
+
import { ModuleBE_BaseDB } from '@nu-art/db-api-backend';
|
|
3
|
+
type Config = {
|
|
4
4
|
BaseShortUrl: string;
|
|
5
5
|
};
|
|
6
|
-
export declare class ModuleBE_ShortUrlDB_Class extends ModuleBE_BaseDB<
|
|
6
|
+
export declare class ModuleBE_ShortUrlDB_Class extends ModuleBE_BaseDB<DatabaseDef_ShortUrl, Config> {
|
|
7
7
|
constructor();
|
|
8
8
|
init(): void;
|
|
9
|
-
|
|
10
|
-
protected preWriteProcessing(dbInstance:
|
|
9
|
+
getShortUrl(params: API_ShortUrl['getShortUrl']['Params']): Promise<API_ShortUrl['getShortUrl']['Response']>;
|
|
10
|
+
protected preWriteProcessing(dbInstance: UI_ShortUrl, originalDbInstance: DB_ShortUrl, transaction?: FirebaseFirestore.Transaction): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const ModuleBE_ShortUrlDB: ModuleBE_ShortUrlDB_Class;
|
|
13
13
|
export {};
|
|
@@ -1,28 +1,73 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
1
35
|
import { ApiDef_ShortUrl, DBDef_ShortUrl } from '@nu-art/ts-short-url-shared';
|
|
2
|
-
import {
|
|
36
|
+
import { ModuleBE_BaseDB } from '@nu-art/db-api-backend';
|
|
37
|
+
import { ApiHandler } from '@nu-art/http-server';
|
|
3
38
|
import { generateShortURL } from '@nu-art/ts-common';
|
|
4
39
|
import { HttpCodes } from '@nu-art/ts-common/core/exceptions/http-codes';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
let ModuleBE_ShortUrlDB_Class = (() => {
|
|
41
|
+
let _classSuper = ModuleBE_BaseDB;
|
|
42
|
+
let _instanceExtraInitializers = [];
|
|
43
|
+
let _getShortUrl_decorators;
|
|
44
|
+
return class ModuleBE_ShortUrlDB_Class extends _classSuper {
|
|
45
|
+
static {
|
|
46
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
47
|
+
_getShortUrl_decorators = [ApiHandler(ApiDef_ShortUrl.getShortUrl)];
|
|
48
|
+
__esDecorate(this, null, _getShortUrl_decorators, { kind: "method", name: "getShortUrl", static: false, private: false, access: { has: obj => "getShortUrl" in obj, get: obj => obj.getShortUrl }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
49
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
50
|
+
}
|
|
51
|
+
constructor() {
|
|
52
|
+
super(DBDef_ShortUrl);
|
|
53
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
54
|
+
}
|
|
55
|
+
init() {
|
|
56
|
+
super.init();
|
|
57
|
+
}
|
|
58
|
+
async getShortUrl(params) {
|
|
59
|
+
const dbDoc = await this.query.unique(params._id);
|
|
60
|
+
if (!dbDoc)
|
|
61
|
+
throw HttpCodes._5XX.INTERNAL_SERVER_ERROR(`db doc with id ${params._id} not found`);
|
|
62
|
+
return {
|
|
63
|
+
shortUrl: `${this.config.BaseShortUrl}${dbDoc._shortUrl}`
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async preWriteProcessing(dbInstance, originalDbInstance, transaction) {
|
|
67
|
+
if (!dbInstance._shortUrl)
|
|
68
|
+
dbInstance._shortUrl = generateShortURL();
|
|
69
|
+
}
|
|
22
70
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
dbInstance._shortUrl = generateShortURL();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
71
|
+
})();
|
|
72
|
+
export { ModuleBE_ShortUrlDB_Class };
|
|
28
73
|
export const ModuleBE_ShortUrlDB = new ModuleBE_ShortUrlDB_Class();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApisForDBModuleV3 } from '@nu-art/thunderstorm-backend';
|
|
1
|
+
import { createApisForDBModule } from '@nu-art/db-api-backend';
|
|
3
2
|
import { Module_ShortUrlResolver } from '../../function-module/Module_ShortUrlResolver.js';
|
|
4
|
-
|
|
3
|
+
import { ModuleBE_ShortUrlDB } from './ModuleBE_ShortUrlDB.js';
|
|
4
|
+
export const ModulePackBE_ShortUrlDB = [ModuleBE_ShortUrlDB, Module_ShortUrlResolver, createApisForDBModule(ModuleBE_ShortUrlDB)];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PermissionKey_BE } from '@nu-art/permissions-backend/PermissionKey_BE';
|
|
2
2
|
import { DefaultDef_Package } from '@nu-art/permissions-backend';
|
|
3
3
|
export declare const Domain_ShortUrl: Readonly<{
|
|
4
|
-
_id: "
|
|
4
|
+
_id: import("@nu-art/db-api-shared").DB_UniqueId<"permissions--domain">;
|
|
5
5
|
namespace: "short-url";
|
|
6
6
|
}>;
|
|
7
7
|
export declare const PermissionKeyBE_ShortUrlView: PermissionKey_BE<"permission-key--short-url-view">;
|
|
@@ -2,8 +2,9 @@ import { DefaultAccessLevel_Read, DefaultAccessLevel_Write, DuplicateDefaultAcce
|
|
|
2
2
|
import { defaultValueResolver, PermissionKey_BE } from '@nu-art/permissions-backend/PermissionKey_BE';
|
|
3
3
|
import { ModuleBE_ShortUrlDB } from './ModuleBE_ShortUrlDB.js';
|
|
4
4
|
import { DomainNamespace_ShortUrl, PermissionKey_ShortUrlEdit, PermissionKey_ShortUrlView } from '@nu-art/ts-short-url-shared';
|
|
5
|
+
import { asBrandedId } from '@nu-art/db-api-shared';
|
|
5
6
|
export const Domain_ShortUrl = Object.freeze({
|
|
6
|
-
_id: '8a7614bc128ee1fb6ddf896c46922ab3',
|
|
7
|
+
_id: asBrandedId('8a7614bc128ee1fb6ddf896c46922ab3'),
|
|
7
8
|
namespace: DomainNamespace_ShortUrl
|
|
8
9
|
});
|
|
9
10
|
export const PermissionKeyBE_ShortUrlView = new PermissionKey_BE(PermissionKey_ShortUrlView, () => defaultValueResolver(DomainNamespace_ShortUrl, DefaultAccessLevel_Read.value));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/ts-short-url-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.500.0",
|
|
4
4
|
"description": "ts-short-url - Express & Typescript based backend framework Backend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
"build": "tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nu-art/ts-short-url-shared": "0.
|
|
35
|
-
"@nu-art/firebase-backend": "0.
|
|
36
|
-
"@nu-art/firebase-shared": "0.
|
|
37
|
-
"@nu-art/permissions-backend": "0.
|
|
38
|
-
"@nu-art/permissions-shared": "0.
|
|
39
|
-
"@nu-art/
|
|
40
|
-
"@nu-art/
|
|
41
|
-
"@nu-art/ts-common": "0.401.8",
|
|
34
|
+
"@nu-art/ts-short-url-shared": "0.500.0",
|
|
35
|
+
"@nu-art/firebase-backend": "0.500.0",
|
|
36
|
+
"@nu-art/firebase-shared": "0.500.0",
|
|
37
|
+
"@nu-art/permissions-backend": "0.500.0",
|
|
38
|
+
"@nu-art/permissions-shared": "0.500.0",
|
|
39
|
+
"@nu-art/db-api-shared": "0.500.0",
|
|
40
|
+
"@nu-art/ts-common": "0.500.0",
|
|
42
41
|
"firebase": "^11.9.0",
|
|
43
42
|
"firebase-admin": "13.4.0",
|
|
44
43
|
"firebase-functions": "6.3.2",
|
|
45
|
-
"react": "^18.0.0"
|
|
44
|
+
"react": "^18.0.0",
|
|
45
|
+
"@nu-art/db-api-backend": "0.500.0",
|
|
46
|
+
"@nu-art/http-server": "{{THUNDERSTORM_VERSION}}"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/react": "^18.0.0",
|