@flink-app/management-api-plugin 0.11.14 → 0.12.1-alpha.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/.flink/generatedHandlers.ts +1 -1
- package/.flink/generatedJobs.ts +1 -1
- package/.flink/generatedRepos.ts +1 -1
- package/.flink/schemas/schemas.json +4 -4
- package/.flink/schemas/schemas.ts +5 -5
- package/.flink/start.ts +1 -1
- package/dist/.flink/generatedHandlers.js +1 -1
- package/dist/.flink/generatedJobs.js +1 -1
- package/dist/.flink/generatedRepos.js +1 -1
- package/dist/.flink/schemas/schemas.d.ts +4 -4
- package/dist/.flink/schemas/schemas.json +4 -4
- package/dist/.flink/start.js +1 -1
- package/dist/src/handlers/User/GetList.d.ts +1 -1
- package/dist/src/handlers/User/GetList.js +2 -2
- package/dist/src/handlers/User/Post.js +3 -3
- package/package.json +3 -4
- package/src/handlers/User/GetList.ts +14 -18
- package/src/handlers/User/Post.ts +19 -24
- package/src/schemas/ManagementUser.ts +6 -6
- package/src/schemas/ManagementUserViewModel.ts +3 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
|
|
3
3
|
import * as GetManagement_0 from "../src/handlers/Management/GetManagement";
|
|
4
4
|
import * as DeleteByUserid_0 from "../src/handlers/User/DeleteByUserid";
|
package/.flink/generatedJobs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredJobs } from "@flink-app/flink";
|
|
3
3
|
export const jobs = [];
|
|
4
4
|
autoRegisteredJobs.push(...jobs);
|
package/.flink/generatedRepos.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredRepos } from "@flink-app/flink";
|
|
3
3
|
import ManagementUserRepo from "../src/repos/ManagementUserRepo";
|
|
4
4
|
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
],
|
|
118
118
|
"definitions": {}
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"GetList_9_ReqSchema": {
|
|
121
121
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
122
122
|
"type": "object",
|
|
123
123
|
"additionalProperties": false,
|
|
124
124
|
"properties": {},
|
|
125
125
|
"definitions": {}
|
|
126
126
|
},
|
|
127
|
-
"
|
|
127
|
+
"GetList_9_ResSchema": {
|
|
128
128
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
129
129
|
"type": "object",
|
|
130
130
|
"additionalProperties": false,
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
],
|
|
193
193
|
"definitions": {}
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"Post_14_ReqSchema": {
|
|
196
196
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
197
197
|
"type": "object",
|
|
198
198
|
"additionalProperties": false,
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
],
|
|
211
211
|
"definitions": {}
|
|
212
212
|
},
|
|
213
|
-
"
|
|
213
|
+
"Post_14_ResSchema": {
|
|
214
214
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
215
215
|
"type": "object",
|
|
216
216
|
"additionalProperties": false,
|
|
@@ -15,7 +15,7 @@ import { PostUserLoginRes } from "../../src/schemas/User/PostLoginRes";
|
|
|
15
15
|
import { PutUserByUseridReq } from "../../src/schemas/User/PutByUseridReq";
|
|
16
16
|
import { PutUserByUseridRes } from "../../src/schemas/User/PutByUseridRes";
|
|
17
17
|
|
|
18
|
-
// Generated
|
|
18
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
19
19
|
export interface GetManagement_9_ReqSchema extends GetManagementReq {}
|
|
20
20
|
|
|
21
21
|
export interface GetManagement_9_ResSchema extends GetManagementRes {}
|
|
@@ -28,17 +28,17 @@ export interface GetByUserid_15_ReqSchema extends GetUserByUseridReq {}
|
|
|
28
28
|
|
|
29
29
|
export interface GetByUserid_15_ResSchema extends GetUserByUseridRes {}
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface GetList_9_ReqSchema extends GetUserListReq {}
|
|
32
32
|
|
|
33
|
-
export interface
|
|
33
|
+
export interface GetList_9_ResSchema extends GetUserListRes {}
|
|
34
34
|
|
|
35
35
|
export interface GetMe_8_ReqSchema extends GetUserMeReq {}
|
|
36
36
|
|
|
37
37
|
export interface GetMe_8_ResSchema extends GetUserMeRes {}
|
|
38
38
|
|
|
39
|
-
export interface
|
|
39
|
+
export interface Post_14_ReqSchema extends PostUserReq {}
|
|
40
40
|
|
|
41
|
-
export interface
|
|
41
|
+
export interface Post_14_ResSchema extends PostUserRes {}
|
|
42
42
|
|
|
43
43
|
export interface PostLogin_21_ReqSchema extends PostUserLoginReq {}
|
|
44
44
|
|
package/.flink/start.ts
CHANGED
|
@@ -20,7 +20,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.handlers = void 0;
|
|
23
|
-
// Generated
|
|
23
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
24
24
|
var flink_1 = require("@flink-app/flink");
|
|
25
25
|
var DeleteByUserid_0 = __importStar(require("../src/handlers/User/DeleteByUserid"));
|
|
26
26
|
var GetByUserid_1 = __importStar(require("../src/handlers/User/GetByUserid"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jobs = void 0;
|
|
4
|
-
// Generated
|
|
4
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
5
5
|
var flink_1 = require("@flink-app/flink");
|
|
6
6
|
exports.jobs = [];
|
|
7
7
|
flink_1.autoRegisteredJobs.push.apply(flink_1.autoRegisteredJobs, exports.jobs);
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.repos = void 0;
|
|
7
|
-
// Generated
|
|
7
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
8
8
|
var flink_1 = require("@flink-app/flink");
|
|
9
9
|
var ManagementUserRepo_1 = __importDefault(require("../src/repos/ManagementUserRepo"));
|
|
10
10
|
exports.repos = [{ collectionName: "managementuser", repoInstanceName: "managementUserRepo", Repo: ManagementUserRepo_1.default }];
|
|
@@ -26,17 +26,17 @@ export interface GetByUserid_15_ReqSchema extends GetUserByUseridReq {
|
|
|
26
26
|
}
|
|
27
27
|
export interface GetByUserid_15_ResSchema extends GetUserByUseridRes {
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface GetList_9_ReqSchema extends GetUserListReq {
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface GetList_9_ResSchema extends GetUserListRes {
|
|
32
32
|
}
|
|
33
33
|
export interface GetMe_8_ReqSchema extends GetUserMeReq {
|
|
34
34
|
}
|
|
35
35
|
export interface GetMe_8_ResSchema extends GetUserMeRes {
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface Post_14_ReqSchema extends PostUserReq {
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface Post_14_ResSchema extends PostUserRes {
|
|
40
40
|
}
|
|
41
41
|
export interface PostLogin_21_ReqSchema extends PostUserLoginReq {
|
|
42
42
|
}
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
],
|
|
118
118
|
"definitions": {}
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"GetList_9_ReqSchema": {
|
|
121
121
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
122
122
|
"type": "object",
|
|
123
123
|
"additionalProperties": false,
|
|
124
124
|
"properties": {},
|
|
125
125
|
"definitions": {}
|
|
126
126
|
},
|
|
127
|
-
"
|
|
127
|
+
"GetList_9_ResSchema": {
|
|
128
128
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
129
129
|
"type": "object",
|
|
130
130
|
"additionalProperties": false,
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
],
|
|
193
193
|
"definitions": {}
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"Post_14_ReqSchema": {
|
|
196
196
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
197
197
|
"type": "object",
|
|
198
198
|
"additionalProperties": false,
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
],
|
|
211
211
|
"definitions": {}
|
|
212
212
|
},
|
|
213
|
-
"
|
|
213
|
+
"Post_14_ResSchema": {
|
|
214
214
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
215
215
|
"type": "object",
|
|
216
216
|
"additionalProperties": false,
|
package/dist/.flink/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated
|
|
3
|
+
// Generated Wed Mar 19 2025 16:31:54 GMT+0100 (Central European Standard Time)
|
|
4
4
|
require("./generatedHandlers");
|
|
5
5
|
require("./generatedRepos");
|
|
6
6
|
require("./generatedJobs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Handler } from "@flink-app/flink";
|
|
2
|
+
import { Ctx } from "../../Ctx";
|
|
2
3
|
import { GetUserListReq } from "../../schemas/User/GetListReq";
|
|
3
4
|
import { GetUserListRes } from "../../schemas/User/GetListRes";
|
|
4
|
-
import { Ctx } from "../../Ctx";
|
|
5
5
|
declare type Params = {};
|
|
6
6
|
declare const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params>;
|
|
7
7
|
export default GetUserList;
|
|
@@ -51,9 +51,9 @@ var GetUserList = function (_a) {
|
|
|
51
51
|
users = _b.sent();
|
|
52
52
|
return [2 /*return*/, {
|
|
53
53
|
data: {
|
|
54
|
-
users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel)
|
|
54
|
+
users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel),
|
|
55
55
|
},
|
|
56
|
-
status: 200
|
|
56
|
+
status: 200,
|
|
57
57
|
}];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
@@ -38,8 +38,8 @@ 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 = exports.Route = void 0;
|
|
40
40
|
var flink_1 = require("@flink-app/flink");
|
|
41
|
-
var bcrypt_1 = require("../../utils/bcrypt");
|
|
42
41
|
var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
|
|
42
|
+
var bcrypt_1 = require("../../utils/bcrypt");
|
|
43
43
|
exports.Route = {
|
|
44
44
|
path: "/user",
|
|
45
45
|
method: flink_1.HttpMethod.post,
|
|
@@ -69,14 +69,14 @@ var PostUser = function (_a) {
|
|
|
69
69
|
obj = {
|
|
70
70
|
username: req.body.username,
|
|
71
71
|
password: hash,
|
|
72
|
-
salt: salt
|
|
72
|
+
salt: salt,
|
|
73
73
|
};
|
|
74
74
|
return [4 /*yield*/, ctx.repos.managementuserRepo.create(obj)];
|
|
75
75
|
case 4:
|
|
76
76
|
user = _b.sent();
|
|
77
77
|
return [2 /*return*/, {
|
|
78
78
|
data: ManagementUserViewModel_1.GetManagementUserViewModel(user),
|
|
79
|
-
status: 200
|
|
79
|
+
status: 200,
|
|
80
80
|
}];
|
|
81
81
|
}
|
|
82
82
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/management-api-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1-alpha.0",
|
|
4
4
|
"description": "Flink plugin that makes it possible to expose management api:s for other plugins",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
"types": "dist/src/index.d.ts",
|
|
17
17
|
"main": "dist/src/index.js",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/mongodb": "3.6.12",
|
|
20
19
|
"bcrypt": "^5.0.1",
|
|
21
20
|
"express": "^4.17.1",
|
|
22
21
|
"jsonwebtoken": "^8.5.1"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@flink-app/flink": "^0.
|
|
24
|
+
"@flink-app/flink": "^0.12.1-alpha.0",
|
|
26
25
|
"@types/bcrypt": "^5.0.0",
|
|
27
26
|
"@types/express": "4.17.11",
|
|
28
27
|
"@types/express-fileupload": "^1.1.7",
|
|
@@ -31,5 +30,5 @@
|
|
|
31
30
|
"ts-node": "^9.1.1",
|
|
32
31
|
"typescript": "^4.2.4"
|
|
33
32
|
},
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7f6e32aa896f5cade313f3c5133c756fc5391ce8"
|
|
35
34
|
}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { Handler
|
|
1
|
+
import { Handler } from "@flink-app/flink";
|
|
2
|
+
import { Ctx } from "../../Ctx";
|
|
3
|
+
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
2
4
|
import { GetUserListReq } from "../../schemas/User/GetListReq";
|
|
3
5
|
import { GetUserListRes } from "../../schemas/User/GetListRes";
|
|
4
|
-
import { Ctx } from "../../Ctx";
|
|
5
|
-
import { GetManagementUserViewModel} from "../../schemas/ManagementUserViewModel";
|
|
6
6
|
|
|
7
|
-
type Params = {
|
|
8
|
-
};
|
|
7
|
+
type Params = {};
|
|
9
8
|
|
|
10
9
|
const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params> = async ({ ctx, req }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const users = await repo.findAll();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
data: {
|
|
18
|
-
users : users.map(GetManagementUserViewModel)
|
|
19
|
-
},
|
|
20
|
-
status : 200
|
|
21
|
-
};
|
|
10
|
+
const repo = ctx.repos.managementuserRepo;
|
|
11
|
+
const users = await repo.findAll();
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
return {
|
|
14
|
+
data: {
|
|
15
|
+
users: users.map(GetManagementUserViewModel),
|
|
16
|
+
},
|
|
17
|
+
status: 200,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default GetUserList;
|
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
import { badRequest, conflict, Handler, HttpMethod,
|
|
1
|
+
import { badRequest, conflict, Handler, HttpMethod, RouteProps } from "@flink-app/flink";
|
|
2
2
|
import { Ctx } from "../../Ctx";
|
|
3
|
+
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
3
4
|
import { PostUserReq } from "../../schemas/User/PostReq";
|
|
4
5
|
import { PostUserRes } from "../../schemas/User/PostRes";
|
|
5
|
-
import { encrypt, genSalt } from "../../utils/bcrypt"
|
|
6
|
-
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
6
|
+
import { encrypt, genSalt } from "../../utils/bcrypt";
|
|
7
7
|
export const Route: RouteProps = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: "/user",
|
|
9
|
+
method: HttpMethod.post,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
type Params = {
|
|
13
|
-
};
|
|
12
|
+
type Params = {};
|
|
14
13
|
|
|
15
14
|
const PostUser: Handler<Ctx, PostUserReq, PostUserRes, Params> = async ({ ctx, req }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if(req.body.username.length == 0 || req.body.password.length == 0){
|
|
20
|
-
return badRequest("Username and password must be specified");
|
|
15
|
+
if (req.body.username.length == 0 || req.body.password.length == 0) {
|
|
16
|
+
return badRequest("Username and password must be specified");
|
|
21
17
|
}
|
|
22
|
-
const existingUser = await ctx.repos.managementuserRepo.getOne({ username
|
|
23
|
-
if(existingUser!=null){
|
|
24
|
-
|
|
18
|
+
const existingUser = await ctx.repos.managementuserRepo.getOne({ username: req.body.username });
|
|
19
|
+
if (existingUser != null) {
|
|
20
|
+
return conflict("Username already taken");
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
const salt = await genSalt(10);
|
|
28
24
|
const hash = await encrypt(req.body.password, salt);
|
|
29
25
|
|
|
30
26
|
var obj = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
27
|
+
username: req.body.username,
|
|
28
|
+
password: hash,
|
|
29
|
+
salt: salt,
|
|
30
|
+
};
|
|
35
31
|
|
|
36
32
|
const user = await ctx.repos.managementuserRepo.create(obj);
|
|
37
33
|
|
|
38
34
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
data: GetManagementUserViewModel(user),
|
|
36
|
+
status: 200,
|
|
41
37
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export default PostUser;
|
|
38
|
+
};
|
|
39
|
+
export default PostUser;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface ManagementUser{
|
|
2
|
-
_id
|
|
3
|
-
username
|
|
4
|
-
password
|
|
5
|
-
salt
|
|
6
|
-
}
|
|
1
|
+
export interface ManagementUser {
|
|
2
|
+
_id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
salt: string;
|
|
6
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ManagementUser } from "./ManagementUser";
|
|
2
|
-
export interface ManagementUserViewModel extends Omit<ManagementUser, "password" | "salt">{
|
|
2
|
+
export interface ManagementUserViewModel extends Omit<ManagementUser, "password" | "salt"> {}
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const GetManagementUserViewModel = (user : ManagementUser) : ManagementUserViewModel => {
|
|
4
|
+
export const GetManagementUserViewModel = (user: ManagementUser): ManagementUserViewModel => {
|
|
7
5
|
const { password, salt, ...resp } = user;
|
|
8
6
|
return resp;
|
|
9
|
-
}
|
|
7
|
+
};
|