@flink-app/management-api-plugin 0.11.0 → 0.11.4-next.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated Tue Jun 18 2024 09:50:45 GMT+0200 (Central European Summer Time)
3
+ // Generated Mon Dec 09 2024 15:57:58 GMT+0100 (Central European Standard Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -0,0 +1,7 @@
1
+ import { GetHandler } from "@flink-app/flink";
2
+ import { Ctx } from "../../Ctx";
3
+ import { GetManagementRes } from "../../schemas/Management/GetRes";
4
+ declare const GetManagement: GetHandler<Ctx, GetManagementRes>;
5
+ export default GetManagement;
6
+ export declare const __assumedHttpMethod = "get", __file = "Get.ts";
7
+ export declare const __schemas: any;
@@ -0,0 +1,53 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__file = exports.__assumedHttpMethod = void 0;
40
+ var GetManagement = function (_a) {
41
+ var ctx = _a.ctx, req = _a.req;
42
+ return __awaiter(void 0, void 0, void 0, function () {
43
+ return __generator(this, function (_b) {
44
+ return [2 /*return*/, {
45
+ data: ctx.plugins.managementApi.moduleList,
46
+ status: 200,
47
+ }];
48
+ });
49
+ });
50
+ };
51
+ exports.default = GetManagement;
52
+ exports.__assumedHttpMethod = "get", exports.__file = "Get.ts";
53
+ exports.__schemas = { reqSchema: undefined, resSchema: { "type": "object", "additionalProperties": false, "properties": { "modules": { "type": "array", "items": { "$ref": "#/definitions/Module" } } }, "required": ["modules"] } };
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -37,17 +37,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
- var GetManagement = function (_a) {
41
- var ctx = _a.ctx, req = _a.req;
42
- return __awaiter(void 0, void 0, void 0, function () {
43
- return __generator(this, function (_b) {
44
- return [2 /*return*/, {
45
- data: ctx.plugins.managementApi.moduleList,
46
- status: 200,
47
- }];
48
- });
40
+ var GetManagement = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
41
+ var ctx = _b.ctx, req = _b.req;
42
+ return __generator(this, function (_c) {
43
+ return [2 /*return*/, {
44
+ data: ctx.plugins.managementApi.moduleList,
45
+ status: 200,
46
+ }];
49
47
  });
50
- };
48
+ }); };
51
49
  exports.default = GetManagement;
52
50
  exports.__assumedHttpMethod = "get", exports.__file = "GetManagement.ts", exports.__query = [], exports.__params = [];
53
51
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "modules": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" }, "features": { "type": "array", "items": { "type": "string" } }, "title": { "type": "string" }, "ui": { "type": "string" }, "data": { "type": "object" }, "endpoints": { "type": "array", "items": { "type": "object", "properties": { "method": { "type": "string" }, "url": { "type": "string" } }, "required": ["method", "url"], "additionalProperties": false } } }, "required": ["id", "type", "features", "title", "ui", "data", "endpoints"], "additionalProperties": false } } }, "required": ["modules"], "definitions": {} } };
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -45,26 +45,24 @@ exports.Route = {
45
45
  // type Params = {
46
46
  // userid: string;
47
47
  // };
48
- var DeleteUserByUserid = function (_a) {
49
- var ctx = _a.ctx, req = _a.req;
50
- return __awaiter(void 0, void 0, void 0, function () {
51
- var count;
52
- return __generator(this, function (_b) {
53
- switch (_b.label) {
54
- case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.deleteById(req.params.userid)];
55
- case 1:
56
- count = _b.sent();
57
- if (count == 0) {
58
- return [2 /*return*/, flink_1.notFound()];
59
- }
60
- return [2 /*return*/, {
61
- data: {},
62
- status: 200,
63
- }];
64
- }
65
- });
48
+ var DeleteUserByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
49
+ var count;
50
+ var ctx = _b.ctx, req = _b.req;
51
+ return __generator(this, function (_c) {
52
+ switch (_c.label) {
53
+ case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.deleteById(req.params.userid)];
54
+ case 1:
55
+ count = _c.sent();
56
+ if (count == 0) {
57
+ return [2 /*return*/, (0, flink_1.notFound)()];
58
+ }
59
+ return [2 /*return*/, {
60
+ data: {},
61
+ status: 200,
62
+ }];
63
+ }
66
64
  });
67
- };
65
+ }); };
68
66
  exports.default = DeleteUserByUserid;
69
67
  exports.__assumedHttpMethod = "delete", exports.__file = "DeleteByUserid.ts", exports.__query = [], exports.__params = [];
70
68
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -46,26 +46,24 @@ exports.Route = {
46
46
  // type Params = {
47
47
  // userid: string;
48
48
  // };
49
- var GetUserByUserid = function (_a) {
50
- var ctx = _a.ctx, req = _a.req;
51
- return __awaiter(void 0, void 0, void 0, function () {
52
- var user;
53
- return __generator(this, function (_b) {
54
- switch (_b.label) {
55
- case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getById(req.params.userid)];
56
- case 1:
57
- user = _b.sent();
58
- if (user == null) {
59
- return [2 /*return*/, flink_1.notFound()];
60
- }
61
- return [2 /*return*/, {
62
- data: ManagementUserViewModel_1.GetManagementUserViewModel(user),
63
- status: 200,
64
- }];
65
- }
66
- });
49
+ var GetUserByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
50
+ var user;
51
+ var ctx = _b.ctx, req = _b.req;
52
+ return __generator(this, function (_c) {
53
+ switch (_c.label) {
54
+ case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getById(req.params.userid)];
55
+ case 1:
56
+ user = _c.sent();
57
+ if (user == null) {
58
+ return [2 /*return*/, (0, flink_1.notFound)()];
59
+ }
60
+ return [2 /*return*/, {
61
+ data: (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user),
62
+ status: 200,
63
+ }];
64
+ }
67
65
  });
68
- };
66
+ }); };
69
67
  exports.default = GetUserByUserid;
70
68
  exports.__assumedHttpMethod = "get", exports.__file = "GetByUserid.ts", exports.__query = [], exports.__params = [];
71
69
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"], "definitions": {} } };
@@ -2,7 +2,7 @@ import { Handler } from "@flink-app/flink";
2
2
  import { GetUserListReq } from "../../schemas/User/GetListReq";
3
3
  import { GetUserListRes } from "../../schemas/User/GetListRes";
4
4
  import { Ctx } from "../../Ctx";
5
- declare type Params = {};
5
+ type Params = {};
6
6
  declare const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params>;
7
7
  export default GetUserList;
8
8
  export declare const __assumedHttpMethod = "get", __file = "GetList.ts", __query: never[], __params: never[];
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,27 +38,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
41
- var GetUserList = function (_a) {
42
- var ctx = _a.ctx, req = _a.req;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var repo, users;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- repo = ctx.repos.managementuserRepo;
49
- return [4 /*yield*/, repo.findAll()];
50
- case 1:
51
- users = _b.sent();
52
- return [2 /*return*/, {
53
- data: {
54
- users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel)
55
- },
56
- status: 200
57
- }];
58
- }
59
- });
41
+ var GetUserList = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var repo, users;
43
+ var ctx = _b.ctx, req = _b.req;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ repo = ctx.repos.managementuserRepo;
48
+ return [4 /*yield*/, repo.findAll()];
49
+ case 1:
50
+ users = _c.sent();
51
+ return [2 /*return*/, {
52
+ data: {
53
+ users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel)
54
+ },
55
+ status: 200
56
+ }];
57
+ }
60
58
  });
61
- };
59
+ }); };
62
60
  exports.default = GetUserList;
63
61
  exports.__assumedHttpMethod = "get", exports.__file = "GetList.ts", exports.__query = [], exports.__params = [];
64
62
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "users": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } } }, "required": ["users"], "definitions": {} } };
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -53,29 +53,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
54
54
  var flink_1 = require("@flink-app/flink");
55
55
  var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
56
- var GetUserMe = function (_a) {
57
- var ctx = _a.ctx, req = _a.req;
58
- return __awaiter(void 0, void 0, void 0, function () {
59
- var user, iat, rest;
60
- return __generator(this, function (_b) {
61
- try {
62
- user = jsonwebtoken_1.default.verify(req.headers["management-token"], ctx.plugins.managementApi.jwtSecret);
63
- iat = user.iat, rest = __rest(user, ["iat"]);
64
- return [2 /*return*/, {
65
- data: {
66
- token: req.headers["management-token"],
67
- user: rest
68
- },
69
- status: 200
70
- }];
71
- }
72
- catch (ex) {
73
- return [2 /*return*/, flink_1.unauthorized()];
74
- }
75
- return [2 /*return*/];
76
- });
56
+ var GetUserMe = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
+ var user, iat, rest;
58
+ var ctx = _b.ctx, req = _b.req;
59
+ return __generator(this, function (_c) {
60
+ try {
61
+ user = jsonwebtoken_1.default.verify(req.headers["management-token"], ctx.plugins.managementApi.jwtSecret);
62
+ iat = user.iat, rest = __rest(user, ["iat"]);
63
+ return [2 /*return*/, {
64
+ data: {
65
+ token: req.headers["management-token"],
66
+ user: rest
67
+ },
68
+ status: 200
69
+ }];
70
+ }
71
+ catch (ex) {
72
+ return [2 /*return*/, (0, flink_1.unauthorized)()];
73
+ }
74
+ return [2 /*return*/];
77
75
  });
78
- };
76
+ }); };
79
77
  exports.default = GetUserMe;
80
78
  exports.__assumedHttpMethod = "get", exports.__file = "GetMe.ts", exports.__query = [], exports.__params = [];
81
79
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"], "definitions": {} } };
@@ -3,7 +3,7 @@ import { Ctx } from "../../Ctx";
3
3
  import { PostUserReq } from "../../schemas/User/PostReq";
4
4
  import { PostUserRes } from "../../schemas/User/PostRes";
5
5
  export declare const Route: RouteProps;
6
- declare type Params = {};
6
+ type Params = {};
7
7
  declare const PostUser: Handler<Ctx, PostUserReq, PostUserRes, Params>;
8
8
  export default PostUser;
9
9
  export declare const __assumedHttpMethod = "post", __file = "Post.ts", __query: never[], __params: never[];
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -44,44 +44,42 @@ exports.Route = {
44
44
  path: "/user",
45
45
  method: flink_1.HttpMethod.post,
46
46
  };
47
- var PostUser = function (_a) {
48
- var ctx = _a.ctx, req = _a.req;
49
- return __awaiter(void 0, void 0, void 0, function () {
50
- var existingUser, salt, hash, obj, user;
51
- return __generator(this, function (_b) {
52
- switch (_b.label) {
53
- case 0:
54
- if (req.body.username.length == 0 || req.body.password.length == 0) {
55
- return [2 /*return*/, flink_1.badRequest("Username and password must be specified")];
56
- }
57
- return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({ username: req.body.username })];
58
- case 1:
59
- existingUser = _b.sent();
60
- if (existingUser != null) {
61
- return [2 /*return*/, flink_1.conflict("Username already taken")];
62
- }
63
- return [4 /*yield*/, bcrypt_1.genSalt(10)];
64
- case 2:
65
- salt = _b.sent();
66
- return [4 /*yield*/, bcrypt_1.encrypt(req.body.password, salt)];
67
- case 3:
68
- hash = _b.sent();
69
- obj = {
70
- username: req.body.username,
71
- password: hash,
72
- salt: salt
73
- };
74
- return [4 /*yield*/, ctx.repos.managementuserRepo.create(obj)];
75
- case 4:
76
- user = _b.sent();
77
- return [2 /*return*/, {
78
- data: ManagementUserViewModel_1.GetManagementUserViewModel(user),
79
- status: 200
80
- }];
81
- }
82
- });
47
+ var PostUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
48
+ var existingUser, salt, hash, obj, user;
49
+ var ctx = _b.ctx, req = _b.req;
50
+ return __generator(this, function (_c) {
51
+ switch (_c.label) {
52
+ case 0:
53
+ if (req.body.username.length == 0 || req.body.password.length == 0) {
54
+ return [2 /*return*/, (0, flink_1.badRequest)("Username and password must be specified")];
55
+ }
56
+ return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({ username: req.body.username })];
57
+ case 1:
58
+ existingUser = _c.sent();
59
+ if (existingUser != null) {
60
+ return [2 /*return*/, (0, flink_1.conflict)("Username already taken")];
61
+ }
62
+ return [4 /*yield*/, (0, bcrypt_1.genSalt)(10)];
63
+ case 2:
64
+ salt = _c.sent();
65
+ return [4 /*yield*/, (0, bcrypt_1.encrypt)(req.body.password, salt)];
66
+ case 3:
67
+ hash = _c.sent();
68
+ obj = {
69
+ username: req.body.username,
70
+ password: hash,
71
+ salt: salt
72
+ };
73
+ return [4 /*yield*/, ctx.repos.managementuserRepo.create(obj)];
74
+ case 4:
75
+ user = _c.sent();
76
+ return [2 /*return*/, {
77
+ data: (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user),
78
+ status: 200
79
+ }];
80
+ }
83
81
  });
84
- };
82
+ }); };
85
83
  exports.default = PostUser;
86
84
  exports.__assumedHttpMethod = "post", exports.__file = "Post.ts", exports.__query = [], exports.__params = [];
87
85
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"], "definitions": {} } };
@@ -3,7 +3,7 @@ import { Ctx } from "../../Ctx";
3
3
  import { PostUserLoginReq } from "../../schemas/User/PostLoginReq";
4
4
  import { PostUserLoginRes } from "../../schemas/User/PostLoginRes";
5
5
  export declare const Route: RouteProps;
6
- declare type Params = {};
6
+ type Params = {};
7
7
  declare const PostUserLogin: Handler<Ctx, PostUserLoginReq, PostUserLoginRes, Params>;
8
8
  export default PostUserLogin;
9
9
  export declare const __assumedHttpMethod = "post", __file = "PostLogin.ts", __query: never[], __params: never[];
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -48,39 +48,37 @@ exports.Route = {
48
48
  path: "/user/login",
49
49
  method: flink_1.HttpMethod.post,
50
50
  };
51
- var PostUserLogin = function (_a) {
52
- var ctx = _a.ctx, req = _a.req;
53
- return __awaiter(void 0, void 0, void 0, function () {
54
- var user, hashCandidate, viewUser, token;
55
- return __generator(this, function (_b) {
56
- switch (_b.label) {
57
- case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
58
- username: req.body.username,
59
- })];
60
- case 1:
61
- user = _b.sent();
62
- if (user == null) {
63
- return [2 /*return*/, flink_1.unauthorized("Username or password invalid")];
64
- }
65
- return [4 /*yield*/, bcrypt_1.encrypt(req.body.password, user.salt)];
66
- case 2:
67
- hashCandidate = _b.sent();
68
- if (hashCandidate !== user.password) {
69
- return [2 /*return*/, flink_1.unauthorized("Username or password invalid")];
70
- }
71
- viewUser = ManagementUserViewModel_1.GetManagementUserViewModel(user);
72
- token = jsonwebtoken_1.default.sign(viewUser, ctx.plugins.managementApi.jwtSecret);
73
- return [2 /*return*/, {
74
- data: {
75
- user: viewUser,
76
- token: token,
77
- },
78
- status: 200,
79
- }];
80
- }
81
- });
51
+ var PostUserLogin = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
52
+ var user, hashCandidate, viewUser, token;
53
+ var ctx = _b.ctx, req = _b.req;
54
+ return __generator(this, function (_c) {
55
+ switch (_c.label) {
56
+ case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
57
+ username: req.body.username,
58
+ })];
59
+ case 1:
60
+ user = _c.sent();
61
+ if (user == null) {
62
+ return [2 /*return*/, (0, flink_1.unauthorized)("Username or password invalid")];
63
+ }
64
+ return [4 /*yield*/, (0, bcrypt_1.encrypt)(req.body.password, user.salt)];
65
+ case 2:
66
+ hashCandidate = _c.sent();
67
+ if (hashCandidate !== user.password) {
68
+ return [2 /*return*/, (0, flink_1.unauthorized)("Username or password invalid")];
69
+ }
70
+ viewUser = (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user);
71
+ token = jsonwebtoken_1.default.sign(viewUser, ctx.plugins.managementApi.jwtSecret);
72
+ return [2 /*return*/, {
73
+ data: {
74
+ user: viewUser,
75
+ token: token,
76
+ },
77
+ status: 200,
78
+ }];
79
+ }
82
80
  });
83
- };
81
+ }); };
84
82
  exports.default = PostUserLogin;
85
83
  exports.__assumedHttpMethod = "post", exports.__file = "PostLogin.ts", exports.__query = [], exports.__params = [];
86
84
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"], "definitions": {} } };