@churchapps/apihelper 0.0.22 → 0.0.24
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/.prettierrc.json +13 -0
- package/CLAUDE.md +110 -0
- package/dist/auth/AuthenticatedUser.js +1 -2
- package/dist/auth/AuthenticatedUser.js.map +1 -1
- package/dist/auth/CustomAuthProvider.d.ts +1 -1
- package/dist/auth/CustomAuthProvider.d.ts.map +1 -1
- package/dist/auth/CustomAuthProvider.js +13 -24
- package/dist/auth/CustomAuthProvider.js.map +1 -1
- package/dist/controllers/CustomBaseController.d.ts +4 -4
- package/dist/controllers/CustomBaseController.d.ts.map +1 -1
- package/dist/controllers/CustomBaseController.js +24 -37
- package/dist/controllers/CustomBaseController.js.map +1 -1
- package/dist/controllers/ErrorController.d.ts +1 -1
- package/dist/controllers/ErrorController.d.ts.map +1 -1
- package/dist/controllers/ErrorController.js +19 -30
- package/dist/controllers/ErrorController.js.map +1 -1
- package/dist/helpers/AwsHelper.d.ts.map +1 -1
- package/dist/helpers/AwsHelper.js +84 -115
- package/dist/helpers/AwsHelper.js.map +1 -1
- package/dist/helpers/DB.js +37 -54
- package/dist/helpers/DB.js.map +1 -1
- package/dist/helpers/DBCreator.js +23 -36
- package/dist/helpers/DBCreator.js.map +1 -1
- package/dist/helpers/EmailHelper.d.ts +1 -1
- package/dist/helpers/EmailHelper.d.ts.map +1 -1
- package/dist/helpers/EmailHelper.js +62 -70
- package/dist/helpers/EmailHelper.js.map +1 -1
- package/dist/helpers/EncryptionHelper.d.ts.map +1 -1
- package/dist/helpers/EnvironmentBase.js +14 -25
- package/dist/helpers/EnvironmentBase.js.map +1 -1
- package/dist/helpers/FileStorageHelper.d.ts.map +1 -1
- package/dist/helpers/FileStorageHelper.js +29 -38
- package/dist/helpers/FileStorageHelper.js.map +1 -1
- package/dist/helpers/LoggingHelper.js +1 -1
- package/dist/helpers/LoggingHelper.js.map +1 -1
- package/dist/helpers/Pool.d.ts.map +1 -1
- package/dist/helpers/Pool.js +2 -1
- package/dist/helpers/Pool.js.map +1 -1
- package/dist/templates/ChurchEmailTemplate.html +383 -0
- package/dist/templates/EmailTemplate.html +426 -0
- package/eslint.config.mjs +40 -0
- package/package.json +38 -36
- package/scripts/copy-assets.js +22 -0
- package/src/auth/CustomAuthProvider.ts +1 -1
- package/src/controllers/CustomBaseController.ts +2 -2
- package/src/controllers/ErrorController.ts +2 -2
- package/src/helpers/AwsHelper.ts +10 -10
- package/src/helpers/DBCreator.ts +2 -2
- package/src/helpers/EmailHelper.ts +38 -34
- package/src/helpers/LoggingHelper.ts +1 -1
- package/src/helpers/Pool.ts +2 -1
- package/tsconfig.json +8 -18
- package/dist/tools/DBCreator.d.ts +0 -1
- package/dist/tools/DBCreator.d.ts.map +0 -1
- package/dist/tools/DBCreator.js +0 -1
- package/dist/tools/DBCreator.js.map +0 -1
- package/src/tools/DBCreator.ts +0 -0
- package/tslint.json +0 -15
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"printWidth": 120,
|
|
3
|
+
"tabWidth": 2,
|
|
4
|
+
"useTabs": false,
|
|
5
|
+
"semi": true,
|
|
6
|
+
"singleQuote": false,
|
|
7
|
+
"quoteProps": "as-needed",
|
|
8
|
+
"trailingComma": "none",
|
|
9
|
+
"bracketSpacing": true,
|
|
10
|
+
"bracketSameLine": false,
|
|
11
|
+
"arrowParens": "avoid",
|
|
12
|
+
"endOfLine": "lf"
|
|
13
|
+
}
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is the `@churchapps/apihelper` package - a Node.js/Express.js server-side utility library that provides common functionality for ChurchApps API projects. It serves as a foundation layer for building REST APIs with authentication, database access, AWS integration, and error handling.
|
|
8
|
+
|
|
9
|
+
## Key Dependencies
|
|
10
|
+
|
|
11
|
+
- **Core**: Express.js with Inversify for dependency injection
|
|
12
|
+
- **AWS SDK v3**: S3, SES, CloudWatch Logs, SSM Parameter Store
|
|
13
|
+
- **Database**: MySQL2 with connection pooling
|
|
14
|
+
- **Authentication**: JSON Web Tokens (JWT)
|
|
15
|
+
- **Depends on**: `@churchapps/helpers` (base utilities package)
|
|
16
|
+
|
|
17
|
+
## Common Development Commands
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Build the package
|
|
21
|
+
npm run clean # Remove dist folder
|
|
22
|
+
npm run tsc # TypeScript compilation only
|
|
23
|
+
npm run build # Full build (clean + tsc + copy-assets)
|
|
24
|
+
|
|
25
|
+
# Code quality
|
|
26
|
+
npm run lint # Run ESLint
|
|
27
|
+
npm run lint:fix # Auto-fix lint issues
|
|
28
|
+
npm run format # Format code with Prettier
|
|
29
|
+
npm run format:check # Check formatting
|
|
30
|
+
|
|
31
|
+
# Local development
|
|
32
|
+
npm run build
|
|
33
|
+
npm link
|
|
34
|
+
|
|
35
|
+
# In consuming project
|
|
36
|
+
npm link @churchapps/apihelper
|
|
37
|
+
|
|
38
|
+
# Publishing
|
|
39
|
+
npm run build
|
|
40
|
+
npm publish --access=public
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Architecture Overview
|
|
44
|
+
|
|
45
|
+
### Core Components
|
|
46
|
+
|
|
47
|
+
1. **Authentication System** (`/auth`)
|
|
48
|
+
- `CustomAuthProvider`: Inversify-based authentication provider
|
|
49
|
+
- `AuthenticatedUser`: User session management with JWT
|
|
50
|
+
- `Principal`: Security principal for authorization checks
|
|
51
|
+
|
|
52
|
+
2. **Base Controllers** (`/controllers`)
|
|
53
|
+
- `CustomBaseController`: Extends Inversify's BaseHttpController
|
|
54
|
+
- Provides error handling (`internalServerError`, `notFound`, `conflict`)
|
|
55
|
+
- Authentication helpers (`loadUser`, `checkAccess`)
|
|
56
|
+
- Request utilities (`getNumber`, `getBoolean`, `getDate`)
|
|
57
|
+
- `ErrorController`: Centralized error logging to database
|
|
58
|
+
|
|
59
|
+
3. **AWS Integration** (`/helpers`)
|
|
60
|
+
- `AwsHelper`: S3 operations, SSM parameter reading, presigned URLs
|
|
61
|
+
- `FileStorageHelper`: Abstraction for file storage operations
|
|
62
|
+
- `EmailHelper`: Dual support for SMTP and AWS SES
|
|
63
|
+
- `LoggingHelper`: Winston logging with CloudWatch integration
|
|
64
|
+
|
|
65
|
+
4. **Database Layer** (`/helpers`)
|
|
66
|
+
- `DB`: Promise-based MySQL query wrapper
|
|
67
|
+
- `Pool`: MySQL connection pooling management
|
|
68
|
+
- `MySqlHelper`: MySQL-specific utilities
|
|
69
|
+
- `DBCreator`: Database schema creation utilities
|
|
70
|
+
|
|
71
|
+
### Key Technical Details
|
|
72
|
+
|
|
73
|
+
- **Inversify Decorators**: Controllers use `@controller`, `@httpGet`, etc.
|
|
74
|
+
- **Environment Configuration**: `EnvironmentBase` class handles env vars with SSM fallback
|
|
75
|
+
- **Email Templates**: HTML templates copied to dist/templates during build
|
|
76
|
+
- **TypeScript**: Targets ES2020 with decorators enabled, declaration files generated
|
|
77
|
+
|
|
78
|
+
### Important Notes
|
|
79
|
+
|
|
80
|
+
- **Build Process Issue**: The copy-assets script references `src/apiBase/tools/templates/*` but the actual path is `src/tools/templates/*`
|
|
81
|
+
- **No Test Suite**: Currently no tests configured in package.json
|
|
82
|
+
- **Environment Variables**: Expects `CONNECTION_STRING`, `ENCRYPTION_KEY`, `JWT_SECRET`, `SMTP_*` configs
|
|
83
|
+
|
|
84
|
+
## Usage Pattern
|
|
85
|
+
|
|
86
|
+
This package is designed to be extended by API projects:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Example controller
|
|
90
|
+
import { controller, httpGet } from "inversify-express-utils";
|
|
91
|
+
import { CustomBaseController } from "@churchapps/apihelper";
|
|
92
|
+
|
|
93
|
+
@controller("/api/example")
|
|
94
|
+
export class ExampleController extends CustomBaseController {
|
|
95
|
+
@httpGet("/")
|
|
96
|
+
public async getAll(req: express.Request, res: express.Response): Promise<any> {
|
|
97
|
+
return this.actionWrapper(req, res, async () => {
|
|
98
|
+
// Implementation
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Development Workflow
|
|
105
|
+
|
|
106
|
+
1. Controllers extend `CustomBaseController` for built-in error handling and utilities
|
|
107
|
+
2. Use `EnvironmentBase` for configuration management
|
|
108
|
+
3. Database queries through `DB.query()` or `DB.queryOne()`
|
|
109
|
+
4. AWS operations via `AwsHelper` static methods
|
|
110
|
+
5. Logging through `LoggingHelper.getInstance()` singleton
|
|
@@ -16,12 +16,11 @@ class AuthenticatedUser {
|
|
|
16
16
|
this.groupIds = principal.details.groupIds;
|
|
17
17
|
}
|
|
18
18
|
checkAccess(permission) {
|
|
19
|
-
var _a;
|
|
20
19
|
const key = (permission.apiName)
|
|
21
20
|
? permission.apiName + "_" + permission.contentType + "__" + permission.action
|
|
22
21
|
: permission.contentType + "__" + permission.action;
|
|
23
22
|
let result = false;
|
|
24
|
-
|
|
23
|
+
this.permissions?.forEach((p) => {
|
|
25
24
|
if (p === key)
|
|
26
25
|
result = true;
|
|
27
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatedUser.js","sourceRoot":"","sources":["../../src/auth/AuthenticatedUser.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAiB;IAa5B,YAAmB,SAAoB;QACrC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW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,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAC3D,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAEM,WAAW,CAAC,UAAuB;QACxC,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;YAC9B,CAAC,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,GAAG,UAAU,CAAC,WAAW,GAAG,IAAI,GAAG,UAAU,CAAC,MAAM;YAC9E,CAAC,CAAC,UAAU,CAAC,WAAW,GAAG,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC;QAEtD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;YACtC,IAAI,CAAC,KAAK,GAAG;gBAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtCD,8CAsCC"}
|
|
@@ -2,6 +2,6 @@ import { interfaces } from "inversify-express-utils";
|
|
|
2
2
|
import express from "express";
|
|
3
3
|
import { Principal } from "./";
|
|
4
4
|
export declare class CustomAuthProvider implements interfaces.AuthProvider {
|
|
5
|
-
getUser(req: express.Request,
|
|
5
|
+
getUser(req: express.Request, _res: express.Response, _next: express.NextFunction): Promise<Principal>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=CustomAuthProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAG/B,qBACa,kBAAmB,YAAW,UAAU,CAAC,YAAY;IAEnD,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CustomAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAG/B,qBACa,kBAAmB,YAAW,UAAU,CAAC,YAAY;IAEnD,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;CAcpH"}
|
|
@@ -5,15 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
10
|
};
|
|
@@ -25,21 +16,19 @@ const _1 = require("./");
|
|
|
25
16
|
const __1 = require("..");
|
|
26
17
|
let CustomAuthProvider = class CustomAuthProvider {
|
|
27
18
|
// public async getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<interfaces.Principal> {
|
|
28
|
-
getUser(req,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
});
|
|
19
|
+
async getUser(req, _res, _next) {
|
|
20
|
+
const authHeader = req.headers.authorization;
|
|
21
|
+
if (authHeader) {
|
|
22
|
+
const token = authHeader.split(" ")[1];
|
|
23
|
+
if (!token)
|
|
24
|
+
return null;
|
|
25
|
+
const decoded = jsonwebtoken_1.default.verify(token, __1.EnvironmentBase.jwtSecret);
|
|
26
|
+
const result = decoded ? new _1.Principal(decoded) : null;
|
|
27
|
+
if (result)
|
|
28
|
+
result.details.jwt = token;
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
43
32
|
}
|
|
44
33
|
};
|
|
45
34
|
exports.CustomAuthProvider = CustomAuthProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAuthProvider.js","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomAuthProvider.js","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AAGvC,gEAA+B;AAC/B,yBAA+B;AAC/B,0BAAqC;AAG9B,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,iIAAiI;IAC1H,KAAK,CAAC,OAAO,CAAC,GAAoB,EAAE,IAAsB,EAAE,KAA2B;QAC5F,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;QAC7C,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YACxB,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,mBAAe,CAAC,SAAS,CAAC,CAAC;YAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,YAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACvD,IAAI,MAAM;gBAAE,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACvC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAhBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;GACA,kBAAkB,CAgB9B"}
|
|
@@ -5,11 +5,11 @@ import { AuthenticatedUser } from "../auth";
|
|
|
5
5
|
export declare class CustomBaseController extends BaseHttpController {
|
|
6
6
|
logger: LoggingHelper;
|
|
7
7
|
constructor();
|
|
8
|
-
error(errors: string[]): import("inversify-express-utils/lib/results").JsonResult;
|
|
9
|
-
denyAccess(errors: string[]): import("inversify-express-utils/lib/results").JsonResult;
|
|
8
|
+
error(errors: string[]): import("inversify-express-utils/lib/cjs/results").JsonResult;
|
|
9
|
+
denyAccess(errors: string[]): import("inversify-express-utils/lib/cjs/results").JsonResult;
|
|
10
10
|
authUser(): AuthenticatedUser;
|
|
11
11
|
include(req: express.Request, item: string): boolean;
|
|
12
|
-
actionWrapper(
|
|
13
|
-
actionWrapperAnon(
|
|
12
|
+
actionWrapper(_req: express.Request, _res: express.Response, fetchFunction: (_au: AuthenticatedUser) => any): Promise<any>;
|
|
13
|
+
actionWrapperAnon(_req: express.Request, _res: express.Response, fetchFunction: () => any): Promise<any>;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=CustomBaseController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomBaseController.d.ts","sourceRoot":"","sources":["../../src/controllers/CustomBaseController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAa,MAAM,SAAS,CAAA;AAEtD,qBAAa,oBAAqB,SAAQ,kBAAkB;IAEjD,MAAM,EAAE,aAAa,CAAC;;IAOtB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE;IAItB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE;IAI3B,QAAQ,IAAI,iBAAiB;IAK7B,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM;IAUpC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"CustomBaseController.d.ts","sourceRoot":"","sources":["../../src/controllers/CustomBaseController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAa,MAAM,SAAS,CAAA;AAEtD,qBAAa,oBAAqB,SAAQ,kBAAkB;IAEjD,MAAM,EAAE,aAAa,CAAC;;IAOtB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE;IAItB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE;IAI3B,QAAQ,IAAI,iBAAiB;IAK7B,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM;IAUpC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAiB1H,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAmBxH"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.CustomBaseController = void 0;
|
|
13
4
|
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
@@ -40,43 +31,39 @@ class CustomBaseController extends inversify_express_utils_1.BaseHttpController
|
|
|
40
31
|
}
|
|
41
32
|
return result;
|
|
42
33
|
}
|
|
43
|
-
actionWrapper(
|
|
44
|
-
|
|
34
|
+
async actionWrapper(_req, _res, fetchFunction) {
|
|
35
|
+
try {
|
|
36
|
+
const result = await fetchFunction(this.authUser());
|
|
37
|
+
await this.logger.flush();
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
45
41
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return result;
|
|
42
|
+
this.logger.error(e);
|
|
43
|
+
await this.logger.flush();
|
|
49
44
|
}
|
|
50
45
|
catch (e) {
|
|
51
|
-
|
|
52
|
-
this.logger.error(e);
|
|
53
|
-
yield this.logger.flush();
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
console.log(e);
|
|
57
|
-
}
|
|
58
|
-
return this.internalServerError(e);
|
|
46
|
+
console.log(e);
|
|
59
47
|
}
|
|
60
|
-
|
|
48
|
+
return this.internalServerError(e);
|
|
49
|
+
}
|
|
61
50
|
}
|
|
62
|
-
actionWrapperAnon(
|
|
63
|
-
|
|
51
|
+
async actionWrapperAnon(_req, _res, fetchFunction) {
|
|
52
|
+
try {
|
|
53
|
+
const result = await fetchFunction();
|
|
54
|
+
await this.logger.flush();
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
64
58
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return result;
|
|
59
|
+
this.logger.error(e);
|
|
60
|
+
await this.logger.flush();
|
|
68
61
|
}
|
|
69
62
|
catch (e) {
|
|
70
|
-
|
|
71
|
-
this.logger.error(e);
|
|
72
|
-
yield this.logger.flush();
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
console.log(e);
|
|
76
|
-
}
|
|
77
|
-
return this.internalServerError(e);
|
|
63
|
+
console.log(e);
|
|
78
64
|
}
|
|
79
|
-
|
|
65
|
+
return this.internalServerError(e);
|
|
66
|
+
}
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
exports.CustomBaseController = CustomBaseController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomBaseController.js","sourceRoot":"","sources":["../../src/controllers/CustomBaseController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomBaseController.js","sourceRoot":"","sources":["../../src/controllers/CustomBaseController.ts"],"names":[],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;YACpD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,CAAK,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,IAAqB,EAAE,IAAsB,EAAE,aAAwB;QAClG,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,CAAK,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;CAIJ;AApED,oDAoEC"}
|
|
@@ -2,6 +2,6 @@ import express from "express";
|
|
|
2
2
|
import { CustomBaseController } from "./CustomBaseController";
|
|
3
3
|
import { ErrorLog } from "../models";
|
|
4
4
|
export declare class ErrorController extends CustomBaseController {
|
|
5
|
-
save(req: express.Request<{}, {}, ErrorLog[]>,
|
|
5
|
+
save(req: express.Request<{}, {}, ErrorLog[]>, _res: express.Response): Promise<any>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=ErrorController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorController.d.ts","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,qBACa,eAAgB,SAAQ,oBAAoB;IAGxC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"ErrorController.d.ts","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,qBACa,eAAgB,SAAQ,oBAAoB;IAGxC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAsBpG"}
|
|
@@ -8,15 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
13
|
};
|
|
@@ -26,28 +17,26 @@ const inversify_express_utils_1 = require("inversify-express-utils");
|
|
|
26
17
|
const express_1 = __importDefault(require("express"));
|
|
27
18
|
const CustomBaseController_1 = require("./CustomBaseController");
|
|
28
19
|
let ErrorController = class ErrorController extends CustomBaseController_1.CustomBaseController {
|
|
29
|
-
save(req,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.logger.log(error.application, error.level, fullMessage);
|
|
44
|
-
});
|
|
45
|
-
yield this.logger.flush();
|
|
46
|
-
return req.body;
|
|
47
|
-
// } catch (e) {
|
|
48
|
-
// console.log(e)
|
|
49
|
-
// };
|
|
20
|
+
async save(req, _res) {
|
|
21
|
+
// try {
|
|
22
|
+
/*
|
|
23
|
+
try {
|
|
24
|
+
au = this.authUser();
|
|
25
|
+
} catch (e) {
|
|
26
|
+
this.logger.log(req.body[0].application, "info", e);
|
|
27
|
+
}*/
|
|
28
|
+
req.body.forEach(error => {
|
|
29
|
+
let fullMessage = error.message;
|
|
30
|
+
if (error.additionalDetails !== undefined)
|
|
31
|
+
fullMessage += "\n" + error.additionalDetails;
|
|
32
|
+
// if (au !== null) fullMessage += "\nUser: " + au.id + " Church: " + au.churchId;
|
|
33
|
+
this.logger.log(error.application, error.level, fullMessage);
|
|
50
34
|
});
|
|
35
|
+
await this.logger.flush();
|
|
36
|
+
return req.body;
|
|
37
|
+
// } catch (e) {
|
|
38
|
+
// console.log(e)
|
|
39
|
+
// };
|
|
51
40
|
}
|
|
52
41
|
};
|
|
53
42
|
exports.ErrorController = ErrorController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorController.js","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorController.js","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qEAA+D;AAC/D,sDAA8B;AAC9B,iEAA6D;AAKtD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2CAAoB;IAGxC,AAAN,KAAK,CAAC,IAAI,CAAC,GAAwC,EAAE,IAAsB;QAC9E,QAAQ;QACR;;;;;WAKG;QACH,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC;YAChC,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS;gBAAE,WAAW,IAAI,IAAI,GAAG,KAAK,CAAC,iBAAiB,CAAC;YACzF,kFAAkF;YAClF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,IAAI,CAAC;QAChB,gBAAgB;QAChB,iBAAiB;QACjB,KAAK;IAET,CAAC;CAEJ,CAAA;AAzBY,0CAAe;AAGX;IADZ,IAAA,kCAAQ,EAAC,GAAG,CAAC;;;;2CAqBb;0BAvBQ,eAAe;IAD3B,IAAA,oCAAU,EAAC,SAAS,CAAC;GACT,eAAe,CAyB3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AwsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/AwsHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"AwsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/AwsHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyH,MAAM,oBAAoB,CAAC;AAKrK,qBAAa,SAAS;WAGP,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAelE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAW;IAEjC,OAAO,CAAC,MAAM,CAAC,SAAS;WAOX,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAczC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAY3E,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WASpC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAI/C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAUrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;WAIvC,eAAe,CAAC,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE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