@roadmanjs/firebase-admin 0.1.1 → 1.0.2
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/_utils/file.utils.d.ts +1 -0
- package/dist/_utils/file.utils.d.ts.map +1 -0
- package/dist/_utils/uuid.d.ts +1 -0
- package/dist/_utils/uuid.d.ts.map +1 -0
- package/dist/client/gql/index.d.ts +1 -0
- package/dist/client/gql/index.d.ts.map +1 -0
- package/dist/client/gql/media.fragment.d.ts +1 -0
- package/dist/client/gql/media.fragment.d.ts.map +1 -0
- package/dist/client/gql/media.mutation.d.ts +1 -0
- package/dist/client/gql/media.mutation.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +0 -1
- package/dist/config.js.map +1 -1
- package/dist/firebase/index.d.ts +3 -2
- package/dist/firebase/index.d.ts.map +1 -0
- package/dist/firebase/index.js +31 -26
- package/dist/firebase/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/media/file.input.d.ts +1 -0
- package/dist/media/file.input.d.ts.map +1 -0
- package/dist/media/file.input.js +9 -9
- package/dist/media/file.input.js.map +1 -1
- package/dist/media/media.model.d.ts +1 -2
- package/dist/media/media.model.d.ts.map +1 -0
- package/dist/media/media.model.js +17 -17
- package/dist/media/media.model.js.map +1 -1
- package/dist/roadman.d.ts +2 -3
- package/dist/roadman.d.ts.map +1 -0
- package/dist/roadman.js +4 -19
- package/dist/roadman.js.map +1 -1
- package/dist/script.d.ts +1 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.d.ts.map +1 -0
- package/package.json +8 -50
- package/dist/firebase/firebase.test.d.ts +0 -1
- package/dist/firebase/firebase.test.js +0 -54
- package/dist/firebase/firebase.test.js.map +0 -1
- package/dist/media/media.methods.d.ts +0 -1
- package/dist/media/media.methods.js +0 -36
- package/dist/media/media.methods.js.map +0 -1
- package/dist/media/media.resolver.d.ts +0 -8
- package/dist/media/media.resolver.js +0 -164
- package/dist/media/media.resolver.js.map +0 -1
- package/dist/middlewares/index.d.ts +0 -1
- package/dist/middlewares/index.js +0 -18
- package/dist/middlewares/index.js.map +0 -1
- package/dist/middlewares/isAuth.d.ts +0 -10
- package/dist/middlewares/isAuth.js +0 -36
- package/dist/middlewares/isAuth.js.map +0 -1
- package/dist/shared.d.ts +0 -8
- package/dist/shared.js +0 -3
- package/dist/shared.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.utils.d.ts","sourceRoot":"","sources":["../../src/_utils/file.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAc,MAAM,WAEhD,CAAC"}
|
package/dist/_utils/uuid.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/_utils/uuid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,QAAO,MAE/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/gql/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.fragment.d.ts","sourceRoot":"","sources":["../../../src/client/gql/media.fragment.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,aAAa;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,qBAAqB,gCAajC,CAAC"}
|
|
@@ -2,3 +2,4 @@ export declare const UPLOAD_FILES_MUTATION: import("graphql").DocumentNode;
|
|
|
2
2
|
export declare const UPLOAD_STRING_FILES_MUTATION: import("graphql").DocumentNode;
|
|
3
3
|
export declare const UPLOAD_FILES_FASTDFS_MUTATION: import("graphql").DocumentNode;
|
|
4
4
|
export declare const UPLOAD_STRING_FILES_FASTDFS_MUTATION: import("graphql").DocumentNode;
|
|
5
|
+
//# sourceMappingURL=media.mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.mutation.d.ts","sourceRoot":"","sources":["../../../src/client/gql/media.mutation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,gCAOjC,CAAC;AAEF,eAAO,MAAM,4BAA4B,gCAOxC,CAAC;AAGF,eAAO,MAAM,6BAA6B,gCAOzC,CAAC;AAEF,eAAO,MAAM,oCAAoC,gCAOhD,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,KAAqC,CAAC;AAElD,eAAe,MAAM,CAAC"}
|
package/dist/config.js
CHANGED
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAAA,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;AAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAElD,kBAAe,MAAM,CAAC"}
|
package/dist/firebase/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { app } from 'firebase-admin';
|
|
1
|
+
import type { app } from 'firebase-admin';
|
|
2
2
|
export interface FirebaseConfig {
|
|
3
3
|
appOptions: any;
|
|
4
4
|
name?: string;
|
|
@@ -6,4 +6,5 @@ export interface FirebaseConfig {
|
|
|
6
6
|
export interface FirebaseProject extends app.App {
|
|
7
7
|
projectId: string;
|
|
8
8
|
}
|
|
9
|
-
export declare
|
|
9
|
+
export declare let configureFirebase: (fbconfig?: FirebaseConfig) => Promise<FirebaseProject>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firebase/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,GAAG,CAAC,GAAG;IAC5C,SAAS,EAAE,MAAM,CAAC;CACrB;AAKD,eAAO,IAAI,iBAAiB,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC"}
|
package/dist/firebase/index.js
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.configureFirebase = void 0;
|
|
30
|
-
const
|
|
7
|
+
const flarebase_auth_1 = require("@marplex/flarebase-auth");
|
|
8
|
+
const utils_1 = require("@roadmanjs/utils/dist/utils");
|
|
31
9
|
const config_1 = __importDefault(require("../config"));
|
|
32
|
-
|
|
10
|
+
let admin;
|
|
11
|
+
const edge = (0, utils_1.isEdge)();
|
|
12
|
+
const configureFirebaseNode = async (fbconfig) => {
|
|
33
13
|
if (fbconfig) {
|
|
34
14
|
const initAndReturn = async () => {
|
|
35
15
|
const app = await admin.initializeApp({
|
|
@@ -64,5 +44,30 @@ const configureFirebase = async (fbconfig) => {
|
|
|
64
44
|
const projectId = config_1.default.project_id;
|
|
65
45
|
return Object.assign({ projectId }, defaultApp);
|
|
66
46
|
};
|
|
67
|
-
|
|
47
|
+
const configureFirebaseEdge = async (fbconfig) => {
|
|
48
|
+
const initAndReturn = async (_config) => {
|
|
49
|
+
const auth = () => new flarebase_auth_1.FlarebaseAuth({
|
|
50
|
+
apiKey: _config.appOptions.apiKey,
|
|
51
|
+
projectId: _config.appOptions.project_id,
|
|
52
|
+
privateKey: _config.appOptions.private_key,
|
|
53
|
+
serviceAccountEmail: _config.appOptions.client_email,
|
|
54
|
+
});
|
|
55
|
+
// initialize app
|
|
56
|
+
return {
|
|
57
|
+
projectId: _config.name || _config.appOptions.project_id,
|
|
58
|
+
auth,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
if (fbconfig) {
|
|
62
|
+
return initAndReturn(fbconfig);
|
|
63
|
+
}
|
|
64
|
+
return initAndReturn(config_1.default);
|
|
65
|
+
};
|
|
66
|
+
if (edge) {
|
|
67
|
+
exports.configureFirebase = configureFirebaseEdge;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
admin = require('firebase-admin');
|
|
71
|
+
exports.configureFirebase = configureFirebaseNode;
|
|
72
|
+
}
|
|
68
73
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firebase/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firebase/index.ts"],"names":[],"mappings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HANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.input.d.ts","sourceRoot":"","sources":["../../src/media/file.input.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAE5C,qBACa,SAAU,YAAW,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;CAC3D;AAED,qBACa,eAAe;IACe,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,GAAG,EAAE,MAAM,CAAC;CACtD"}
|
package/dist/media/file.input.js
CHANGED
|
@@ -7,35 +7,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.FileStringInput = exports.FileInput = void 0;
|
|
10
|
-
const
|
|
10
|
+
const type_graphql_1 = require("type-graphql");
|
|
11
11
|
let FileInput = class FileInput {
|
|
12
12
|
};
|
|
13
13
|
exports.FileInput = FileInput;
|
|
14
14
|
__decorate([
|
|
15
|
-
(0,
|
|
15
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
16
16
|
], FileInput.prototype, "filename", void 0);
|
|
17
17
|
__decorate([
|
|
18
|
-
(0,
|
|
18
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
19
19
|
], FileInput.prototype, "mimetype", void 0);
|
|
20
20
|
__decorate([
|
|
21
|
-
(0,
|
|
21
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
22
22
|
], FileInput.prototype, "encoding", void 0);
|
|
23
23
|
exports.FileInput = FileInput = __decorate([
|
|
24
|
-
(0,
|
|
24
|
+
(0, type_graphql_1.InputType)()
|
|
25
25
|
], FileInput);
|
|
26
26
|
let FileStringInput = class FileStringInput {
|
|
27
27
|
};
|
|
28
28
|
exports.FileStringInput = FileStringInput;
|
|
29
29
|
__decorate([
|
|
30
|
-
(0,
|
|
30
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
31
31
|
], FileStringInput.prototype, "filename", void 0);
|
|
32
32
|
__decorate([
|
|
33
|
-
(0,
|
|
33
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
34
34
|
], FileStringInput.prototype, "mimetype", void 0);
|
|
35
35
|
__decorate([
|
|
36
|
-
(0,
|
|
36
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
37
37
|
], FileStringInput.prototype, "uri", void 0);
|
|
38
38
|
exports.FileStringInput = FileStringInput = __decorate([
|
|
39
|
-
(0,
|
|
39
|
+
(0, type_graphql_1.InputType)('FileStringInput')
|
|
40
40
|
], FileStringInput);
|
|
41
41
|
//# sourceMappingURL=file.input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.input.js","sourceRoot":"","sources":["../../src/media/file.input.ts"],"names":[],"mappings":";;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"file.input.js","sourceRoot":"","sources":["../../src/media/file.input.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA8C;AAKvC,IAAM,SAAS,GAAf,MAAM,SAAS;CAMrB,CAAA;AANY,8BAAS;AACqB;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CAAkB;AAEjB;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CAAkB;AAEjB;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CAAkB;oBAL/C,SAAS;IADrB,IAAA,wBAAS,GAAE;GACC,SAAS,CAMrB;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;CAM3B,CAAA;AANY,0CAAe;AACe;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDAAkB;AAEjB;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDAAkB;AAEjB;IAAtC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;4CAAa;0BAL1C,eAAe;IAD3B,IAAA,wBAAS,EAAC,iBAAiB,CAAC;GAChB,eAAe,CAM3B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Model } from 'couchset';
|
|
2
1
|
/**
|
|
3
2
|
* GraphQL Types start
|
|
4
3
|
*/
|
|
@@ -19,5 +18,5 @@ export declare class MediaDataType {
|
|
|
19
18
|
/**
|
|
20
19
|
* GraphQL Types end
|
|
21
20
|
*/
|
|
22
|
-
export declare const MediaDataModel: Model;
|
|
23
21
|
export default MediaDataType;
|
|
22
|
+
//# sourceMappingURL=media.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.model.d.ts","sourceRoot":"","sources":["../../src/media/media.model.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBACa,aAAa;IAEtB,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AAIH,eAAe,aAAa,CAAC"}
|
|
@@ -6,9 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const
|
|
11
|
-
const modelName = 'Media';
|
|
9
|
+
exports.MediaDataType = void 0;
|
|
10
|
+
const type_graphql_1 = require("type-graphql");
|
|
11
|
+
// const modelName = 'Media';
|
|
12
12
|
/**
|
|
13
13
|
* GraphQL Types start
|
|
14
14
|
*/
|
|
@@ -16,50 +16,50 @@ let MediaDataType = class MediaDataType {
|
|
|
16
16
|
};
|
|
17
17
|
exports.MediaDataType = MediaDataType;
|
|
18
18
|
__decorate([
|
|
19
|
-
(0,
|
|
19
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
20
20
|
], MediaDataType.prototype, "id", void 0);
|
|
21
21
|
__decorate([
|
|
22
|
-
(0,
|
|
22
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
23
23
|
], MediaDataType.prototype, "name", void 0);
|
|
24
24
|
__decorate([
|
|
25
|
-
(0,
|
|
25
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
26
26
|
], MediaDataType.prototype, "filename", void 0);
|
|
27
27
|
__decorate([
|
|
28
|
-
(0,
|
|
28
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
29
29
|
], MediaDataType.prototype, "mimetype", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
(0,
|
|
31
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
32
32
|
], MediaDataType.prototype, "encoding", void 0);
|
|
33
33
|
__decorate([
|
|
34
|
-
(0,
|
|
34
|
+
(0, type_graphql_1.Field)(() => String, {
|
|
35
35
|
nullable: true,
|
|
36
36
|
description: 'The server where the file is stored, e.g fastdfs',
|
|
37
37
|
})
|
|
38
38
|
], MediaDataType.prototype, "server", void 0);
|
|
39
39
|
__decorate([
|
|
40
|
-
(0,
|
|
40
|
+
(0, type_graphql_1.Field)(() => Number, { nullable: true })
|
|
41
41
|
], MediaDataType.prototype, "size", void 0);
|
|
42
42
|
__decorate([
|
|
43
|
-
(0,
|
|
43
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
44
44
|
], MediaDataType.prototype, "path", void 0);
|
|
45
45
|
__decorate([
|
|
46
|
-
(0,
|
|
46
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
47
47
|
], MediaDataType.prototype, "url", void 0);
|
|
48
48
|
__decorate([
|
|
49
|
-
(0,
|
|
49
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true })
|
|
50
50
|
], MediaDataType.prototype, "owner", void 0);
|
|
51
51
|
__decorate([
|
|
52
|
-
(0,
|
|
52
|
+
(0, type_graphql_1.Field)(() => Date, { nullable: true })
|
|
53
53
|
], MediaDataType.prototype, "createdAt", void 0);
|
|
54
54
|
__decorate([
|
|
55
|
-
(0,
|
|
55
|
+
(0, type_graphql_1.Field)(() => Date, { nullable: true })
|
|
56
56
|
], MediaDataType.prototype, "updatedAt", void 0);
|
|
57
57
|
exports.MediaDataType = MediaDataType = __decorate([
|
|
58
|
-
(0,
|
|
58
|
+
(0, type_graphql_1.ObjectType)()
|
|
59
59
|
], MediaDataType);
|
|
60
60
|
/**
|
|
61
61
|
* GraphQL Types end
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
// export const MediaDataModel: Model = new Model(modelName);
|
|
64
64
|
exports.default = MediaDataType;
|
|
65
65
|
//# sourceMappingURL=media.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.model.js","sourceRoot":"","sources":["../../src/media/media.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"media.model.js","sourceRoot":"","sources":["../../src/media/media.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA+C;AAE/C,6BAA6B;AAC7B;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;CAuCzB,CAAA;AAvCY,sCAAa;AAEtB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;yCAC1B;AAGZ;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CACxB;AAGd;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;+CACpB;AAGlB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;+CACpB;AAGlB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;+CACpB;AAMlB;IAJC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,kDAAkD;KAClE,CAAC;6CACc;AAGhB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CACxB;AAGd;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;2CACxB;AAGd;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;0CACzB;AAGb;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;4CACvB;AAGf;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;gDACnB;AAGjB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;gDACnB;wBAtCR,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAuCzB;AAED;;GAEG;AAEH,6DAA6D;AAE7D,kBAAe,aAAa,CAAC"}
|
package/dist/roadman.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RoadMan } from '@roadmanjs/core';
|
|
2
|
-
import MediaResolver from './media/media.resolver';
|
|
1
|
+
import type { RoadMan } from '@roadmanjs/core';
|
|
3
2
|
/**
|
|
4
3
|
* A firebase roadman
|
|
5
4
|
* @param RoadmanBuild
|
|
6
5
|
* TODO mediaRoadman
|
|
7
6
|
*/
|
|
8
7
|
export declare const firebaseRoadman: RoadMan;
|
|
9
|
-
|
|
8
|
+
//# sourceMappingURL=roadman.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roadman.d.ts","sourceRoot":"","sources":["../src/roadman.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAQ3D;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,OAU7B,CAAC"}
|
package/dist/roadman.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
3
|
+
exports.firebaseRoadman = void 0;
|
|
4
|
+
// import MediaResolver from './media/media.resolver';
|
|
8
5
|
// import MediaResolverFastdfs from './media/media.resolver.fastdfs';
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
6
|
const firebase_1 = require("./firebase");
|
|
11
7
|
// import {isEmpty} from 'lodash';
|
|
12
8
|
const logs_1 = require("@roadmanjs/logs");
|
|
@@ -17,20 +13,9 @@ const logs_1 = require("@roadmanjs/logs");
|
|
|
17
13
|
*/
|
|
18
14
|
const firebaseRoadman = async (args) => {
|
|
19
15
|
const { projectId } = await (0, firebase_1.configureFirebase)();
|
|
20
|
-
(0, logs_1.log)('ROADMAN: Firebase',
|
|
21
|
-
// const FASTDFS_SERVER = process.env.FASTDFS_SERVER;
|
|
22
|
-
// log(
|
|
23
|
-
// 'ROADMAN: FASTDFS',
|
|
24
|
-
// isEmpty(FASTDFS_SERVER)
|
|
25
|
-
// ? chalk.redBright('FASTDFS_SERVER not set')
|
|
26
|
-
// : chalk.greenBright(
|
|
27
|
-
// '**************************************FASTDFS********************',
|
|
28
|
-
// FASTDFS_SERVER
|
|
29
|
-
// )
|
|
30
|
-
// );
|
|
16
|
+
(0, logs_1.log)('ROADMAN: Firebase', '**************************************ProjectID********************', projectId);
|
|
31
17
|
return args;
|
|
32
18
|
};
|
|
33
19
|
exports.firebaseRoadman = firebaseRoadman;
|
|
34
|
-
const getMediaFileUploadResolvers = () => [
|
|
35
|
-
exports.getMediaFileUploadResolvers = getMediaFileUploadResolvers;
|
|
20
|
+
// export const getMediaFileUploadResolvers = () => [MediaResolver];
|
|
36
21
|
//# sourceMappingURL=roadman.js.map
|
package/dist/roadman.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roadman.js","sourceRoot":"","sources":["../src/roadman.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"roadman.js","sourceRoot":"","sources":["../src/roadman.ts"],"names":[],"mappings":";;;AAEA,sDAAsD;AACtD,qEAAqE;AACrE,yCAA6C;AAC7C,kCAAkC;AAClC,0CAAoC;AAEpC;;;;GAIG;AACI,MAAM,eAAe,GAAY,KAAK,EAAE,IAAkB,EAAyB,EAAE;IACxF,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,IAAA,4BAAiB,GAAE,CAAC;IAE9C,IAAA,UAAG,EACC,mBAAmB,EACnB,qEAAqE,EACrE,SAAS,CACZ,CAAC;IAEF,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B;AAEF,oEAAoE"}
|
package/dist/script.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../src/script.ts"],"names":[],"mappings":""}
|
package/dist/test.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roadmanjs/firebase-admin",
|
|
3
|
-
"version": "0.1.1",
|
|
4
3
|
"description": "A roadman for firebase-admin",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
5
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
"private": false,
|
|
20
19
|
"scripts": {
|
|
21
20
|
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json",
|
|
22
|
-
"build": "rm -rf dist &&
|
|
21
|
+
"build": "rm -rf dist && tsc --skipLibCheck && npm run client",
|
|
23
22
|
"client": "node dist/script.js",
|
|
24
23
|
"test": "ts-node src/test.ts",
|
|
25
24
|
"fb:test": "mocha src/firebase/*test.ts --exit",
|
|
@@ -35,58 +34,17 @@
|
|
|
35
34
|
"pre-commit": "lint-staged"
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/chai": "^4.2.14",
|
|
40
|
-
"@types/chalk": "^2.2.0",
|
|
41
|
-
"@types/debug": "^4.1.5",
|
|
42
|
-
"@types/dotenv": "^8.2.0",
|
|
43
|
-
"@types/lodash": "^4.14.168",
|
|
44
|
-
"@types/mocha": "^8.2.0",
|
|
45
|
-
"@types/node": "^10.0.3",
|
|
46
|
-
"@types/request": "^2.48.8",
|
|
47
|
-
"@types/source-map-support": "^0.4.0",
|
|
48
|
-
"@types/uuid": "8.3.1",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
|
50
|
-
"@typescript-eslint/parser": "^3.4.0",
|
|
51
|
-
"chai": "^4.2.0",
|
|
52
|
-
"eslint": "^6.8.0",
|
|
53
|
-
"eslint-config-prettier": "^6.11.0",
|
|
54
|
-
"eslint-loader": "^4.0.2",
|
|
55
|
-
"eslint-plugin-import": "^2.20.2",
|
|
56
|
-
"eslint-plugin-json": "^2.1.1",
|
|
57
|
-
"eslint-plugin-prettier": "^3.1.4",
|
|
58
|
-
"eslint-plugin-simple-import-sort": "^5.0.2",
|
|
59
|
-
"eslint-plugin-typescript": "^0.14.0",
|
|
60
|
-
"husky": "^4.2.5",
|
|
61
|
-
"lint-staged": "^10.1.7",
|
|
62
|
-
"mocha": "^10.7.3",
|
|
63
|
-
"prettier": "^2.0.5",
|
|
64
|
-
"reflect-metadata": "^0.1.13",
|
|
65
|
-
"rimraf": "^2.5.4",
|
|
66
|
-
"ts-node": "^10.9.2",
|
|
67
|
-
"tslint": "^5.11.0",
|
|
68
|
-
"tslint-config-standard": "^8.0.1",
|
|
69
|
-
"typescript": "^5.6.2"
|
|
70
|
-
},
|
|
71
|
-
"peerDependencies": {
|
|
72
|
-
"@roadmanjs/couchset": ">=0.1.1",
|
|
73
|
-
"couchset": ">=0.0.18",
|
|
74
|
-
"graphql-upload": ">=13.0.0",
|
|
75
|
-
"typescript": ">=2.0"
|
|
76
|
-
},
|
|
77
37
|
"dependencies": {
|
|
78
|
-
"@
|
|
79
|
-
"@roadmanjs/
|
|
80
|
-
"@roadmanjs/logs": "
|
|
81
|
-
"@roadmanjs/utils": "
|
|
38
|
+
"@marplex/flarebase-auth": "^1.2.0",
|
|
39
|
+
"@roadmanjs/core": "*",
|
|
40
|
+
"@roadmanjs/logs": "*",
|
|
41
|
+
"@roadmanjs/utils": "*",
|
|
82
42
|
"@stoqey/client-graphql": "^1.1.13",
|
|
83
|
-
"chalk": "^4.1.0",
|
|
84
43
|
"debug": "^4.3.1",
|
|
85
|
-
"dotenv": "^8.2.0",
|
|
86
44
|
"firebase-admin": "^12.6.0",
|
|
87
|
-
"graphql-upload": "13",
|
|
88
45
|
"lodash": "^4.17.20",
|
|
89
|
-
"type-graphql": "^
|
|
46
|
+
"type-graphql": "^ 2.0.0-rc.2",
|
|
90
47
|
"uuid": "^8.3.2"
|
|
91
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"version": "1.0.2"
|
|
92
50
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'mocha';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("mocha");
|
|
4
|
-
const _1 = require("./");
|
|
5
|
-
const chai_1 = require("chai");
|
|
6
|
-
const FIREBASE_CUSTOM_CONFIG = process.env.FIREBASE_CUSTOM_CONFIG || '{}';
|
|
7
|
-
const getCustomProjectConfig = () => JSON.parse(FIREBASE_CUSTOM_CONFIG);
|
|
8
|
-
const customProjectId = getCustomProjectConfig().project_id;
|
|
9
|
-
const opts = {
|
|
10
|
-
appOptions: getCustomProjectConfig(),
|
|
11
|
-
name: customProjectId,
|
|
12
|
-
};
|
|
13
|
-
describe('Firebase', () => {
|
|
14
|
-
it('should init firebase default project', async () => {
|
|
15
|
-
const firebaseProject = await (0, _1.configureFirebase)();
|
|
16
|
-
const projectId = firebaseProject.projectId;
|
|
17
|
-
console.log('projectId', projectId);
|
|
18
|
-
(0, chai_1.expect)(projectId).to.equal('stqnetwork-dev');
|
|
19
|
-
});
|
|
20
|
-
it('should init firebase custom project then default project', async () => {
|
|
21
|
-
const firebaseProject = await (0, _1.configureFirebase)(opts);
|
|
22
|
-
const projectId = firebaseProject.projectId;
|
|
23
|
-
console.log('projectId', projectId);
|
|
24
|
-
(0, chai_1.expect)(projectId).to.equal(customProjectId);
|
|
25
|
-
const defaultProject = await (0, _1.configureFirebase)();
|
|
26
|
-
(0, chai_1.expect)(defaultProject.projectId).to.equal('stqnetwork-dev');
|
|
27
|
-
});
|
|
28
|
-
it('should init firebase custom project', async () => {
|
|
29
|
-
const firebaseProject = await (0, _1.configureFirebase)(opts);
|
|
30
|
-
const projectId = firebaseProject.projectId;
|
|
31
|
-
console.log('projectId', projectId);
|
|
32
|
-
(0, chai_1.expect)(projectId).to.equal(customProjectId);
|
|
33
|
-
});
|
|
34
|
-
it('should init firebase custom project with default project', async () => {
|
|
35
|
-
await (0, _1.configureFirebase)(); // init default project.
|
|
36
|
-
// init second project
|
|
37
|
-
const firebaseProject = await (0, _1.configureFirebase)(opts);
|
|
38
|
-
const projectId = firebaseProject.projectId;
|
|
39
|
-
console.log('projectId', projectId);
|
|
40
|
-
(0, chai_1.expect)(projectId).to.equal(customProjectId);
|
|
41
|
-
});
|
|
42
|
-
it('should return existing custom firebase project and use an api with it', async () => {
|
|
43
|
-
await (0, _1.configureFirebase)(); // init default project.
|
|
44
|
-
// init second project
|
|
45
|
-
const firebaseProject = await (0, _1.configureFirebase)(opts);
|
|
46
|
-
const storage = firebaseProject.storage();
|
|
47
|
-
const files = await storage
|
|
48
|
-
.bucket(`${customProjectId}.appspot.com`)
|
|
49
|
-
.getFiles({ prefix: 'thumb' });
|
|
50
|
-
console.log('files', files);
|
|
51
|
-
(0, chai_1.expect)(files).to.not.be.empty;
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=firebase.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.test.js","sourceRoot":"","sources":["../../src/firebase/firebase.test.ts"],"names":[],"mappings":";;AAAA,iBAAe;AAEf,yBAAqC;AACrC,+BAA4B;AAE5B,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,IAAI,CAAC;AAC1E,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;AACxE,MAAM,eAAe,GAAG,sBAAsB,EAAE,CAAC,UAAU,CAAC;AAC5D,MAAM,IAAI,GAAG;IACT,UAAU,EAAE,sBAAsB,EAAE;IACpC,IAAI,EAAE,eAAe;CACxB,CAAC;AAEF,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,eAAe,GAAG,MAAM,IAAA,oBAAiB,GAAE,CAAC;QAClD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACpC,IAAA,aAAM,EAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,eAAe,GAAG,MAAM,IAAA,oBAAiB,EAAC,IAAI,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACpC,IAAA,aAAM,EAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,C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MAAM,CAAC,GAAG,eAAe,cAAc,CAAC;aACxC,QAAQ,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;QAEjC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAE5B,IAAA,aAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function uploadFileToBucket(filePath: string, fileDest: string, contentType?: string): Promise<string>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadFileToBucket = uploadFileToBucket;
|
|
4
|
-
const firebase_1 = require("../firebase");
|
|
5
|
-
const logs_1 = require("@roadmanjs/logs");
|
|
6
|
-
async function uploadFileToBucket(filePath, fileDest, contentType = 'image/png') {
|
|
7
|
-
const { projectId, storage: adminStorage } = await (0, firebase_1.configureFirebase)();
|
|
8
|
-
const storage = adminStorage();
|
|
9
|
-
const bucketName = `${projectId}.appspot.com`;
|
|
10
|
-
// const DefaultPlaceholder = `https://storage.googleapis.com/${bucketName}/placeholder.png`;
|
|
11
|
-
// Uploads a local file to the bucket
|
|
12
|
-
try {
|
|
13
|
-
const bucket = storage.bucket(bucketName);
|
|
14
|
-
await bucket.upload(filePath, {
|
|
15
|
-
public: true,
|
|
16
|
-
destination: fileDest,
|
|
17
|
-
// By setting the option `destination`, you can change the name of the
|
|
18
|
-
// object you are uploading to a bucket.
|
|
19
|
-
metadata: {
|
|
20
|
-
contentType,
|
|
21
|
-
// Enable long-lived HTTP caching headers
|
|
22
|
-
// Use only if the contents of the file will never change
|
|
23
|
-
cacheControl: 'no-cache',
|
|
24
|
-
// cacheControl: 'public, max-age=31536000',
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
const publicUrl = `https://storage.googleapis.com/${bucketName}/${fileDest}`;
|
|
28
|
-
(0, logs_1.log)(`Public url -> ${publicUrl}`);
|
|
29
|
-
return publicUrl;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
(0, logs_1.log)('error uploading file', JSON.stringify(error));
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=media.methods.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media.methods.js","sourceRoot":"","sources":["../../src/media/media.methods.ts"],"names":[],"mappings":";;AAEA,gDAoCC;AAtCD,0CAA8C;AAC9C,0CAAoC;AAC7B,KAAK,UAAU,kBAAkB,CACpC,QAAgB,EAChB,QAAgB,EAChB,WAAW,GAAG,WAAW;IAEzB,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAC,GAAG,MAAM,IAAA,4BAAiB,GAAE,CAAC;IACrE,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAE/B,MAAM,UAAU,GAAG,GAAG,SAAS,cAAc,CAAC;IAE9C,6FAA6F;IAE7F,qCAAqC;IACrC,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC1B,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,QAAQ;YACrB,sEAAsE;YACtE,wCAAwC;YACxC,QAAQ,EAAE;gBACN,WAAW;gBACX,yCAAyC;gBACzC,yDAAyD;gBACzD,YAAY,EAAE,UAAU;gBACxB,4CAA4C;aAC/C;SACJ,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,kCAAkC,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC7E,IAAA,UAAG,EAAC,iBAAiB,SAAS,EAAE,CAAC,CAAC;QAClC,OAAO,SAAS,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAA,UAAG,EAAC,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FileInput, FileStringInput } from './file.input';
|
|
2
|
-
import { MediaDataType } from './media.model';
|
|
3
|
-
import { ContextType } from '../shared';
|
|
4
|
-
export declare class MediaResolver {
|
|
5
|
-
upload(ctx: ContextType, files: FileInput[]): Promise<MediaDataType[]>;
|
|
6
|
-
uploadString(ctx: ContextType, files: FileStringInput[]): Promise<MediaDataType[]>;
|
|
7
|
-
}
|
|
8
|
-
export default MediaResolver;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.MediaResolver = void 0;
|
|
27
|
-
const client_graphql_1 = require("@stoqey/client-graphql");
|
|
28
|
-
const util_1 = require("util");
|
|
29
|
-
const stream_1 = require("stream");
|
|
30
|
-
const type_graphql_1 = require("type-graphql");
|
|
31
|
-
const file_input_1 = require("./file.input");
|
|
32
|
-
const media_model_1 = require("./media.model");
|
|
33
|
-
const uuid_1 = require("../_utils/uuid");
|
|
34
|
-
const file_utils_1 = require("../_utils/file.utils");
|
|
35
|
-
const media_methods_1 = require("./media.methods");
|
|
36
|
-
const logs_1 = require("@roadmanjs/logs");
|
|
37
|
-
const fs_1 = __importDefault(require("fs"));
|
|
38
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
39
|
-
const middlewares_1 = require("../middlewares");
|
|
40
|
-
// TODO
|
|
41
|
-
const graphql_upload_1 = require("graphql-upload");
|
|
42
|
-
const finishes = (0, util_1.promisify)(stream_1.finished);
|
|
43
|
-
let MediaResolver = class MediaResolver {
|
|
44
|
-
// for web based Files
|
|
45
|
-
async upload(ctx, files) {
|
|
46
|
-
const owner = (0, get_1.default)(ctx, 'payload.userId', '');
|
|
47
|
-
const [error, allFiles] = await (0, client_graphql_1.awaitTo)(Promise.all(files.map(async (file) => {
|
|
48
|
-
const _a = await file, { encoding, filename, mimetype } = _a, others = __rest(_a, ["encoding", "filename", "mimetype"]);
|
|
49
|
-
const newFileNameID = (0, uuid_1.generateUUID)();
|
|
50
|
-
const fileExt = (0, file_utils_1.getFileExtension)(mimetype);
|
|
51
|
-
const fullfilename = `${newFileNameID}.${fileExt}`;
|
|
52
|
-
const createReadStream = others.createReadStream;
|
|
53
|
-
(0, logs_1.log)('preview ---------------------------->', {
|
|
54
|
-
filename,
|
|
55
|
-
mimetype,
|
|
56
|
-
encoding,
|
|
57
|
-
fileExt,
|
|
58
|
-
});
|
|
59
|
-
// Save file to local
|
|
60
|
-
const localFile = `/tmp/${fullfilename}`;
|
|
61
|
-
const stream = createReadStream();
|
|
62
|
-
const out = fs_1.default.createWriteStream(localFile);
|
|
63
|
-
stream.pipe(out);
|
|
64
|
-
await finishes(out);
|
|
65
|
-
// Save file to cloud
|
|
66
|
-
const savedToCloudUrl = await (0, media_methods_1.uploadFileToBucket)(localFile, fullfilename, mimetype);
|
|
67
|
-
if (!savedToCloudUrl) {
|
|
68
|
-
throw new Error('Not saved to cloud, please try again');
|
|
69
|
-
}
|
|
70
|
-
// Save file to db
|
|
71
|
-
const newMediaData = {
|
|
72
|
-
id: newFileNameID,
|
|
73
|
-
name: filename,
|
|
74
|
-
filename,
|
|
75
|
-
mimetype,
|
|
76
|
-
encoding,
|
|
77
|
-
owner,
|
|
78
|
-
url: savedToCloudUrl,
|
|
79
|
-
};
|
|
80
|
-
await media_model_1.MediaDataModel.create(newMediaData);
|
|
81
|
-
// Return file
|
|
82
|
-
return newMediaData;
|
|
83
|
-
})));
|
|
84
|
-
if (allFiles) {
|
|
85
|
-
return allFiles;
|
|
86
|
-
}
|
|
87
|
-
if (error) {
|
|
88
|
-
console.error(error);
|
|
89
|
-
}
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
// For expo strings files in base64
|
|
93
|
-
async uploadString(ctx, files) {
|
|
94
|
-
const owner = (0, get_1.default)(ctx, 'payload.userId', '');
|
|
95
|
-
const [error, allFiles] = await (0, client_graphql_1.awaitTo)(Promise.all(files.map(async (file) => {
|
|
96
|
-
const { filename, mimetype, uri } = file;
|
|
97
|
-
const encoding = 'base64';
|
|
98
|
-
let uriData = uri;
|
|
99
|
-
const newFileNameID = (0, uuid_1.generateUUID)();
|
|
100
|
-
const fileExt = (0, file_utils_1.getFileExtension)(mimetype);
|
|
101
|
-
const fullfilename = `${newFileNameID}.${fileExt}`;
|
|
102
|
-
(0, logs_1.log)('preview ---------------------------->', {
|
|
103
|
-
filename,
|
|
104
|
-
mimetype,
|
|
105
|
-
fileExt,
|
|
106
|
-
});
|
|
107
|
-
// remove the the prefixes
|
|
108
|
-
// TODO for audio files, and other files, focus on images for now
|
|
109
|
-
// TODO move to utility
|
|
110
|
-
if (fileExt === 'png') {
|
|
111
|
-
uriData = uriData.replace(/^data:image\/png;base64,/, '');
|
|
112
|
-
}
|
|
113
|
-
if (fileExt === 'jpeg') {
|
|
114
|
-
uriData = uriData.replace(/^data:image\/jpeg;base64,/, '');
|
|
115
|
-
}
|
|
116
|
-
// Save file to local
|
|
117
|
-
const localFile = `/tmp/${fullfilename}`;
|
|
118
|
-
fs_1.default.writeFileSync(localFile, uriData, { encoding });
|
|
119
|
-
// Save file to cloud
|
|
120
|
-
const savedToCloudUrl = await (0, media_methods_1.uploadFileToBucket)(localFile, fullfilename, mimetype);
|
|
121
|
-
if (!savedToCloudUrl) {
|
|
122
|
-
throw new Error('Not saved to cloud, please try again');
|
|
123
|
-
}
|
|
124
|
-
// Save file to db
|
|
125
|
-
const newMediaData = {
|
|
126
|
-
id: newFileNameID,
|
|
127
|
-
name: filename,
|
|
128
|
-
filename,
|
|
129
|
-
mimetype,
|
|
130
|
-
encoding,
|
|
131
|
-
owner,
|
|
132
|
-
url: savedToCloudUrl,
|
|
133
|
-
};
|
|
134
|
-
await media_model_1.MediaDataModel.create(newMediaData);
|
|
135
|
-
// Return file
|
|
136
|
-
return newMediaData;
|
|
137
|
-
})));
|
|
138
|
-
if (allFiles) {
|
|
139
|
-
return allFiles;
|
|
140
|
-
}
|
|
141
|
-
if (error) {
|
|
142
|
-
console.error(error);
|
|
143
|
-
}
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
exports.MediaResolver = MediaResolver;
|
|
148
|
-
__decorate([
|
|
149
|
-
(0, type_graphql_1.UseMiddleware)(middlewares_1.isAuth),
|
|
150
|
-
(0, type_graphql_1.Mutation)(() => [media_model_1.MediaDataType]),
|
|
151
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
152
|
-
__param(1, (0, type_graphql_1.Arg)('files', () => [graphql_upload_1.GraphQLUpload], { nullable: false }))
|
|
153
|
-
], MediaResolver.prototype, "upload", null);
|
|
154
|
-
__decorate([
|
|
155
|
-
(0, type_graphql_1.UseMiddleware)(middlewares_1.isAuth),
|
|
156
|
-
(0, type_graphql_1.Mutation)(() => [media_model_1.MediaDataType]),
|
|
157
|
-
__param(0, (0, type_graphql_1.Ctx)()),
|
|
158
|
-
__param(1, (0, type_graphql_1.Arg)('files', () => [file_input_1.FileStringInput], { nullable: false }))
|
|
159
|
-
], MediaResolver.prototype, "uploadString", null);
|
|
160
|
-
exports.MediaResolver = MediaResolver = __decorate([
|
|
161
|
-
(0, type_graphql_1.Resolver)(media_model_1.MediaDataType)
|
|
162
|
-
], MediaResolver);
|
|
163
|
-
exports.default = MediaResolver;
|
|
164
|
-
//# sourceMappingURL=media.resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media.resolver.js","sourceRoot":"","sources":["../../src/media/media.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA+C;AAC/C,+BAA+B;AAC/B,mCAAgC;AAChC,+CAAyE;AACzE,6CAAwD;AACxD,+CAA4D;AAC5D,yCAA4C;AAC5C,qDAAsD;AACtD,mDAAmD;AACnD,0CAAoC;AACpC,4CAAoB;AACpB,qDAA8B;AAC9B,gDAAsC;AAGtC,OAAO;AACP,mDAA6C;AAC7C,MAAM,QAAQ,GAAG,IAAA,gBAAS,EAAC,iBAAQ,CAAC,CAAC;AAE9B,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,sBAAsB;IAGhB,A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,IAAA,uBAAQ,EAAC,GAAG,EAAE,CAAC,CAAC,2BAAa,CAAC,CAAC;IAE3B,WAAA,IAAA,kBAAG,GAAE,CAAA;IACL,WAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,8BAAa,CAAC,EAAE,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAA;2CAmE1D;AAKK;IAFL,IAAA,4BAAa,EAAC,oBAAM,CAAC;IACrB,IAAA,uBAAQ,EAAC,GAAG,EAAE,CAAC,CAAC,2BAAa,CAAC,CAAC;IAE3B,WAAA,IAAA,kBAAG,GAAE,CAAA;IACL,WAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,4BAAe,CAAC,EAAE,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAA;iDA8E5D;wBA9JQ,aAAa;IADzB,IAAA,uBAAQ,EAAC,2BAAa,CAAC;GACX,aAAa,CA+JzB;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './isAuth';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./isAuth"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ContextType } from '../shared';
|
|
2
|
-
import { MiddlewareFn } from 'couchset';
|
|
3
|
-
export declare const verifyAuthToken: (token: string) => string | import("jsonwebtoken").JwtPayload;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @sets context.payload = { userId, iat, exp }
|
|
7
|
-
* @param next
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare const isAuth: MiddlewareFn<ContextType>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAuth = exports.verifyAuthToken = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
|
-
const logs_1 = require("@roadmanjs/logs");
|
|
6
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
7
|
-
const verifyAuthToken = (token) => {
|
|
8
|
-
const secret = (0, lodash_1.get)(process.env, 'ACCESS_TOKEN_SECRET', '');
|
|
9
|
-
const verified = (0, jsonwebtoken_1.verify)(token, secret, { ignoreExpiration: false });
|
|
10
|
-
return verified;
|
|
11
|
-
};
|
|
12
|
-
exports.verifyAuthToken = verifyAuthToken;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @sets context.payload = { userId, iat, exp }
|
|
16
|
-
* @param next
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
const isAuth = ({ context }, next) => {
|
|
20
|
-
const authorization = (0, lodash_1.get)(context, 'req.headers.authorization', '');
|
|
21
|
-
if ((0, lodash_1.isEmpty)(authorization)) {
|
|
22
|
-
throw new Error('Not Authenticated');
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
const token = authorization.split(' ')[1];
|
|
26
|
-
const verified = (0, exports.verifyAuthToken)(token);
|
|
27
|
-
context.payload = verified;
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
(0, logs_1.log)('not authenticated');
|
|
31
|
-
throw new Error('not authenticated');
|
|
32
|
-
}
|
|
33
|
-
return next();
|
|
34
|
-
};
|
|
35
|
-
exports.isAuth = isAuth;
|
|
36
|
-
//# sourceMappingURL=isAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isAuth.js","sourceRoot":"","sources":["../../src/middlewares/isAuth.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAI5C,0CAAoC;AACpC,+CAAoC;AAE7B,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,EAAE;IAC7C,MAAM,MAAM,GAAG,IAAA,YAAI,EAAC,OAAO,CAAC,GAAG,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,MAAM,EAAE,EAAC,gBAAgB,EAAE,KAAK,EAAC,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AACF;;;;;GAKG;AACI,MAAM,MAAM,GAA8B,CAAC,EAAC,OAAO,EAAC,EAAE,IAAI,EAAE,EAAE;IACjE,MAAM,aAAa,GAAG,IAAA,YAAI,EAAC,OAAO,EAAE,2BAA2B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,IAAA,gBAAO,EAAC,aAAa,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;QACxC,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAA,UAAG,EAAC,mBAAmB,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,IAAI,EAAE,CAAC;AAClB,CAAC,CAAC;AAjBW,QAAA,MAAM,UAiBjB"}
|
package/dist/shared.d.ts
DELETED
package/dist/shared.js
DELETED
package/dist/shared.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":""}
|