roadman 0.1.17 → 0.2.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.
- package/dist/afters/index.js +5 -1
- package/dist/afters/index.js.map +1 -1
- package/dist/befores/express.d.ts +7 -1
- package/dist/befores/express.js +25 -24
- package/dist/befores/express.js.map +1 -1
- package/dist/befores/index.js +5 -1
- package/dist/befores/index.js.map +1 -1
- package/dist/config/const.d.ts +5 -0
- package/dist/config/const.js +9 -1
- package/dist/config/const.js.map +1 -1
- package/dist/config/index.js +5 -1
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/roadman.builder.d.ts +4 -3
- package/dist/roadman.builder.js +5 -6
- package/dist/roadman.builder.js.map +1 -1
- package/dist/shared.d.ts +3 -3
- package/dist/wastemans/index.js +5 -1
- package/dist/wastemans/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/pengs/index.d.ts +0 -1
- package/dist/pengs/index.js +0 -14
- package/dist/pengs/index.js.map +0 -1
- package/dist/pengs/isAuth.d.ts +0 -3
- package/dist/pengs/isAuth.js +0 -24
- package/dist/pengs/isAuth.js.map +0 -1
package/dist/afters/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/afters/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/afters/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/afters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { RoadmanBuild } from '../shared';
|
|
2
|
+
export interface ExpressRoadmanArgs {
|
|
3
|
+
limit?: string;
|
|
4
|
+
maxFileSize?: number;
|
|
5
|
+
maxFiles?: number;
|
|
6
|
+
defaultIndex?: boolean;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* First Builder Roadman, #1 my g
|
|
4
10
|
* @param BeforeRoadmanBuild
|
|
5
11
|
* @returns BeforeRoadmanBuild
|
|
6
12
|
*/
|
|
7
|
-
export declare const expressRoadman: ({ app }: RoadmanBuild) => Promise<RoadmanBuild>;
|
|
13
|
+
export declare const expressRoadman: ({ app }: RoadmanBuild, args?: ExpressRoadmanArgs) => Promise<RoadmanBuild>;
|
|
8
14
|
export default expressRoadman;
|
package/dist/befores/express.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -23,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
27
|
};
|
|
24
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
29
|
exports.expressRoadman = void 0;
|
|
30
|
+
const config_1 = require("../config");
|
|
26
31
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
27
32
|
const express_1 = __importStar(require("express"));
|
|
28
33
|
const graphql_redis_subscriptions_1 = require("graphql-redis-subscriptions");
|
|
29
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
30
34
|
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
31
35
|
const cors_1 = __importDefault(require("cors"));
|
|
32
36
|
const graphql_upload_1 = require("graphql-upload");
|
|
@@ -36,33 +40,29 @@ const lodash_1 = require("lodash");
|
|
|
36
40
|
* @param BeforeRoadmanBuild
|
|
37
41
|
* @returns BeforeRoadmanBuild
|
|
38
42
|
*/
|
|
39
|
-
const expressRoadman = async ({ app }) => {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const isRedisHost = !(0, lodash_1.isEmpty)(redisHost);
|
|
43
|
+
const expressRoadman = async ({ app }, args) => {
|
|
44
|
+
const { limit = '5mb', maxFileSize = 10000000, maxFiles = 10, defaultIndex = true } = args;
|
|
45
|
+
const isRedisUrl = !(0, lodash_1.isEmpty)(config_1.REDIS_URL);
|
|
46
|
+
const isRedisHost = !(0, lodash_1.isEmpty)(config_1.REDIS_HOST);
|
|
44
47
|
let pubsub = null;
|
|
45
|
-
if (isRedisHost) {
|
|
46
|
-
const redisTls = !(0, lodash_1.isEmpty)((0, get_1.default)(process.env, 'REDIS_TLS', ''));
|
|
47
|
-
const redisPort = (0, get_1.default)(process.env, 'REDIS_PORT', 6379);
|
|
48
|
-
const redisPass = (0, get_1.default)(process.env, 'REDIS_PASS', undefined);
|
|
48
|
+
if (isRedisHost || isRedisUrl) {
|
|
49
49
|
// Create ioredis
|
|
50
50
|
const options = isRedisUrl
|
|
51
|
-
?
|
|
51
|
+
? config_1.REDIS_URL
|
|
52
52
|
: {
|
|
53
|
-
host:
|
|
54
|
-
port: +
|
|
53
|
+
host: config_1.REDIS_HOST,
|
|
54
|
+
port: +config_1.REDIS_PORT,
|
|
55
55
|
retryStrategy: (times) => {
|
|
56
56
|
// reconnect after
|
|
57
57
|
return Math.min(times * 50, 2000);
|
|
58
58
|
},
|
|
59
|
-
tls:
|
|
59
|
+
tls: config_1.REDIS_TLS
|
|
60
60
|
? {
|
|
61
|
-
host:
|
|
62
|
-
port: +
|
|
61
|
+
host: config_1.REDIS_HOST,
|
|
62
|
+
port: +config_1.REDIS_PORT,
|
|
63
63
|
}
|
|
64
64
|
: undefined,
|
|
65
|
-
password:
|
|
65
|
+
password: config_1.REDIS_PASS,
|
|
66
66
|
connectTimeout: 10000,
|
|
67
67
|
};
|
|
68
68
|
pubsub = new graphql_redis_subscriptions_1.RedisPubSub({
|
|
@@ -70,22 +70,23 @@ const expressRoadman = async ({ app }) => {
|
|
|
70
70
|
subscriber: new ioredis_1.default(options),
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
app.use((0, express_1.json)({ limit
|
|
74
|
-
app.use((0, graphql_upload_1.graphqlUploadExpress)({ maxFileSize
|
|
73
|
+
app.use((0, express_1.json)({ limit }));
|
|
74
|
+
app.use((0, graphql_upload_1.graphqlUploadExpress)({ maxFileSize, maxFiles }));
|
|
75
75
|
app.use((0, cors_1.default)({
|
|
76
76
|
origin: '*',
|
|
77
77
|
credentials: true,
|
|
78
78
|
}));
|
|
79
79
|
app.use((0, cookie_parser_1.default)());
|
|
80
|
-
app.use(express_1.default.json());
|
|
81
80
|
app.use(express_1.default.urlencoded({ extended: true }));
|
|
82
81
|
app.use((req, res, next) => {
|
|
83
82
|
req.pubsub = pubsub;
|
|
84
83
|
next();
|
|
85
84
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (defaultIndex) {
|
|
86
|
+
app.get('/', (_, res) => {
|
|
87
|
+
res.send('hello');
|
|
88
|
+
});
|
|
89
|
+
}
|
|
89
90
|
return { app, pubsub };
|
|
90
91
|
};
|
|
91
92
|
exports.expressRoadman = expressRoadman;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/befores/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/befores/express.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmF;AACnF,sDAA4C;AAC5C,mDAAsC;AAEtC,6EAAkE;AAElE,kEAAyC;AACzC,gDAAwB;AACxB,mDAAoD;AACpD,mCAA+B;AAS/B;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAC/B,EAAC,GAAG,EAAe,EACnB,IAAyB,EACJ,EAAE;IACvB,MAAM,EAAC,KAAK,GAAG,KAAK,EAAE,WAAW,GAAG,QAAQ,EAAE,QAAQ,GAAG,EAAE,EAAE,YAAY,GAAG,IAAI,EAAC,GAAG,IAAI,CAAC;IAEzF,MAAM,UAAU,GAAG,CAAC,IAAA,gBAAO,EAAC,kBAAS,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,CAAC,IAAA,gBAAO,EAAC,mBAAU,CAAC,CAAC;IAEzC,IAAI,MAAM,GAAW,IAAI,CAAC;IAC1B,IAAI,WAAW,IAAI,UAAU,EAAE;QAC3B,iBAAiB;QACjB,MAAM,OAAO,GAA0B,UAAU;YAC7C,CAAC,CAAC,kBAAS;YACX,CAAC,CAAC;gBACI,IAAI,EAAE,mBAAU;gBAChB,IAAI,EAAE,CAAC,mBAAU;gBACjB,aAAa,EAAE,CAAC,KAAa,EAAE,EAAE;oBAC7B,kBAAkB;oBAClB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;gBACtC,CAAC;gBACD,GAAG,EAAE,kBAAS;oBACV,CAAC,CAAC;wBACI,IAAI,EAAE,mBAAU;wBAChB,IAAI,EAAE,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 -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/befores/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/befores/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
|
package/dist/config/const.d.ts
CHANGED
|
@@ -3,5 +3,10 @@ export declare const serviceAccount: string;
|
|
|
3
3
|
export declare const nodeEnv: string;
|
|
4
4
|
export declare const isDev: boolean;
|
|
5
5
|
export declare const PORT: number;
|
|
6
|
+
export declare const REDIS_URL: string;
|
|
7
|
+
export declare const REDIS_HOST: string;
|
|
8
|
+
export declare const REDIS_TLS: boolean;
|
|
9
|
+
export declare const REDIS_PORT: string | number;
|
|
10
|
+
export declare const REDIS_PASS: any;
|
|
6
11
|
export declare const demoToken = "mytokengenerastor";
|
|
7
12
|
export declare const graphqlPath = "/graphql";
|
package/dist/config/const.js
CHANGED
|
@@ -3,14 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.graphqlPath = exports.demoToken = exports.PORT = exports.isDev = exports.nodeEnv = exports.serviceAccount = void 0;
|
|
6
|
+
exports.graphqlPath = exports.demoToken = exports.REDIS_PASS = exports.REDIS_PORT = exports.REDIS_TLS = exports.REDIS_HOST = exports.REDIS_URL = exports.PORT = exports.isDev = exports.nodeEnv = exports.serviceAccount = void 0;
|
|
7
7
|
require("dotenv/config");
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
9
10
|
// Service account
|
|
10
11
|
exports.serviceAccount = (0, get_1.default)(process.env, 'SA_KEY', '{}');
|
|
11
12
|
exports.nodeEnv = (0, get_1.default)(process.env, 'NODE_ENV');
|
|
12
13
|
exports.isDev = exports.nodeEnv !== 'production';
|
|
13
14
|
exports.PORT = +(0, get_1.default)(process.env, 'PORT', 3099);
|
|
15
|
+
// this
|
|
16
|
+
exports.REDIS_URL = (0, get_1.default)(process.env, 'REDIS_URL', '');
|
|
17
|
+
// or this
|
|
18
|
+
exports.REDIS_HOST = (0, get_1.default)(process.env, 'REDIS_HOST', '');
|
|
19
|
+
exports.REDIS_TLS = !(0, isEmpty_1.default)((0, get_1.default)(process.env, 'REDIS_TLS', ''));
|
|
20
|
+
exports.REDIS_PORT = (0, get_1.default)(process.env, 'REDIS_PORT', 6379);
|
|
21
|
+
exports.REDIS_PASS = (0, get_1.default)(process.env, 'REDIS_PASS', undefined);
|
|
14
22
|
exports.demoToken = 'mytokengenerastor';
|
|
15
23
|
exports.graphqlPath = '/graphql';
|
|
16
24
|
//# sourceMappingURL=const.js.map
|
package/dist/config/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/config/const.ts"],"names":[],"mappings":";;;;;;AAAA,yBAAuB;
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/config/const.ts"],"names":[],"mappings":";;;;;;AAAA,yBAAuB;AAEvB,qDAA8B;AAC9B,6DAAqC;AAErC,kBAAkB;AACL,QAAA,cAAc,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnD,QAAA,OAAO,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AACxC,QAAA,KAAK,GAAG,eAAO,KAAK,YAAY,CAAC;AACjC,QAAA,IAAI,GAAW,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAE7D,OAAO;AACM,QAAA,SAAS,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;AAE5D,UAAU;AACG,QAAA,UAAU,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;AACjD,QAAA,SAAS,GAAG,CAAC,IAAA,iBAAO,EAAC,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,QAAA,UAAU,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AACnD,QAAA,UAAU,GAAG,IAAA,aAAI,EAAC,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAExD,QAAA,SAAS,GAAG,mBAAmB,CAAC;AAChC,QAAA,WAAW,GAAG,UAAU,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,wCAAsB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { ExpressRoadmanArgs } from './befores';
|
|
2
3
|
import { IRoadMan } from './shared';
|
|
3
4
|
interface IRoadmanDefault {
|
|
4
5
|
resolvers?: Function[];
|
|
@@ -6,11 +7,10 @@ interface IRoadmanDefault {
|
|
|
6
7
|
apps?: any[];
|
|
7
8
|
wastemen?: Promise<any>[];
|
|
8
9
|
}
|
|
9
|
-
export declare const roadman: (args?: IRoadmanDefault) => Promise<boolean>;
|
|
10
|
+
export declare const roadman: (args?: IRoadmanDefault, expressArgs?: Partial<ExpressRoadmanArgs>) => Promise<boolean>;
|
|
10
11
|
export * from './roadman.builder';
|
|
11
12
|
export * from './shared';
|
|
12
13
|
export * from './config';
|
|
13
14
|
export * from './befores';
|
|
14
15
|
export * from './afters';
|
|
15
|
-
export * from './pengs';
|
|
16
16
|
export * from './wastemans';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -15,12 +19,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
20
|
exports.roadman = void 0;
|
|
17
21
|
require("reflect-metadata");
|
|
18
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
19
22
|
const roadman_builder_1 = require("./roadman.builder");
|
|
20
|
-
const
|
|
23
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
24
|
+
const roadman = async (args, expressArgs) => {
|
|
21
25
|
const { resolvers, roadmen, apps, wastemen } = args;
|
|
22
26
|
const roadman = new roadman_builder_1.RoadmanBuilder();
|
|
23
|
-
await roadman.firstRoadman();
|
|
27
|
+
await roadman.firstRoadman(expressArgs);
|
|
24
28
|
if (apps) {
|
|
25
29
|
roadman.useApp(apps);
|
|
26
30
|
}
|
|
@@ -47,6 +51,5 @@ __exportStar(require("./shared"), exports);
|
|
|
47
51
|
__exportStar(require("./config"), exports);
|
|
48
52
|
__exportStar(require("./befores"), exports);
|
|
49
53
|
__exportStar(require("./afters"), exports);
|
|
50
|
-
__exportStar(require("./pengs"), exports);
|
|
51
54
|
__exportStar(require("./wastemans"), exports);
|
|
52
55
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAI1B,uDAAiD;AACjD,6DAAqC;AAS9B,MAAM,OAAO,GAAG,KAAK,EACxB,IAAsB,EACtB,WAAyC,EACzB,EAAE;IAClB,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;IAElD,MAAM,OAAO,GAAG,IAAI,gCAAc,EAAE,CAAC;IAErC,MAAM,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAExC,IAAI,IAAI,EAAE;QACN,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACxB;IAED,IAAI,OAAO,EAAE;QACT,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;KAC/B;IAED,IAAI,SAAS,EAAE;QACX,sBAAsB;QACtB,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC/B,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;YACnC,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;KACN;IAED,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,uBAAuB;IACvD,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,iCAAiC;IAE9D,IAAI,CAAC,IAAA,iBAAO,EAAC,QAAQ,CAAC,EAAE;QACpB,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;KAClC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAlCW,QAAA,OAAO,WAkClB;AAEF,oDAAkC;AAClC,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { ExpressRoadmanArgs } from './befores';
|
|
3
|
+
import { IRoadMan, RoadmanBuild } from './shared';
|
|
3
4
|
import { Application } from 'express';
|
|
5
|
+
import { ApolloServer } from 'apollo-server-express';
|
|
4
6
|
import { RedisPubSub } from 'graphql-redis-subscriptions';
|
|
5
7
|
import { Server } from 'http';
|
|
6
|
-
import { RoadmanBuild, IRoadMan } from './shared';
|
|
7
8
|
/**
|
|
8
9
|
* The Roadman Builder
|
|
9
10
|
* const roadman = new RoadmanBuilder(app);
|
|
@@ -19,7 +20,7 @@ export declare class RoadmanBuilder implements RoadmanBuild {
|
|
|
19
20
|
httpServer: Server;
|
|
20
21
|
resolvers: any[];
|
|
21
22
|
constructor(app?: Application, roadmen?: IRoadMan[]);
|
|
22
|
-
firstRoadman(
|
|
23
|
+
firstRoadman(expressArgs?: ExpressRoadmanArgs): Promise<RoadmanBuilder>;
|
|
23
24
|
useApp(use: any | any[]): RoadmanBuilder;
|
|
24
25
|
useRoadman(roadman: IRoadMan | IRoadMan[]): Promise<RoadmanBuilder>;
|
|
25
26
|
graphqlRoadman(roadman?: IRoadMan): Promise<RoadmanBuilder>;
|
package/dist/roadman.builder.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RoadmanBuilder = void 0;
|
|
7
|
-
const
|
|
7
|
+
const befores_1 = require("./befores");
|
|
8
8
|
const express_1 = __importDefault(require("express"));
|
|
9
|
+
const awaitTo_1 = __importDefault(require("./utils/awaitTo"));
|
|
9
10
|
const lodash_1 = require("lodash");
|
|
10
11
|
const afters_1 = require("./afters");
|
|
11
|
-
const
|
|
12
|
-
const awaitTo_1 = __importDefault(require("./utils/awaitTo"));
|
|
12
|
+
const console_1 = require("console");
|
|
13
13
|
/**
|
|
14
14
|
* The Roadman Builder
|
|
15
15
|
* const roadman = new RoadmanBuilder(app);
|
|
@@ -29,9 +29,8 @@ class RoadmanBuilder {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async firstRoadman(
|
|
33
|
-
const
|
|
34
|
-
const { app, pubsub } = await mandem(this);
|
|
32
|
+
async firstRoadman(expressArgs) {
|
|
33
|
+
const { app, pubsub } = await (0, befores_1.expressRoadman)(this, expressArgs);
|
|
35
34
|
this.app = app;
|
|
36
35
|
this.pubsub = pubsub;
|
|
37
36
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roadman.builder.js","sourceRoot":"","sources":["../src/roadman.builder.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"roadman.builder.js","sourceRoot":"","sources":["../src/roadman.builder.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA6E;AAE7E,sDAA6C;AAK7C,8DAAsC;AACtC,mCAA+B;AAC/B,qCAAuC;AACvC,qCAA4B;AAE5B;;;;;;;GAOG;AACH,MAAa,cAAc;IAOvB,YAAY,GAAiB,EAAE,OAAoB;QAFnD,cAAS,GAAG,EAAE,CAAC;QAGX,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,iBAAO,GAAE,CAAC;QACjC,gCAAgC;QAEhC,IAAI,CAAC,IAAA,gBAAO,EAAC,OAAO,CAAC,EAAE;YACnB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;gBAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;aACjB;SACJ;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,WAAgC;QAC/C,MAAM,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE9D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,GAAgB;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE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AS,CAAC,CAAC,CAAC;QACrE,IAAI,KAAK,EAAE;YACP,IAAA,aAAG,EAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YACtC,OAAO;SACV;QACD,IAAA,aAAG,EAAC,OAAO,QAAQ,CAAC,MAAM,YAAY,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;CACJ;AAjFD,wCAiFC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ApolloServer } from 'apollo-server-express';
|
|
3
|
-
import http from 'http';
|
|
4
2
|
import { Application, Request, Response } from 'express';
|
|
3
|
+
import { ApolloServer } from 'apollo-server-express';
|
|
5
4
|
import { RedisPubSub } from 'graphql-redis-subscriptions';
|
|
5
|
+
import http from 'http';
|
|
6
6
|
export interface ContextType {
|
|
7
7
|
req: Request;
|
|
8
8
|
res: Response;
|
|
9
9
|
payload?: any;
|
|
10
|
-
pubsub
|
|
10
|
+
pubsub?: RedisPubSub;
|
|
11
11
|
}
|
|
12
12
|
export interface RoadmanBuild {
|
|
13
13
|
app: Application;
|
package/dist/wastemans/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wastemans/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wastemans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roadman",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "An efficient, and flexible NodeJS library for building backend services.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"eslint": "7.32.0",
|
|
77
77
|
"eslint-config-prettier": "^6.11.0",
|
|
78
78
|
"eslint-loader": "^4.0.2",
|
|
79
|
-
"eslint-plugin-import": "^2.
|
|
79
|
+
"eslint-plugin-import": "^2.26.0",
|
|
80
80
|
"eslint-plugin-json": "^2.1.1",
|
|
81
81
|
"eslint-plugin-prettier": "^3.1.4",
|
|
82
82
|
"eslint-plugin-simple-import-sort": "^5.0.2",
|
package/dist/pengs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './isAuth';
|
package/dist/pengs/index.js
DELETED
|
@@ -1,14 +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
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./isAuth"), exports);
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/dist/pengs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pengs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB"}
|
package/dist/pengs/isAuth.d.ts
DELETED
package/dist/pengs/isAuth.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAuth = void 0;
|
|
4
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
5
|
-
const lodash_1 = require("lodash");
|
|
6
|
-
const isAuth = (args, next) => {
|
|
7
|
-
const context = (args && args.context) || {};
|
|
8
|
-
const authorization = (0, lodash_1.get)(context, 'req.headers.authorization', '');
|
|
9
|
-
if ((0, lodash_1.isEmpty)(authorization)) {
|
|
10
|
-
throw new Error('Not Authenticated');
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const token = authorization.split(' ')[1];
|
|
14
|
-
const verified = (0, jsonwebtoken_1.verify)(token, process.env.ACCESS_TOKEN_SECRET);
|
|
15
|
-
context.payload = verified;
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
console.log('not authenticated');
|
|
19
|
-
throw new Error('not authenticated');
|
|
20
|
-
}
|
|
21
|
-
return next();
|
|
22
|
-
};
|
|
23
|
-
exports.isAuth = isAuth;
|
|
24
|
-
//# sourceMappingURL=isAuth.js.map
|
package/dist/pengs/isAuth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isAuth.js","sourceRoot":"","sources":["../../src/pengs/isAuth.ts"],"names":[],"mappings":";;;AAEA,+CAAoC;AACpC,mCAA4C;AAErC,MAAM,MAAM,GAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;IAC5D,MAAM,OAAO,GAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAClD,MAAM,aAAa,GAAG,IAAA,YAAI,EAAC,OAAO,EAAE,2BAA2B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,IAAA,gBAAO,EAAC,aAAa,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC;IAED,IAAI;QACA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAoB,CAAC,CAAC;QACjE,OAAO,CAAC,OAAO,GAAG,QAAe,CAAC;KACrC;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC;IAED,OAAO,IAAI,EAAE,CAAC;AAClB,CAAC,CAAC;AAlBW,QAAA,MAAM,UAkBjB"}
|