Skip to content

Commit

Permalink
Merge branch 'UAT' into v1.11.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/config/account.js
#	src/resources/datarequest/datarequest.controller.js
#	src/resources/datarequest/utils/__tests__/datarequest.util.test.js
#	src/resources/datarequest/utils/datarequest.util.js
#	src/resources/stats/stats.router.js
#	src/resources/utilities/constants.util.js
  • Loading branch information
Paul McCafferty committed Apr 12, 2021
2 parents 8823ec2 + e28dd99 commit 16f60cd
Show file tree
Hide file tree
Showing 57 changed files with 6,777 additions and 1,188 deletions.
2 changes: 2 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ steps:
'${_REGION}',
'--allow-unauthenticated',
]
- name: 'node'
args: ['npm', 'install']
- name: 'node'
args: ['npm', 'test']
env:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"@google-cloud/storage": "^5.3.0",
"@sendgrid/mail": "^7.1.0",
"@sentry/node": "^5.29.0",
"ajv": "^7.1.1",
"async": "^3.2.0",
"await-to-js": "^2.1.1",
"axios": "0.19.2",
"axios": "0.21.1",
"axios-retry": "^3.1.9",
"base64url": "^3.0.1",
"bcrypt": "^5.0.0",
Expand All @@ -28,6 +29,7 @@
"express-session": "^1.17.1",
"express-validator": "^6.6.1",
"faker": "^5.3.1",
"form-data": "^3.0.0",
"googleapis": "^55.0.0",
"jose": "^2.0.2",
"jsonwebtoken": "^8.5.1",
Expand Down
9 changes: 7 additions & 2 deletions src/config/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ connectToDatabase();

// (optional) only made for logging and
// bodyParser, parses the request body to be a readable json format
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.use(bodyParser.json({ limit: '10mb', extended: true }));
app.use(bodyParser.urlencoded({ limit: '10mb', extended: false }));

app.use(logger('dev'));
app.use(cookieParser());
app.use(passport.initialize());
Expand Down Expand Up @@ -214,6 +216,7 @@ app.use('/api/v1/coursecounter', require('../resources/course/coursecounter.rout

app.use('/api/v1/discourse', require('../resources/discourse/discourse.route'));

app.use('/api/v1/dataset-onboarding', require('../resources/dataset/datasetonboarding.route'));
app.use('/api/v1/datasets', require('../resources/dataset/v1/dataset.route'));
app.use('/api/v2/datasets', require('../resources/dataset/v2/dataset.route'));

Expand All @@ -226,6 +229,8 @@ app.use('/api/v1/analyticsdashboard', require('../resources/googleanalytics/goog

app.use('/api/v1/help', require('../resources/help/help.router'));

app.use('/api/v2/filters', require('../resources/filters/filters.route'));

initialiseAuthentication(app);

// launch our backend into a port
Expand Down
33 changes: 0 additions & 33 deletions src/resources/account/account.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,6 @@ router.get('/admin', passport.authenticate('jwt'), utils.checkIsInRole(ROLES.Adm
return result;
});

/**
* {get} /api/v1/accounts/admin/collections
*
* Returns list of all collections.
*/
router.get('/admin/collections', passport.authenticate('jwt'), utils.checkIsInRole(ROLES.Admin), async (req, res) => {
var result;
var startIndex = 0;
var maxResults = 25;

if (req.query.startIndex) {
startIndex = req.query.startIndex;
}
if (req.query.maxResults) {
maxResults = req.query.maxResults;
}

var q = Collections.aggregate([
{ $lookup: { from: 'tools', localField: 'authors', foreignField: 'id', as: 'persons' } },
{ $sort: { updatedAt: -1 } },
]); //.skip(parseInt(startIndex)).limit(parseInt(maxResults));
q.exec((err, data) => {
if (err) return res.json({ success: false, error: err });

data.map(dat => {
dat.persons = helper.hidePrivateProfileDetails(dat.persons);
});
result = res.json({ success: true, data: data });
});

return result;
});

/**
* {get} /api/v1/accounts
*
Expand Down
10 changes: 9 additions & 1 deletion src/resources/auth/auth.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ router.get('/status', function (req, res, next) {
return { ...publisher, type, roles };
});
}

let adminArray = teams.filter(team => team.type === 'admin');
let teamArray = teams
.filter(team => team.type !== 'admin')
.sort(function (a, b) {
return a.name.toUpperCase() < b.name.toUpperCase() ? -1 : a.name.toUpperCase() > b.name.toUpperCase() ? 1 : 0;
});

// 2. Return user info
return res.json({
success: true,
Expand All @@ -88,7 +96,7 @@ router.get('/status', function (req, res, next) {
id: req.user.id,
name: req.user.firstname + ' ' + req.user.lastname,
loggedIn: true,
teams,
teams: [...adminArray, ...teamArray],
provider: req.user.provider,
advancedSearchRoles: req.user.advancedSearchRoles,
acceptedAdvancedSearchTerms: req.user.acceptedAdvancedSearchTerms,
Expand Down
7 changes: 6 additions & 1 deletion src/resources/base/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export default class Repository {
//Build query
let queryObj = { ...query };

// Population from query
if(query.populate) {
populate = query.populate.split(',').join(' ');
}

// Filtering
const excludedFields = ['page', 'sort', 'limit', 'fields', 'count', 'search', 'expanded'];
const excludedFields = ['page', 'sort', 'limit', 'fields', 'count', 'search', 'expanded', 'populate'];
excludedFields.forEach(el => delete queryObj[el]);

// Keyword search
Expand Down
Loading

0 comments on commit 16f60cd

Please sign in to comment.