@openneuro/server 4.3.0-alpha.0 → 4.3.0-alpha.5
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/Dockerfile +1 -1
- package/package.json +2 -3
- package/src/__mocks__/mongoose.js +0 -1
- package/src/app.js +0 -6
- package/src/datalad/snapshots.js +0 -3
- package/src/graphql/resolvers/__tests__/user.spec.js +2 -13
- package/src/graphql/resolvers/dataset.js +0 -4
- package/src/graphql/resolvers/user.js +8 -4
- package/src/libs/orcid.js +0 -2
- package/src/server.js +0 -7
- package/src/__mocks__/mongodb.js +0 -5
package/Dockerfile
CHANGED
|
@@ -20,4 +20,4 @@ HEALTHCHECK --interval=10s --retries=10 CMD curl -f 'http://localhost:8111' || e
|
|
|
20
20
|
ENV NODE_OPTIONS=--max_old_space_size=2048
|
|
21
21
|
|
|
22
22
|
# start server
|
|
23
|
-
CMD ["
|
|
23
|
+
CMD ["node", "-r", "/srv/.pnp.cjs", "/srv/packages/openneuro-server/dist/server.js"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.5",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"ioredis-mock": "^3.8.1",
|
|
90
90
|
"jest": "^26.6.3",
|
|
91
91
|
"mockingoose": "2.11.0",
|
|
92
|
-
"mongo-mock": "3.7.1",
|
|
93
92
|
"nodemon": "^2.0.7",
|
|
94
93
|
"supertest": "^3.0.0",
|
|
95
94
|
"ts-node-dev": "1.1.6",
|
|
@@ -104,5 +103,5 @@
|
|
|
104
103
|
"publishConfig": {
|
|
105
104
|
"access": "public"
|
|
106
105
|
},
|
|
107
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "6ce7aecd560416297947a40014fe246df40a92f5"
|
|
108
107
|
}
|
package/src/app.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* Express app setup
|
|
6
6
|
*/
|
|
7
7
|
import express from 'express'
|
|
8
|
-
import * as Sentry from '@sentry/node'
|
|
9
8
|
import passport from 'passport'
|
|
10
9
|
import config from './config'
|
|
11
10
|
import routes from './routes'
|
|
@@ -28,9 +27,6 @@ export default test => {
|
|
|
28
27
|
|
|
29
28
|
setupPassportAuth()
|
|
30
29
|
|
|
31
|
-
// Sentry must be first to work
|
|
32
|
-
test || app.use(Sentry.Handlers.requestHandler())
|
|
33
|
-
|
|
34
30
|
app.use(passport.initialize())
|
|
35
31
|
|
|
36
32
|
app.use((req, res, next) => {
|
|
@@ -48,8 +44,6 @@ export default test => {
|
|
|
48
44
|
app.use(config.apiPrefix, routes)
|
|
49
45
|
|
|
50
46
|
// error handling --------------------------------------------------\
|
|
51
|
-
// Sentry reporting passes to the next step
|
|
52
|
-
test || app.use(Sentry.Handlers.errorHandler())
|
|
53
47
|
|
|
54
48
|
// Apollo engine setup
|
|
55
49
|
const engineConfig = {
|
package/src/datalad/snapshots.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get snapshots from datalad-service tags
|
|
3
3
|
*/
|
|
4
|
-
import * as Sentry from '@sentry/node'
|
|
5
4
|
import request from 'superagent'
|
|
6
5
|
import { redis, redlock } from '../libs/redis'
|
|
7
6
|
import CacheItem, { CacheType } from '../cache/item'
|
|
@@ -61,7 +60,6 @@ const createIfNotExistsDoi = async (
|
|
|
61
60
|
if (snapshotDoi)
|
|
62
61
|
descriptionFieldUpdates['DatasetDOI'] = `doi:${snapshotDoi}`
|
|
63
62
|
} catch (err) {
|
|
64
|
-
Sentry.captureException(err)
|
|
65
63
|
console.error(err)
|
|
66
64
|
throw new Error('DOI minting failed.')
|
|
67
65
|
}
|
|
@@ -177,7 +175,6 @@ export const createSnapshot = async (
|
|
|
177
175
|
// this avoids inconsistent cache state after failures
|
|
178
176
|
snapshotCache.drop()
|
|
179
177
|
snapshotLock.unlock()
|
|
180
|
-
Sentry.captureException(err)
|
|
181
178
|
return err
|
|
182
179
|
}
|
|
183
180
|
}
|
|
@@ -3,24 +3,13 @@ import { users } from '../user.js'
|
|
|
3
3
|
describe('user resolvers', () => {
|
|
4
4
|
describe('users()', () => {
|
|
5
5
|
it('throws an error for non-admins', () => {
|
|
6
|
-
expect(
|
|
6
|
+
expect(
|
|
7
7
|
users(
|
|
8
8
|
null,
|
|
9
9
|
{ id: '3311cfe8-9764-434d-b80e-1b1ee72c686d' },
|
|
10
10
|
{ userInfo: {} },
|
|
11
11
|
),
|
|
12
|
-
).
|
|
13
|
-
})
|
|
14
|
-
it('admins should be able to override restrictions', () => {
|
|
15
|
-
expect(() =>
|
|
16
|
-
users(
|
|
17
|
-
null,
|
|
18
|
-
{ id: '3311cfe8-9764-434d-b80e-1b1ee72c686d' },
|
|
19
|
-
{
|
|
20
|
-
userInfo: { admin: true },
|
|
21
|
-
},
|
|
22
|
-
),
|
|
23
|
-
).not.toThrowError()
|
|
12
|
+
).rejects.toEqual(new Error('You must be a site admin to retrieve users'))
|
|
24
13
|
})
|
|
25
14
|
})
|
|
26
15
|
})
|
|
@@ -17,7 +17,6 @@ import * as dataladAnalytics from '../../datalad/analytics.js'
|
|
|
17
17
|
import DatasetModel from '../../models/dataset'
|
|
18
18
|
import Deletion from '../../models/deletion'
|
|
19
19
|
import fetch from 'node-fetch'
|
|
20
|
-
import * as Sentry from '@sentry/node'
|
|
21
20
|
import { reviewers } from './reviewer'
|
|
22
21
|
import { UpdatedFile } from '../utils/file.js'
|
|
23
22
|
import { getDatasetWorker } from '../../libs/datalad-service.js'
|
|
@@ -165,7 +164,6 @@ export const deleteFiles = async (
|
|
|
165
164
|
|
|
166
165
|
return true
|
|
167
166
|
} catch (err) {
|
|
168
|
-
Sentry.captureException(err)
|
|
169
167
|
return false
|
|
170
168
|
}
|
|
171
169
|
}
|
|
@@ -187,7 +185,6 @@ export const removeAnnexObject = async (
|
|
|
187
185
|
)
|
|
188
186
|
return true
|
|
189
187
|
} catch (err) {
|
|
190
|
-
Sentry.captureException(err)
|
|
191
188
|
return false
|
|
192
189
|
}
|
|
193
190
|
}
|
|
@@ -208,7 +205,6 @@ export const flagAnnexObject = async (
|
|
|
208
205
|
)
|
|
209
206
|
return true
|
|
210
207
|
} catch (err) {
|
|
211
|
-
Sentry.captureException(err)
|
|
212
208
|
return false
|
|
213
209
|
}
|
|
214
210
|
}
|
|
@@ -13,7 +13,9 @@ export const users = (obj, args, { userInfo }) => {
|
|
|
13
13
|
if (userInfo.admin) {
|
|
14
14
|
return User.find().exec()
|
|
15
15
|
} else {
|
|
16
|
-
|
|
16
|
+
return Promise.reject(
|
|
17
|
+
new Error('You must be a site admin to retrieve users'),
|
|
18
|
+
)
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -21,7 +23,7 @@ export const removeUser = (obj, { id }, { userInfo }) => {
|
|
|
21
23
|
if (userInfo.admin) {
|
|
22
24
|
return User.findByIdAndRemove(id).exec()
|
|
23
25
|
} else {
|
|
24
|
-
|
|
26
|
+
return Promise.reject(new Error('You must be a site admin to remove users'))
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -29,7 +31,9 @@ export const setAdmin = (obj, { id, admin }, { userInfo }) => {
|
|
|
29
31
|
if (userInfo.admin) {
|
|
30
32
|
return User.findOneAndUpdate({ id }, { admin }).exec()
|
|
31
33
|
} else {
|
|
32
|
-
|
|
34
|
+
return Promise.reject(
|
|
35
|
+
new Error('You must be a site admin to modify this value'),
|
|
36
|
+
)
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -37,7 +41,7 @@ export const setBlocked = (obj, { id, blocked }, { userInfo }) => {
|
|
|
37
41
|
if (userInfo.admin) {
|
|
38
42
|
return User.findOneAndUpdate({ id }, { blocked }).exec()
|
|
39
43
|
} else {
|
|
40
|
-
|
|
44
|
+
return Promise.reject(new Error('You must be a site admin to block a user'))
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
package/src/libs/orcid.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Camel case rule is disabled since ORCID API uses snake case variables
|
|
2
2
|
import request from 'request'
|
|
3
3
|
import xmldoc from 'xmldoc'
|
|
4
|
-
import * as Sentry from '@sentry/node'
|
|
5
4
|
import config from '../config'
|
|
6
5
|
|
|
7
6
|
export default {
|
|
@@ -21,7 +20,6 @@ export default {
|
|
|
21
20
|
},
|
|
22
21
|
(err, res) => {
|
|
23
22
|
if (err) {
|
|
24
|
-
Sentry.captureException(err)
|
|
25
23
|
reject({
|
|
26
24
|
message:
|
|
27
25
|
'An unexpected ORCID login failure occurred, please try again later.',
|
package/src/server.js
CHANGED
|
@@ -4,7 +4,6 @@ apm.start({
|
|
|
4
4
|
serviceName: 'openneuro-server',
|
|
5
5
|
})
|
|
6
6
|
|
|
7
|
-
import * as Sentry from '@sentry/node'
|
|
8
7
|
import { createServer } from 'http'
|
|
9
8
|
import mongoose from 'mongoose'
|
|
10
9
|
import subscriptionServerFactory from './libs/subscription-server.js'
|
|
@@ -26,12 +25,6 @@ const redisConnectionSetup = async () => {
|
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
Sentry.init({
|
|
30
|
-
dsn: 'https://ba0c58863b3e40a2a412132bfd2711ea@sentry.io/251076',
|
|
31
|
-
release: version,
|
|
32
|
-
environment: config.sentry.ENVIRONMENT,
|
|
33
|
-
})
|
|
34
|
-
|
|
35
28
|
mongoose.connect(config.mongo.url, {
|
|
36
29
|
useNewUrlParser: true,
|
|
37
30
|
dbName: config.mongo.dbName,
|