@nmxjs/app 1.0.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/.github/workflows/npm.yaml +31 -0
- package/README.md +1 -0
- package/dist/createNestApp.d.ts +1 -0
- package/dist/createNestApp.js +24 -0
- package/dist/createNestApp.js.map +1 -0
- package/dist/createNestHttpApp.d.ts +1 -0
- package/dist/createNestHttpApp.js +21 -0
- package/dist/createNestHttpApp.js.map +1 -0
- package/dist/getGraphQlModule.d.ts +1 -0
- package/dist/getGraphQlModule.js +37 -0
- package/dist/getGraphQlModule.js.map +1 -0
- package/dist/getTypeOrmModule.d.ts +1 -0
- package/dist/getTypeOrmModule.js +12 -0
- package/dist/getTypeOrmModule.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Npm Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
containerize:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Clone files
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
|
+
|
|
15
|
+
- name: Use node
|
|
16
|
+
uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: 18.18.0
|
|
19
|
+
cache: 'yarn'
|
|
20
|
+
registry-url: https://registry.npmjs.org
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: yarn install --frozen-lockfile
|
|
24
|
+
|
|
25
|
+
- name: Build
|
|
26
|
+
run: yarn build
|
|
27
|
+
|
|
28
|
+
- name: Publish
|
|
29
|
+
run: npm publish --access public
|
|
30
|
+
env:
|
|
31
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# nm-app
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createNestApp(serviceName: string, module: any): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNestApp = void 0;
|
|
4
|
+
const api_1 = require("@nmxjs/api");
|
|
5
|
+
const core_1 = require("@nestjs/core");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const utils_1 = require("@nmxjs/utils");
|
|
8
|
+
async function createNestApp(serviceName, module) {
|
|
9
|
+
const isWorker = (0, utils_1.isWorkerApp)();
|
|
10
|
+
const app = await core_1.NestFactory[isWorker ? 'createApplicationContext' : 'create'](module);
|
|
11
|
+
if (!isWorker) {
|
|
12
|
+
app.useGlobalInterceptors(new api_1.RpcExceptionInterceptor());
|
|
13
|
+
const getGrpcOptions = app.get(api_1.getGrpcOptionsKey);
|
|
14
|
+
const microserviceApps = [app.connectMicroservice(getGrpcOptions(serviceName), { inheritAppConfig: true })];
|
|
15
|
+
await app.init();
|
|
16
|
+
await Promise.all(microserviceApps.map(microserviceApp => microserviceApp.listen()));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
await app.init();
|
|
20
|
+
}
|
|
21
|
+
common_1.Logger.log(`Microservice "${serviceName}${process.env.BOOT_MODE ? `-${process.env.BOOT_MODE}` : ''}" started!`);
|
|
22
|
+
}
|
|
23
|
+
exports.createNestApp = createNestApp;
|
|
24
|
+
//# sourceMappingURL=createNestApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNestApp.js","sourceRoot":"","sources":["../src/createNestApp.ts"],"names":[],"mappings":";;;AAAA,oCAAwF;AACxF,uCAA2C;AAE3C,2CAA0D;AAC1D,wCAA2C;AAEpC,KAAK,UAAU,aAAa,CAAC,WAAmB,EAAE,MAAW;IAClE,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAC/B,MAAM,GAAG,GAAqB,MAAM,kBAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;IAE1G,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,GAAG,CAAC,qBAAqB,CAAC,IAAI,6BAAuB,EAAE,CAAC,CAAC;QACzD,MAAM,cAAc,GAAmB,GAAG,CAAC,GAAG,CAAC,uBAAiB,CAAC,CAAC;QAElE,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAsB,cAAc,CAAC,WAAW,CAAC,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACjI,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;IAED,eAAM,CAAC,GAAG,CAAC,iBAAiB,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAClH,CAAC;AAhBD,sCAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createNestHttpApp(serviceName: string, module: any): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNestHttpApp = void 0;
|
|
4
|
+
const helmet_1 = require("helmet");
|
|
5
|
+
const compression = require("compression");
|
|
6
|
+
const utils_1 = require("@nmxjs/utils");
|
|
7
|
+
const types_1 = require("@nmxjs/types");
|
|
8
|
+
const core_1 = require("@nestjs/core");
|
|
9
|
+
const common_1 = require("@nestjs/common");
|
|
10
|
+
async function createNestHttpApp(serviceName, module) {
|
|
11
|
+
const app = await core_1.NestFactory.create(module);
|
|
12
|
+
if ((0, utils_1.getEnvironment)() === types_1.EnvironmentEnum.PRODUCTION) {
|
|
13
|
+
app.use((0, helmet_1.default)());
|
|
14
|
+
}
|
|
15
|
+
app.use(compression());
|
|
16
|
+
const port = process.env.PORT || 3000;
|
|
17
|
+
await app.listen(port);
|
|
18
|
+
common_1.Logger.log(`Http service ${serviceName} started on port "${port}"!`);
|
|
19
|
+
}
|
|
20
|
+
exports.createNestHttpApp = createNestHttpApp;
|
|
21
|
+
//# sourceMappingURL=createNestHttpApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNestHttpApp.js","sourceRoot":"","sources":["../src/createNestHttpApp.ts"],"names":[],"mappings":";;;AAAA,mCAA4B;AAC5B,2CAA2C;AAC3C,wCAA8C;AAC9C,wCAA+C;AAC/C,uCAA2C;AAC3C,2CAAwC;AAEjC,KAAK,UAAU,iBAAiB,CAAC,WAAmB,EAAE,MAAW;IACtE,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE7C,IAAI,IAAA,sBAAc,GAAE,KAAK,uBAAe,CAAC,UAAU,EAAE,CAAC;QACpD,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,GAAE,CAAC,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;IACtC,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvB,eAAM,CAAC,GAAG,CAAC,gBAAgB,WAAW,qBAAqB,IAAI,IAAI,CAAC,CAAC;AACvE,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGraphQlModule: () => import("@nestjs/common").DynamicModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGraphQlModule = void 0;
|
|
4
|
+
const apollo_1 = require("@nestjs/apollo");
|
|
5
|
+
const utils_1 = require("@nmxjs/utils");
|
|
6
|
+
const types_1 = require("@nmxjs/types");
|
|
7
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
8
|
+
const getGraphQlModule = () => graphql_1.GraphQLModule.forRootAsync({
|
|
9
|
+
driver: apollo_1.ApolloDriver,
|
|
10
|
+
useFactory: () => ({
|
|
11
|
+
debug: false,
|
|
12
|
+
autoSchemaFile: true,
|
|
13
|
+
installSubscriptionHandlers: true,
|
|
14
|
+
playground: (0, utils_1.getEnvironment)() !== types_1.EnvironmentEnum.PRODUCTION,
|
|
15
|
+
cors: {
|
|
16
|
+
credentials: true,
|
|
17
|
+
origin: [process.env.ORIGIN || '*'],
|
|
18
|
+
},
|
|
19
|
+
formatError: (error) => {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
|
+
return (Object.assign(Object.assign(Object.assign({}, (((_b = (_a = error.extensions.exception) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code)
|
|
22
|
+
? { code: error.extensions.exception.error.code }
|
|
23
|
+
: error.extensions.code
|
|
24
|
+
? { code: error.extensions.code }
|
|
25
|
+
: {})), (((_d = (_c = error.extensions.exception) === null || _c === void 0 ? void 0 : _c.thrownValue) === null || _d === void 0 ? void 0 : _d.code) ? { code: error.extensions.exception.thrownValue.code } : {})), { message: ((_f = (_e = error.extensions.exception) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message) ||
|
|
26
|
+
((_g = error.extensions.exception) === null || _g === void 0 ? void 0 : _g.message) ||
|
|
27
|
+
((_j = (_h = error.extensions.exception) === null || _h === void 0 ? void 0 : _h.thrownValue) === null || _j === void 0 ? void 0 : _j.message) ||
|
|
28
|
+
error.toString() }));
|
|
29
|
+
},
|
|
30
|
+
context: ctx => ({
|
|
31
|
+
req: ctx.req,
|
|
32
|
+
res: ctx.res,
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
exports.getGraphQlModule = getGraphQlModule;
|
|
37
|
+
//# sourceMappingURL=getGraphQlModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGraphQlModule.js","sourceRoot":"","sources":["../src/getGraphQlModule.ts"],"names":[],"mappings":";;;AAAA,2CAAkE;AAClE,wCAA8C;AAC9C,wCAA+C;AAC/C,6CAAgD;AAEzC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,uBAAa,CAAC,YAAY,CAAqB;IAC7C,MAAM,EAAE,qBAAY;IACpB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,IAAI;QACpB,2BAA2B,EAAE,IAAI;QACjC,UAAU,EAAE,IAAA,sBAAc,GAAE,KAAK,uBAAe,CAAC,UAAU;QAC3D,IAAI,EAAE;YACJ,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;SACpC;QACD,WAAW,EAAE,CAAC,KAAU,EAAE,EAAE;;YAAC,OAAA,+CACxB,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,KAAK,0CAAE,IAAI;gBACzC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE;gBACjD,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI;oBACvB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE;oBACjC,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,WAAW,0CAAE,IAAI,EAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC/G,OAAO,EACL,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,KAAK,0CAAE,OAAO;qBAC1C,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,OAAO,CAAA;qBACnC,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,WAAW,0CAAE,OAAO,CAAA;oBAChD,KAAK,CAAC,QAAQ,EAAE,IAClB,CAAA;SAAA;QACF,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,GAAG,EAAE,GAAG,CAAC,GAAG;SACb,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AA9BQ,QAAA,gBAAgB,oBA8BxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTypeOrmModule: () => import("@nestjs/common").DynamicModule;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypeOrmModule = void 0;
|
|
4
|
+
const utils_1 = require("@nmxjs/utils");
|
|
5
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
6
|
+
const config_1 = require("@nmxjs/config");
|
|
7
|
+
const getTypeOrmModule = () => typeorm_1.TypeOrmModule.forRootAsync({
|
|
8
|
+
useFactory: (0, utils_1.withCreateDbIfNotExists)(async (config) => (Object.assign({ type: config.db.type, host: config.db.host, port: config.db.port, username: config.db.username, password: config.db.password, database: config.db.database, synchronize: true, autoLoadEntities: true }, (config.db.options ? config.db.options : {})))),
|
|
9
|
+
inject: [config_1.configKey],
|
|
10
|
+
});
|
|
11
|
+
exports.getTypeOrmModule = getTypeOrmModule;
|
|
12
|
+
//# sourceMappingURL=getTypeOrmModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTypeOrmModule.js","sourceRoot":"","sources":["../src/getTypeOrmModule.ts"],"names":[],"mappings":";;;AAAA,wCAAuD;AACvD,6CAAgD;AAChD,0CAAmD;AAE5C,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,uBAAa,CAAC,YAAY,CAAC;IACzB,UAAU,EAAE,IAAA,+BAAuB,EAAC,KAAK,EAAE,MAAe,EAAE,EAAE,CAAC,iBAC7D,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,WAAW,EAAE,IAAI,EACjB,gBAAgB,EAAE,IAAI,IACnB,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAC/C,CAAC;IACH,MAAM,EAAE,CAAC,kBAAS,CAAC;CACpB,CAAC,CAAC;AAdQ,QAAA,gBAAgB,oBAcxB"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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("./createNestApp"), exports);
|
|
18
|
+
__exportStar(require("./getTypeOrmModule"), exports);
|
|
19
|
+
__exportStar(require("./getGraphQlModule"), exports);
|
|
20
|
+
__exportStar(require("./createNestHttpApp"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,qDAAmC;AACnC,qDAAmC;AACnC,sDAAoC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nmxjs/app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "echo [@nmxjs/app has no start script]",
|
|
9
|
+
"clear": "rm -rf dist",
|
|
10
|
+
"build": "yarn clear; tsc",
|
|
11
|
+
"test": "jest --config=jest.config.js --runInBand --passWithNoTests"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/n1ghtm6r9/nm-app.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "N1ghtm6r9",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/n1ghtm6r9/nm-app/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/n1ghtm6r9/nm-app#readme",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.10.4",
|
|
26
|
+
"typescript": "^5.1.6"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@nestjs/apollo": "^12.0.11",
|
|
30
|
+
"@nmxjs/api": "^1.0.0",
|
|
31
|
+
"@nmxjs/config": "^1.0.0",
|
|
32
|
+
"compression": "^1.7.4",
|
|
33
|
+
"helmet": "^7.1.0"
|
|
34
|
+
}
|
|
35
|
+
}
|