This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixes merge conflicts with origin/dev
- Loading branch information
Showing
26 changed files
with
9,253 additions
and
1,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ data/* | |
!data/.gitkeep | ||
cloc_output.txt | ||
tree_out.txt | ||
|
||
#don't track our super secret speckle stuff™ file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github", | ||
"@semantic-release/npm", | ||
["@semantic-release/exec", { | ||
"publishCmd": "bash deploy.sh ${nextRelease.version}" | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const winston = require( '../../../config/logger' ) | ||
|
||
const User = require( '../../../models/User' ) | ||
|
||
module.exports = function ( req, res ) { | ||
User.find( {}, '-password' ) | ||
.then( myUsers => { | ||
if ( !myUsers ) throw new Error( 'no user found.' ) | ||
res.send( { success: true, resource: myUsers } ) | ||
} ) | ||
.catch( err => { | ||
winston.error( JSON.stringify( err ) ) | ||
res.status( 400 ) | ||
res.send( { success: false, message: err.toString() } ) | ||
} ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict' | ||
const winston = require( '../../../config/logger' ) | ||
|
||
const User = require( '../../../models/User' ) | ||
|
||
// Used only to grant other users admin role | ||
module.exports = function ( req, res ) { | ||
// if (req.params.userId === req.user._id.toString()) { | ||
// return res.status(400).send({ success: false, message: 'Why would you want to change your own role? Sneaky.' }) | ||
// } | ||
User.findOne( { _id: req.params.userId }, '-password' ) | ||
.then( user => { | ||
//make sure we have a valid request | ||
if ( !user ) throw new Error( 'no user found.' ) | ||
if ( req.body.name == null || | ||
req.body.surname == null || | ||
req.body.company == null || | ||
req.body.email == null || | ||
req.body.role == null || | ||
req.body.archived == null | ||
) { throw new Error( 'Request body is missing required field' ) } | ||
|
||
//update fields | ||
let fields = [ 'name', 'surname', 'company', 'email', 'role', 'archived' ] | ||
fields.forEach( field => { | ||
updateField( user, req.body, field ) | ||
} ) | ||
return user.save() | ||
} ) | ||
.then( () => { | ||
res.send( { success: true, message: 'User profile updated.' } ) | ||
} ) | ||
.catch( err => { | ||
winston.error( JSON.stringify( err ) ) | ||
res.status( 400 ) | ||
res.send( { success: false, message: err.toString() } ) | ||
} ) | ||
} | ||
|
||
function updateField( user, body, field ){ | ||
if ( user[field] != body[field] ){ | ||
user[field] = body[field] | ||
user.markModified( field ) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = ( req, res, next ) => { | ||
if ( req.user.role==="admin" ) next() | ||
else return res.status( 401 ).send( "Only admins can access this route" ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const winston = require( '../../../config/logger' ) | ||
const q2m = require( 'query-to-mongo' ) | ||
const Project = require( '../../../models/Project' ) | ||
|
||
module.exports = ( req, res ) => { | ||
let query = q2m( req.query ) | ||
Project.find( { sort: query.options.sort, skip: query.options.skip, limit: query.options.limit } ) | ||
.then( resources => { | ||
res.send( { success: true, resources: resources } ) | ||
} ) | ||
.catch( err => { | ||
winston.error( JSON.stringify( err ) ) | ||
res.status( err.message.indexOf( 'authorised' ) >= 0 ? 401 : 404 ) | ||
res.send( { success: false, message: err.message, streamId: req.streamId } ) | ||
} ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const winston = require( '../../../config/logger' ) | ||
const q2m = require( 'query-to-mongo' ) | ||
const DataStream = require( '../../../models/DataStream' ) | ||
|
||
module.exports = ( req, res ) => { | ||
winston.debug( 'Getting *all* streams.' ) | ||
let query = q2m( req.query ) | ||
|
||
let finalCriteria = {} | ||
|
||
// perpare array for $and coming from url params | ||
// delete populate permission field if present, as it hijacks the actual query criteria | ||
if ( query.criteria.populatePermissions ) delete query.criteria.populatePermissions | ||
let andCrit = Object.keys( query.criteria ).map( key => { | ||
let crit = {} | ||
crit[key] = query.criteria[key] | ||
return crit | ||
} ) | ||
|
||
// if we actually have any query params, include them | ||
if ( andCrit.length !== 0 ) finalCriteria.$and = andCrit | ||
|
||
DataStream.find( finalCriteria, query.options.fields, { sort: query.options.sort, skip: query.options.skip, limit: query.options.limit } ) | ||
.then( myStreams => { | ||
let resources = myStreams | ||
let streams = [] | ||
resources.forEach( ( stream, i ) => { | ||
streams.push( stream.toObject() ) | ||
if ( streams[i].objects ) streams[i].objects = streams[i].objects.map( o => { return { _id: o.toString(), type: 'Placeholder' } } ) | ||
} ) | ||
|
||
res.send( { success: true, message: 'Master stream list returned.', resources: streams } ) | ||
} ) | ||
.catch( err => { | ||
winston.error( JSON.stringify( err ) ) | ||
res.status( 400 ) | ||
res.send( { success: false, message: 'Something failed.' } ) | ||
} ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.