@drax/identity-back 0.5.4 → 0.5.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.
- package/dist/repository/mongo/RoleMongoRepository.js +24 -1
- package/dist/repository/mongo/TenantMongoRepository.js +14 -2
- package/dist/repository/mongo/UserMongoRepository.js +23 -0
- package/dist/repository/sqlite/TenantSqliteRepository.js +1 -1
- package/dist/routes/RoleRoutes.js +1 -0
- package/dist/routes/UserRoutes.js +1 -0
- package/package.json +5 -5
- package/src/interfaces/IRoleRepository.ts +2 -2
- package/src/repository/mongo/RoleMongoRepository.ts +65 -18
- package/src/repository/mongo/TenantMongoRepository.ts +25 -3
- package/src/repository/mongo/UserMongoRepository.ts +49 -2
- package/src/repository/sqlite/TenantSqliteRepository.ts +0 -1
- package/src/routes/RoleRoutes.ts +2 -0
- package/src/routes/UserRoutes.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/interfaces/IRoleRepository.d.ts +2 -2
- package/types/interfaces/IRoleRepository.d.ts.map +1 -1
- package/types/models/RoleModel.d.ts +5 -0
- package/types/models/RoleModel.d.ts.map +1 -1
- package/types/models/TenantModel.d.ts +5 -0
- package/types/models/TenantModel.d.ts.map +1 -1
- package/types/models/UserApiKeyModel.d.ts +5 -0
- package/types/models/UserApiKeyModel.d.ts.map +1 -1
- package/types/models/UserGroupModel.d.ts +5 -0
- package/types/models/UserGroupModel.d.ts.map +1 -1
- package/types/models/UserModel.d.ts +5 -0
- package/types/models/UserModel.d.ts.map +1 -1
- package/types/repository/mongo/RoleMongoRepository.d.ts +31 -1
- package/types/repository/mongo/RoleMongoRepository.d.ts.map +1 -1
- package/types/repository/mongo/TenantMongoRepository.d.ts +30 -1
- package/types/repository/mongo/TenantMongoRepository.d.ts.map +1 -1
- package/types/repository/mongo/UserMongoRepository.d.ts +31 -1
- package/types/repository/mongo/UserMongoRepository.d.ts.map +1 -1
- package/types/repository/sqlite/TenantSqliteRepository.d.ts +1 -1
- package/types/repository/sqlite/TenantSqliteRepository.d.ts.map +1 -1
- package/types/routes/RoleRoutes.d.ts.map +1 -1
- package/types/routes/UserRoutes.d.ts.map +1 -1
|
@@ -2,7 +2,7 @@ import { RoleModel } from "../../models/RoleModel.js";
|
|
|
2
2
|
import { MongooseQueryFilter, MongooseSort } from "@drax/common-back";
|
|
3
3
|
class RoleMongoRepository {
|
|
4
4
|
constructor() {
|
|
5
|
-
this._searchFields = ['
|
|
5
|
+
this._searchFields = ['name'];
|
|
6
6
|
}
|
|
7
7
|
async create(roleData) {
|
|
8
8
|
const role = new RoleModel(roleData);
|
|
@@ -54,5 +54,28 @@ class RoleMongoRepository {
|
|
|
54
54
|
items: roles.docs
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
async find({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
58
|
+
const query = {};
|
|
59
|
+
if (search) {
|
|
60
|
+
query['$or'] = [
|
|
61
|
+
{ name: new RegExp(search, 'i') },
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
MongooseQueryFilter.applyFilters(query, filters);
|
|
65
|
+
const sort = MongooseSort.applySort(orderBy, order);
|
|
66
|
+
return await RoleModel.find(query).limit(limit).sort(sort);
|
|
67
|
+
}
|
|
68
|
+
async findCursor({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
69
|
+
console.log("RoleMongoRepository.findCursor called");
|
|
70
|
+
const query = {};
|
|
71
|
+
if (search) {
|
|
72
|
+
query['$or'] = [
|
|
73
|
+
{ name: new RegExp(search, 'i') },
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
MongooseQueryFilter.applyFilters(query, filters);
|
|
77
|
+
const sort = MongooseSort.applySort(orderBy, order);
|
|
78
|
+
return RoleModel.find(query).limit(limit).sort(sort).cursor();
|
|
79
|
+
}
|
|
57
80
|
}
|
|
58
81
|
export default RoleMongoRepository;
|
|
@@ -55,7 +55,7 @@ class TenantMongoRepository {
|
|
|
55
55
|
items: tenants.docs
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
async find({
|
|
58
|
+
async find({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
59
59
|
const query = {};
|
|
60
60
|
if (search) {
|
|
61
61
|
query['$or'] = [
|
|
@@ -64,8 +64,20 @@ class TenantMongoRepository {
|
|
|
64
64
|
}
|
|
65
65
|
MongooseQueryFilter.applyFilters(query, filters);
|
|
66
66
|
const sort = MongooseSort.applySort(orderBy, order);
|
|
67
|
-
const items = await TenantModel.find(query).sort(sort);
|
|
67
|
+
const items = await TenantModel.find(query).limit(limit).sort(sort);
|
|
68
68
|
return items;
|
|
69
69
|
}
|
|
70
|
+
async findCursor({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
71
|
+
console.log("TenantMongoRepository.findCursor called");
|
|
72
|
+
const query = {};
|
|
73
|
+
if (search) {
|
|
74
|
+
query['$or'] = [
|
|
75
|
+
{ name: new RegExp(search, 'i') },
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
MongooseQueryFilter.applyFilters(query, filters);
|
|
79
|
+
const sort = MongooseSort.applySort(orderBy, order);
|
|
80
|
+
return TenantModel.find(query).limit(limit).sort(sort).cursor();
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
83
|
export default TenantMongoRepository;
|
|
@@ -90,5 +90,28 @@ class UserMongoRepository {
|
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
async find({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
94
|
+
const query = {};
|
|
95
|
+
if (search) {
|
|
96
|
+
query['$or'] = [
|
|
97
|
+
{ name: new RegExp(search, 'i') },
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
MongooseQueryFilter.applyFilters(query, filters);
|
|
101
|
+
const sort = MongooseSort.applySort(orderBy, order);
|
|
102
|
+
return await UserModel.find(query).populate(['role', 'tenant']).limit(limit).sort(sort);
|
|
103
|
+
}
|
|
104
|
+
async findCursor({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
105
|
+
console.log("RoleMongoRepository.findCursor called");
|
|
106
|
+
const query = {};
|
|
107
|
+
if (search) {
|
|
108
|
+
query['$or'] = [
|
|
109
|
+
{ name: new RegExp(search, 'i') },
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
MongooseQueryFilter.applyFilters(query, filters);
|
|
113
|
+
const sort = MongooseSort.applySort(orderBy, order);
|
|
114
|
+
return UserModel.find(query).populate(['role', 'tenant']).limit(limit).sort(sort).cursor();
|
|
115
|
+
}
|
|
93
116
|
}
|
|
94
117
|
export default UserMongoRepository;
|
|
@@ -96,7 +96,7 @@ class TenantSqliteRepository {
|
|
|
96
96
|
items: tenants
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
async find({
|
|
99
|
+
async find({ limit = 0, orderBy = '', order = false, search = '', filters = [] }) {
|
|
100
100
|
let where = "";
|
|
101
101
|
if (search) {
|
|
102
102
|
where = ` WHERE name LIKE '%${search}%'`;
|
|
@@ -2,6 +2,7 @@ import RoleController from "../controllers/RoleController.js";
|
|
|
2
2
|
async function RoleRoutes(fastify, options) {
|
|
3
3
|
const controller = new RoleController();
|
|
4
4
|
fastify.get('/api/permissions', (req, rep) => controller.permissions(req, rep));
|
|
5
|
+
fastify.get('/api/roles/export', (req, rep) => controller.export(req, rep));
|
|
5
6
|
fastify.get('/api/roles/search', (req, rep) => controller.search(req, rep));
|
|
6
7
|
fastify.get('/api/roles/:id', (req, rep) => controller.findById(req, rep));
|
|
7
8
|
fastify.get('/api/roles/name/:name', (req, rep) => controller.findByName(req, rep));
|
|
@@ -3,6 +3,7 @@ async function UserRoutes(fastify, options) {
|
|
|
3
3
|
const controller = new UserController();
|
|
4
4
|
fastify.post('/api/auth', (req, rep) => controller.auth(req, rep));
|
|
5
5
|
fastify.get('/api/me', (req, rep) => controller.me(req, rep));
|
|
6
|
+
fastify.get('/api/users/export', (req, rep) => controller.export(req, rep));
|
|
6
7
|
fastify.get('/api/users', (req, rep) => controller.paginate(req, rep));
|
|
7
8
|
fastify.post('/api/users', (req, rep) => controller.create(req, rep));
|
|
8
9
|
fastify.put('/api/users/:id', (req, rep) => controller.update(req, rep));
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
6
|
+
"version": "0.5.6",
|
|
7
7
|
"description": "Identity module for user management, authentication and authorization.",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/types/index.d.ts",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"author": "Cristian Incarnato & Drax Team",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@drax/common-back": "^0.5.
|
|
32
|
-
"@drax/crud-back": "^0.5.
|
|
33
|
-
"@drax/crud-share": "^0.5.
|
|
31
|
+
"@drax/common-back": "^0.5.6",
|
|
32
|
+
"@drax/crud-back": "^0.5.6",
|
|
33
|
+
"@drax/crud-share": "^0.5.5",
|
|
34
34
|
"@drax/identity-share": "^0.5.1",
|
|
35
35
|
"bcryptjs": "^2.4.3",
|
|
36
36
|
"express-jwt": "^8.4.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"debug": "0"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "ecb0ad934d7e7b25ee3e74e91a7fbba768305e01"
|
|
66
66
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {IRole, IRoleBase} from "@drax/identity-share";
|
|
2
|
-
import {
|
|
2
|
+
import {IDraxCrudRepository} from "@drax/crud-share";
|
|
3
3
|
|
|
4
|
-
interface IRoleRepository extends
|
|
4
|
+
interface IRoleRepository extends IDraxCrudRepository<IRole, IRoleBase, IRoleBase> {
|
|
5
5
|
findById(id: string): Promise<IRole | null>;
|
|
6
6
|
findByName(name: string): Promise<IRole | null>;
|
|
7
7
|
fetchAll(): Promise<IRole[]>;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
import {RoleModel} from "../../models/RoleModel.js";
|
|
2
2
|
import {IRoleRepository} from '../../interfaces/IRoleRepository'
|
|
3
3
|
import {mongoose, MongooseQueryFilter, MongooseSort} from "@drax/common-back";
|
|
4
|
-
import {PaginateOptions, PaginateResult} from "mongoose";
|
|
4
|
+
import {Cursor, PaginateOptions, PaginateResult} from "mongoose";
|
|
5
5
|
import {DeleteResult} from "mongodb";
|
|
6
|
-
import {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
6
|
+
import {IDraxFindOptions, IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
7
7
|
import {IRoleBase, IRole} from "@drax/identity-share";
|
|
8
8
|
|
|
9
|
-
class RoleMongoRepository implements IRoleRepository{
|
|
9
|
+
class RoleMongoRepository implements IRoleRepository {
|
|
10
10
|
|
|
11
|
-
_searchFields = ['
|
|
11
|
+
_searchFields = ['name']
|
|
12
12
|
|
|
13
13
|
async create(roleData: IRoleBase): Promise<IRole> {
|
|
14
|
-
const role
|
|
14
|
+
const role: mongoose.HydratedDocument<IRole> = new RoleModel(roleData)
|
|
15
15
|
await role.save()
|
|
16
16
|
await role.populate('childRoles')
|
|
17
17
|
return role
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async update(id: string, roleData: IRoleBase): Promise<IRole> {
|
|
21
|
-
const role
|
|
21
|
+
const role: mongoose.HydratedDocument<IRole> = await RoleModel.findOneAndUpdate({_id: id}, roleData, {new: true}).populate('childRoles').exec()
|
|
22
22
|
return role
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async delete(id: string): Promise<boolean> {
|
|
26
|
-
const result
|
|
26
|
+
const result: DeleteResult = await RoleModel.deleteOne({_id: id}).exec()
|
|
27
27
|
return result.deletedCount == 1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async findById(id: string): Promise<IRole | null>{
|
|
30
|
+
async findById(id: string): Promise<IRole | null> {
|
|
31
31
|
const role: mongoose.HydratedDocument<IRole> | null = await RoleModel.findById(id).populate('childRoles').exec()
|
|
32
32
|
return role
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async findByName(name: string): Promise<IRole | null>{
|
|
35
|
+
async findByName(name: string): Promise<IRole | null> {
|
|
36
36
|
const role: mongoose.HydratedDocument<IRole> | null = await RoleModel.findOne({name}).populate('childRoles').exec()
|
|
37
37
|
return role
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async fetchAll(): Promise<IRole[]>{
|
|
40
|
+
async fetchAll(): Promise<IRole[]> {
|
|
41
41
|
const roles: mongoose.HydratedDocument<IRole>[] = await RoleModel.find().populate('childRoles').exec()
|
|
42
42
|
return roles
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
async search(value: string, limit: number = 1000): Promise<IRole[]> {
|
|
46
46
|
const query = {}
|
|
47
|
-
if(value){
|
|
47
|
+
if (value) {
|
|
48
48
|
query['$or'] = this._searchFields.map(field => ({[field]: new RegExp(value.toString(), 'i')}))
|
|
49
49
|
}
|
|
50
50
|
const items: mongoose.HydratedDocument<IRole>[] = await RoleModel.find(query).limit(limit).exec()
|
|
@@ -52,15 +52,16 @@ class RoleMongoRepository implements IRoleRepository{
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async paginate({
|
|
55
|
-
page= 1,
|
|
56
|
-
limit= 5,
|
|
57
|
-
orderBy= '',
|
|
58
|
-
order= false,
|
|
59
|
-
search= '',
|
|
60
|
-
filters= []
|
|
55
|
+
page = 1,
|
|
56
|
+
limit = 5,
|
|
57
|
+
orderBy = '',
|
|
58
|
+
order = false,
|
|
59
|
+
search = '',
|
|
60
|
+
filters = []
|
|
61
|
+
}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IRole>> {
|
|
61
62
|
const query = {}
|
|
62
63
|
|
|
63
|
-
if(search){
|
|
64
|
+
if (search) {
|
|
64
65
|
query['$or'] = this._searchFields.map(field => ({[field]: new RegExp(search.toString(), 'i')}))
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -77,6 +78,52 @@ class RoleMongoRepository implements IRoleRepository{
|
|
|
77
78
|
items: roles.docs
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
async find({
|
|
83
|
+
limit = 0,
|
|
84
|
+
orderBy = '',
|
|
85
|
+
order = false,
|
|
86
|
+
search = '',
|
|
87
|
+
filters = []
|
|
88
|
+
}: IDraxFindOptions): Promise<IRole[]> {
|
|
89
|
+
|
|
90
|
+
const query = {}
|
|
91
|
+
|
|
92
|
+
if (search) {
|
|
93
|
+
query['$or'] = [
|
|
94
|
+
{name: new RegExp(search, 'i')},
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
MongooseQueryFilter.applyFilters(query, filters)
|
|
99
|
+
|
|
100
|
+
const sort = MongooseSort.applySort(orderBy, order)
|
|
101
|
+
|
|
102
|
+
return await RoleModel.find(query).limit(limit).sort(sort)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async findCursor({
|
|
106
|
+
limit = 0,
|
|
107
|
+
orderBy = '',
|
|
108
|
+
order = false,
|
|
109
|
+
search = '',
|
|
110
|
+
filters = []
|
|
111
|
+
}: IDraxFindOptions): Promise<Cursor> {
|
|
112
|
+
console.log("RoleMongoRepository.findCursor called")
|
|
113
|
+
const query = {}
|
|
114
|
+
|
|
115
|
+
if (search) {
|
|
116
|
+
query['$or'] = [
|
|
117
|
+
{name: new RegExp(search, 'i')},
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
MongooseQueryFilter.applyFilters(query, filters)
|
|
122
|
+
|
|
123
|
+
const sort = MongooseSort.applySort(orderBy, order)
|
|
124
|
+
|
|
125
|
+
return RoleModel.find(query).limit(limit).sort(sort).cursor() as Cursor;
|
|
126
|
+
}
|
|
80
127
|
}
|
|
81
128
|
|
|
82
129
|
export default RoleMongoRepository
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {TenantModel} from "../../models/TenantModel.js";
|
|
2
2
|
import {ITenantRepository} from '../../interfaces/ITenantRepository'
|
|
3
3
|
import {mongoose, MongooseSort, MongooseQueryFilter} from "@drax/common-back";
|
|
4
|
-
import {PaginateOptions, PaginateResult} from "mongoose";
|
|
4
|
+
import {Cursor, PaginateOptions, PaginateResult} from "mongoose";
|
|
5
5
|
import {DeleteResult} from "mongodb";
|
|
6
6
|
import {IDraxFindOptions, IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
7
7
|
import {ITenant, ITenantBase} from "@drax/identity-share";
|
|
@@ -82,7 +82,6 @@ class TenantMongoRepository implements ITenantRepository {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
async find({
|
|
85
|
-
cursor = false,
|
|
86
85
|
limit = 0,
|
|
87
86
|
orderBy = '',
|
|
88
87
|
order = false,
|
|
@@ -101,9 +100,32 @@ class TenantMongoRepository implements ITenantRepository {
|
|
|
101
100
|
MongooseQueryFilter.applyFilters(query, filters)
|
|
102
101
|
|
|
103
102
|
const sort = MongooseSort.applySort(orderBy, order)
|
|
104
|
-
const items: ITenant[] = await TenantModel.find(query).sort(sort)
|
|
103
|
+
const items: ITenant[] = await TenantModel.find(query).limit(limit).sort(sort)
|
|
105
104
|
return items
|
|
106
105
|
}
|
|
106
|
+
|
|
107
|
+
async findCursor({
|
|
108
|
+
limit = 0,
|
|
109
|
+
orderBy = '',
|
|
110
|
+
order = false,
|
|
111
|
+
search = '',
|
|
112
|
+
filters = []
|
|
113
|
+
}: IDraxFindOptions): Promise<Cursor> {
|
|
114
|
+
console.log("TenantMongoRepository.findCursor called")
|
|
115
|
+
const query = {}
|
|
116
|
+
|
|
117
|
+
if (search) {
|
|
118
|
+
query['$or'] = [
|
|
119
|
+
{name: new RegExp(search, 'i')},
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
MongooseQueryFilter.applyFilters(query, filters)
|
|
124
|
+
|
|
125
|
+
const sort = MongooseSort.applySort(orderBy, order)
|
|
126
|
+
|
|
127
|
+
return TenantModel.find(query).limit(limit).sort(sort).cursor() as Cursor;
|
|
128
|
+
}
|
|
107
129
|
}
|
|
108
130
|
|
|
109
131
|
export default TenantMongoRepository
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
10
10
|
import {DeleteResult, MongoServerError} from "mongodb";
|
|
11
11
|
import type {IUserRepository} from "../../interfaces/IUserRepository";
|
|
12
|
-
import {PaginateResult} from "mongoose";
|
|
12
|
+
import {Cursor, PaginateResult} from "mongoose";
|
|
13
13
|
import RoleMongoRepository from "./RoleMongoRepository.js";
|
|
14
|
-
import {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
14
|
+
import {IDraxFindOptions, IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
15
|
+
import {IRole} from "@drax/identity-share";
|
|
15
16
|
|
|
16
17
|
class UserMongoRepository implements IUserRepository {
|
|
17
18
|
private roleRepository: RoleMongoRepository;
|
|
@@ -124,6 +125,52 @@ class UserMongoRepository implements IUserRepository {
|
|
|
124
125
|
return false
|
|
125
126
|
}
|
|
126
127
|
}
|
|
128
|
+
|
|
129
|
+
async find({
|
|
130
|
+
limit = 0,
|
|
131
|
+
orderBy = '',
|
|
132
|
+
order = false,
|
|
133
|
+
search = '',
|
|
134
|
+
filters = []
|
|
135
|
+
}: IDraxFindOptions): Promise<IUser[]> {
|
|
136
|
+
|
|
137
|
+
const query = {}
|
|
138
|
+
|
|
139
|
+
if (search) {
|
|
140
|
+
query['$or'] = [
|
|
141
|
+
{name: new RegExp(search, 'i')},
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
MongooseQueryFilter.applyFilters(query, filters)
|
|
146
|
+
|
|
147
|
+
const sort = MongooseSort.applySort(orderBy, order)
|
|
148
|
+
|
|
149
|
+
return await UserModel.find(query).populate(['role','tenant']).limit(limit).sort(sort)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async findCursor({
|
|
153
|
+
limit = 0,
|
|
154
|
+
orderBy = '',
|
|
155
|
+
order = false,
|
|
156
|
+
search = '',
|
|
157
|
+
filters = []
|
|
158
|
+
}: IDraxFindOptions): Promise<Cursor> {
|
|
159
|
+
console.log("RoleMongoRepository.findCursor called")
|
|
160
|
+
const query = {}
|
|
161
|
+
|
|
162
|
+
if (search) {
|
|
163
|
+
query['$or'] = [
|
|
164
|
+
{name: new RegExp(search, 'i')},
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
MongooseQueryFilter.applyFilters(query, filters)
|
|
169
|
+
|
|
170
|
+
const sort = MongooseSort.applySort(orderBy, order)
|
|
171
|
+
|
|
172
|
+
return UserModel.find(query).populate(['role','tenant']).limit(limit).sort(sort).cursor() as Cursor;
|
|
173
|
+
}
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
export default UserMongoRepository
|
package/src/routes/RoleRoutes.ts
CHANGED
|
@@ -8,6 +8,8 @@ async function RoleRoutes(fastify, options) {
|
|
|
8
8
|
|
|
9
9
|
fastify.get('/api/permissions', (req,rep) => controller.permissions(req,rep))
|
|
10
10
|
|
|
11
|
+
fastify.get('/api/roles/export', (req,rep) => controller.export(req,rep) )
|
|
12
|
+
|
|
11
13
|
fastify.get('/api/roles/search', (req,rep) => controller.search(req,rep))
|
|
12
14
|
|
|
13
15
|
fastify.get('/api/roles/:id', (req,rep) => controller.findById(req,rep))
|
package/src/routes/UserRoutes.ts
CHANGED
|
@@ -8,6 +8,8 @@ async function UserRoutes(fastify, options) {
|
|
|
8
8
|
|
|
9
9
|
fastify.get('/api/me', (req,rep) => controller.me(req,rep))
|
|
10
10
|
|
|
11
|
+
fastify.get('/api/users/export', (req,rep) => controller.export(req,rep) )
|
|
12
|
+
|
|
11
13
|
fastify.get('/api/users', (req,rep) => controller.paginate(req,rep))
|
|
12
14
|
|
|
13
15
|
fastify.post('/api/users', (req,rep) => controller.create(req,rep))
|