badmfck-api-server 1.1.4 → 1.1.6

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.
@@ -133,11 +133,13 @@ class APIService extends BaseService_1.BaseService {
133
133
  result = await i.execute(httpRequest);
134
134
  }
135
135
  catch (e) {
136
+ if (this.options.onError)
137
+ this.options.onError(e);
136
138
  this.sendResponse(res, {
137
139
  httpStatus: 500,
138
140
  error: {
139
141
  code: 10002,
140
- message: "Internal server error"
142
+ message: "Internal server error",
141
143
  }
142
144
  }, tme, ep, log);
143
145
  return;
@@ -63,6 +63,17 @@ class MysqlService extends BaseService_1.BaseService {
63
63
  .replaceAll('@fields', insertFieldNames.join(","))
64
64
  .replaceAll('@values', insertFieldValues.join(","));
65
65
  }
66
+ if (query.indexOf("@insert") !== -1) {
67
+ let oninsertNames = [];
68
+ let oninsertValues = [];
69
+ for (let i of fields) {
70
+ if (i.ignoreInInsert)
71
+ continue;
72
+ oninsertNames.push(i.name);
73
+ oninsertValues.push(i._parsedValue);
74
+ }
75
+ query = query.replaceAll("@oninsert", `(${oninsertNames.join(",")}) VALUES (${oninsertValues.join(",")})`);
76
+ }
66
77
  if (query.indexOf("@onupdate") !== -1) {
67
78
  let onUpdate = [];
68
79
  for (let i of fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",