File tree Expand file tree Collapse file tree 11 files changed +104
-5
lines changed Expand file tree Collapse file tree 11 files changed +104
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ apiVersion: v1
2
2
description : A Helm chart for kube-ts-server
3
3
name : kube-ts-server
4
4
version : 1.0.0
5
- appVersion : 1.5.0
5
+ appVersion : 1.5.2
6
6
home : https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-server
7
7
icon : https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
8
8
sources :
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ replicaCount: 2
6
6
7
7
image :
8
8
repository : kubejs/kube-ts-server
9
- tag : 1.5.0
9
+ tag : 1.5.2
10
10
pullPolicy : Always
11
11
containerPort : 3000
12
12
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
RATE_LIMITER_SKIP_METHODS ,
14
14
RATE_LIMITER_WINDOW_MS ,
15
15
READINESS_CHECK_URL ,
16
+ SEARCH_QUERY_PARAM_NAME ,
16
17
TOO_MANY_REQUEST_MESSAGE ,
17
18
TRUST_PROXY ,
18
19
VERSION_CHECK_URL ,
@@ -72,6 +73,7 @@ export interface ClientConfig {
72
73
readonly verifyTokenQueryParamName : string ;
73
74
readonly resetPasswordUrl : string ;
74
75
readonly resetPasswordTokenQueryParamName : string ;
76
+ readonly searchQueryParamName : string ;
75
77
}
76
78
77
79
export interface HttpConfig {
@@ -101,6 +103,7 @@ const config: HttpConfig = {
101
103
process . env . CLIENT_RESET_PASSWORD_URL ,
102
104
CLIENT_RESET_PASSWORD_URL
103
105
) ,
106
+ searchQueryParamName : getStringValue ( process . env . SEARCH_QUERY_PARAM_NAME , SEARCH_QUERY_PARAM_NAME ) ,
104
107
siteUrl : getStringValue ( process . env . CLIENT_URL , CLIENT_URL ) ,
105
108
verifyEmailUrl : getStringValue (
106
109
process . env . CLIENT_VERIFY_EMAIL_URL ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export const CLIENT_VERIFY_EMAIL_URL = 'http://localhost:9000/verify'; // @note:
12
12
export const CLIENT_VERIFY_TOKEN_QUERY_PARAM_NAME = 'token' ;
13
13
export const CLIENT_RESET_PASSWORD_URL = 'http://localhost:9000/reset-password' ; // @note : this is client url
14
14
export const CLIENT_RESET_PASSWORD_TOKEN_QUERY_PARAM_NAME = 'token' ;
15
+ export const SEARCH_QUERY_PARAM_NAME = 'q' ;
15
16
16
17
export const TOO_MANY_REQUEST_MESSAGE =
17
18
'Too many accounts created from this IP, please try again after an 10 minutes' ;
@@ -45,6 +46,7 @@ export const LOGGLY_SUBDOMAIN = 'your-loggly-subdomain';
45
46
// MODEL
46
47
export const UUID_LENGTH = 36 ;
47
48
export const VARCHAR_LENGTH = 255 ;
49
+ export const SAFE_URL_LENGTH = 2000 ;
48
50
export const TEXT_LENGTH = 65535 ;
49
51
export const KNEX_CLIENT = 'mysql' ;
50
52
export const KNEX_DATABASE = 'test_db' ;
Original file line number Diff line number Diff line change @@ -26,3 +26,4 @@ export const MODULES = '/modules';
26
26
export const UNITS = '/units' ;
27
27
export const COMMENTS = '/comments' ;
28
28
export const DISCOVERY_ITEMS = '/discovery-items' ;
29
+ export const SEARCH = '/search' ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
PERMISSIONS ,
11
11
ROLES ,
12
12
ROOT ,
13
+ SEARCH ,
13
14
USERS ,
14
15
} from '../../../../constants/routes' ;
15
16
import Config from '../../presenterFactory/Config' ;
@@ -20,6 +21,7 @@ import enrolmentsFactory from './routes/enrolments/factory';
20
21
import getDiscoveryItems from './routes/getDiscoveryItems' ;
21
22
import permissionsFactory from './routes/permissions/factory' ;
22
23
import rolesFactory from './routes/roles/factory' ;
24
+ import searchHandler from './routes/searchHandler' ;
23
25
import usersFactory from './routes/users/factory' ;
24
26
import describeApi from './routes/utils/describeApi' ;
25
27
@@ -41,6 +43,7 @@ const apiV1 = (config: Config): Router => {
41
43
router . use ( COURSES , coursesFactory ( config ) ) ;
42
44
router . use ( ENROLMENTS , enrolmentsFactory ( config ) ) ;
43
45
router . use ( DISCOVERY_ITEMS , getDiscoveryItems ( config ) ) ;
46
+ router . get ( SEARCH , searchHandler ( config ) ) ;
44
47
// router.use(MODULES, modulesFactory(config));
45
48
// router.use(UNITS, unitsFactory(config));
46
49
// TODO: add route for uploading /avatar
Original file line number Diff line number Diff line change
1
+ import sendResponse from '@js-items/express/dist/utils/sendResponse' ;
2
+ import { toSnake } from 'convert-keys' ;
3
+ import { OK } from 'http-status-codes' ;
4
+ import Record from 'rulr/Record' ;
5
+ import validateData from 'rulr/validateData' ;
6
+ import { SAFE_URL_LENGTH } from '../../../../../../constants' ;
7
+ import String from '../../../../../../utils/validation/rules/String' ;
8
+ import Config from '../../../../presenterFactory/Config' ;
9
+ import catchErrors from '../../../../utils/errors/catchErrors' ;
10
+
11
+
12
+ const searchHandler = ( config : Config ) =>
13
+ catchErrors ( config , async ( req , res ) => {
14
+ const name = config . appConfig . http . client . searchQueryParamName ;
15
+
16
+ const validationSchema = {
17
+ [ name ] : String ( 0 , SAFE_URL_LENGTH ) ,
18
+ } ;
19
+
20
+ const rules = Record ( validationSchema ) ;
21
+ const value = req . query [ name ] ;
22
+
23
+ const payload : any = { [ name ] :value } ;
24
+
25
+ validateData ( rules ) ( payload ) ;
26
+
27
+ const response = await config . service . search ( {
28
+ query : value
29
+ } ) ;
30
+
31
+ sendResponse ( {
32
+ body : toSnake ( response ) ,
33
+ req,
34
+ res,
35
+ status : OK ,
36
+ } ) ;
37
+ } ) ;
38
+
39
+ export default searchHandler ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import getDiscoveryItemsForHomepage from './functions/getDiscoveryItemsForHomepa
6
6
import hasPermission from './functions/hasPermission' ;
7
7
import assignRolePermission from './functions/roles/assignRolePermission' ;
8
8
import revokeRolePermission from './functions/roles/revokeRolePermission' ;
9
+ import search from './functions/search' ;
9
10
import assignUserRole from './functions/users/assignUserRole' ;
10
11
import revokeUserRole from './functions/users/revokeUserRole' ;
11
12
@@ -29,6 +30,7 @@ export default (config: FactoryConfig) => ({
29
30
revokeUserRole : revokeUserRole ( config ) ,
30
31
rolePermission : config . repo . rolePermission ,
31
32
roles : config . repo . roles ,
33
+ search : search ( config ) ,
32
34
sendEmail : config . repo . sendEmail ,
33
35
userRole : config . repo . userRole ,
34
36
users : config . repo . users ,
Original file line number Diff line number Diff line change 1
1
import { Filter , ItemNotFoundError } from '@js-items/foundation' ;
2
2
import _pluck from 'ramda/src/pluck' ;
3
3
import Course from '../../../types/items/Course' ;
4
+ import getVisibleUserProperties from '../../../utils/helpers/model/getVisibleUserProperties' ;
4
5
import Config from '../../FactoryConfig' ;
5
6
6
7
export interface Options {
@@ -30,7 +31,7 @@ export default ({ repo }: Config) => async ({ filter }: Options) => {
30
31
course : {
31
32
...course ,
32
33
category,
33
- user,
34
+ user : getVisibleUserProperties ( user ) ,
34
35
} ,
35
36
} ;
36
37
} ;
You can’t perform that action at this time.
0 commit comments