da9224a069
feat: server & stream invites rework Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
31 lines
663 B
JavaScript
31 lines
663 B
JavaScript
const { buildApolloServer } = require('@/app')
|
|
const { Roles, AllScopes } = require('@/modules/core/helpers/mainConstants')
|
|
const { addLoadersToCtx } = require('@/modules/shared')
|
|
|
|
/**
|
|
* Build an ApolloServer instance with an authenticated context
|
|
* @param {string} userId
|
|
* @param {string} role
|
|
* @param {string} scopes
|
|
*/
|
|
function buildAuthenticatedApolloServer(
|
|
userId,
|
|
role = Roles.Server.User,
|
|
scopes = AllScopes
|
|
) {
|
|
return buildApolloServer({
|
|
context: () =>
|
|
addLoadersToCtx({
|
|
auth: true,
|
|
userId,
|
|
role,
|
|
token: 'asd',
|
|
scopes
|
|
})
|
|
})
|
|
}
|
|
|
|
module.exports = {
|
|
buildAuthenticatedApolloServer
|
|
}
|