pg-mvc-service 2.1.4 → 2.1.5

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/Service.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from "axios";
2
2
  import { Request, Response } from 'express';
3
- import { Context } from 'hono';
3
+ import { Context, TypedResponse } from 'hono';
4
4
  import { Pool, type PoolClient } from 'pg';
5
5
  import { RequestType } from './reqestResponse/RequestType';
6
6
  import { ResponseType } from './reqestResponse/ResponseType';
@@ -15,7 +15,6 @@ export interface IError {
15
15
  description: string;
16
16
  }
17
17
  export declare class Service {
18
- protected readonly module: 'express' | 'hono';
19
18
  protected readonly method: MethodType;
20
19
  get Method(): MethodType;
21
20
  protected readonly endpoint: string;
@@ -35,10 +34,13 @@ export declare class Service {
35
34
  get Tags(): Array<string>;
36
35
  protected readonly errorList: Array<IError>;
37
36
  get ErrorList(): Array<IError>;
38
- protected readonly req?: Request;
39
- protected readonly res?: Response;
40
- protected readonly c?: Context;
41
- protected setResponse(status: TStatusCode, data: any): void;
37
+ private readonly req?;
38
+ protected get Req(): Request;
39
+ private readonly res?;
40
+ protected get Res(): Response;
41
+ private readonly c?;
42
+ protected get C(): Context;
43
+ get Module(): 'express' | 'hono';
42
44
  constructor(request: Request, response: Response);
43
45
  constructor(c: Context);
44
46
  inintialize(): Promise<void>;
@@ -51,9 +53,11 @@ export declare class Service {
51
53
  private setPool;
52
54
  protected checkMaintenance(): Promise<void>;
53
55
  protected middleware(): Promise<void>;
54
- resSuccess(): Context | undefined;
56
+ resSuccessExpress(): void;
57
+ resSuccessHono(): TypedResponse<any>;
55
58
  protected outputErrorLog(ex: any): Promise<void>;
56
- handleException(ex: any): Context | undefined;
59
+ handleExceptionExpress(ex: any): void;
60
+ handleExceptionHono(ex: any): TypedResponse<any>;
57
61
  private pool?;
58
62
  protected get Pool(): Pool;
59
63
  private client?;
@@ -1 +1 @@
1
- {"version":3,"file":"Service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C,aAAa,CAAC,CAAgB;IACtC,IAAI,aAAa,IAAI,aAAa,CASjC;IAEY,UAAU,CAAC,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,GAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAChF,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;CA0C1H"}
package/dist/Service.js CHANGED
@@ -40,17 +40,35 @@ class Service {
40
40
  description: 'サーバー内部エラー(予期せぬエラー)'
41
41
  }];
42
42
  }
43
- setResponse(status, data) {
44
- var _a, _b;
45
- if (this.module === 'express') {
46
- (_a = this.res) === null || _a === void 0 ? void 0 : _a.status(status).json(data);
43
+ get Req() {
44
+ if (this.req === undefined) {
45
+ throw new Error('This method can only be used when module is "express".');
47
46
  }
48
- else {
49
- (_b = this.c) === null || _b === void 0 ? void 0 : _b.json(data, status);
47
+ return this.req;
48
+ }
49
+ get Res() {
50
+ if (this.res === undefined) {
51
+ throw new Error('This method can only be used when module is "express".');
52
+ }
53
+ return this.res;
54
+ }
55
+ get C() {
56
+ if (this.c === undefined) {
57
+ throw new Error('This method can only be used when module is "hono".');
50
58
  }
59
+ return this.c;
51
60
  }
61
+ get Module() {
62
+ if (this.c !== undefined) {
63
+ return 'hono';
64
+ }
65
+ else if (this.req !== undefined && this.res !== undefined) {
66
+ return 'express';
67
+ }
68
+ throw new Error('Failed to determine whether the module is "express" or "hono".');
69
+ }
70
+ ;
52
71
  constructor(param1, param2) {
53
- this.module = 'express';
54
72
  this.method = 'GET';
55
73
  this.endpoint = '';
56
74
  this.apiCode = '';
@@ -69,23 +87,21 @@ class Service {
69
87
  this.isExecuteRollback = false;
70
88
  if (param2 !== undefined) {
71
89
  // Express の場合: (request, response)
72
- this.module = 'express';
73
90
  this.req = param1;
74
91
  this.res = param2;
75
92
  }
76
93
  else {
77
94
  // Hono の場合: (c)
78
- this.module = 'hono';
79
95
  this.c = param1;
80
96
  }
81
97
  }
82
98
  inintialize() {
83
99
  return __awaiter(this, void 0, void 0, function* () {
84
- if (this.module === "express") {
85
- yield this.request.setRequest(this.module, this.req);
100
+ if (this.Module === "express") {
101
+ yield this.request.setRequest(this.Module, this.Req);
86
102
  }
87
103
  else {
88
- yield this.request.setRequest(this.module, this.c);
104
+ yield this.request.setRequest(this.Module, this.C);
89
105
  }
90
106
  yield this.checkMaintenance();
91
107
  yield this.middleware();
@@ -120,69 +136,115 @@ class Service {
120
136
  middleware() {
121
137
  return __awaiter(this, void 0, void 0, function* () { });
122
138
  }
123
- resSuccess() {
124
- this.setResponse(200, this.response.ResponseData);
125
- if (this.module === 'hono') {
126
- return this.c;
127
- }
128
- return;
139
+ resSuccessExpress() {
140
+ this.Res.status(200).json(this.response.ResponseData);
141
+ }
142
+ resSuccessHono() {
143
+ return this.C.json(this.response.ResponseData, 200);
129
144
  }
130
145
  outputErrorLog(ex) {
131
146
  return __awaiter(this, void 0, void 0, function* () { });
132
147
  }
133
- handleException(ex) {
148
+ handleExceptionExpress(ex) {
134
149
  // To avoid slowing down the response, make this asynchronous
135
150
  this.outputErrorLog(ex).catch((ex) => {
136
151
  console.error(ex);
137
152
  });
138
153
  if (ex instanceof Exception_1.AuthException) {
139
- this.setResponse(401, {
154
+ this.Res.status(401).json({
140
155
  message: "Authentication expired. Please login again."
141
156
  });
142
157
  }
143
158
  else if (ex instanceof Exception_1.ForbiddenException) {
144
- this.setResponse(403, {
159
+ this.Res.status(403).json({
145
160
  message: 'Forbidden error'
146
161
  });
147
162
  }
148
163
  else if (ex instanceof Exception_1.InputErrorException) {
149
- this.setResponse(400, {
164
+ this.Res.status(400).json({
150
165
  errorCode: `${this.apiCode}-${ex.ErrorId}`,
151
166
  errorMessage: ex.message
152
167
  });
168
+ return;
153
169
  }
154
170
  else if (ex instanceof Exception_1.DbConflictException) {
155
- this.setResponse(409, {
171
+ this.Res.status(409).json({
156
172
  errorCode: `${this.apiCode}-${ex.ErrorId}`,
157
173
  errorMessage: ex.message
158
174
  });
159
175
  }
160
176
  else if (ex instanceof Exception_1.UnprocessableException) {
161
- this.setResponse(422, {
177
+ this.Res.status(422).json({
162
178
  errorCode: `${this.apiCode}-${ex.ErrorId}`,
163
179
  errorMessage: ex.message
164
180
  });
165
181
  }
166
182
  else if (ex instanceof Exception_1.MaintenanceException) {
167
- this.setResponse(503, {
183
+ this.Res.status(503).json({
168
184
  errorMessage: ex.message
169
185
  });
170
186
  }
171
187
  else if (ex instanceof Exception_1.NotFoundException) {
172
- this.setResponse(404, {
188
+ this.Res.status(404).json({
173
189
  errorCode: `${this.apiCode}-${ex.ErrorId}`,
174
190
  errorMessage: ex.message
175
191
  });
176
192
  }
177
193
  else {
178
- this.setResponse(500, {
194
+ this.Res.status(500).json({
179
195
  message: 'Internal server error'
180
196
  });
181
197
  }
182
- if (this.module === 'hono') {
183
- return this.c;
198
+ }
199
+ handleExceptionHono(ex) {
200
+ // To avoid slowing down the response, make this asynchronous
201
+ this.outputErrorLog(ex).catch((ex) => {
202
+ console.error(ex);
203
+ });
204
+ if (ex instanceof Exception_1.AuthException) {
205
+ return this.C.json({
206
+ message: "Authentication expired. Please login again."
207
+ }, 401);
208
+ }
209
+ else if (ex instanceof Exception_1.ForbiddenException) {
210
+ return this.C.json({
211
+ message: 'Forbidden error'
212
+ }, 403);
213
+ }
214
+ else if (ex instanceof Exception_1.InputErrorException) {
215
+ return this.C.json({
216
+ errorCode: `${this.apiCode}-${ex.ErrorId}`,
217
+ errorMessage: ex.message
218
+ }, 400);
219
+ }
220
+ else if (ex instanceof Exception_1.DbConflictException) {
221
+ return this.C.json({
222
+ errorCode: `${this.apiCode}-${ex.ErrorId}`,
223
+ errorMessage: ex.message
224
+ }, 409);
225
+ }
226
+ else if (ex instanceof Exception_1.UnprocessableException) {
227
+ return this.C.json({
228
+ errorCode: `${this.apiCode}-${ex.ErrorId}`,
229
+ errorMessage: ex.message
230
+ }, 422);
231
+ }
232
+ else if (ex instanceof Exception_1.MaintenanceException) {
233
+ return this.C.json({
234
+ errorMessage: ex.message
235
+ }, 503);
236
+ }
237
+ else if (ex instanceof Exception_1.NotFoundException) {
238
+ return this.C.json({
239
+ errorCode: `${this.apiCode}-${ex.ErrorId}`,
240
+ errorMessage: ex.message
241
+ }, 404);
242
+ }
243
+ else {
244
+ return this.C.json({
245
+ message: 'Internal server error'
246
+ }, 500);
184
247
  }
185
- return;
186
248
  }
187
249
  get Pool() {
188
250
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {