fix slop code, by slop 066543611 hours ago 131 lines · 5.4 KB 1 import path from ' node:path ' ; 2 3 import type { Database 4 import { ApolloDriver , type 5 import { 6 MiddlewareConsumer , 7 Module , 8 NestModule , 9 RequestMethod , 10 } from ' @nestjs/common ' ; 11 import { GraphQLModule } 12 import type { Request , 13 import { GraphQLFormattedError } 14 import { GraphQLError } 15 16 import { DATABASE , DatabaseModule 17 import { DomainError } 18 import { graphqlErrorType } 19 import { createLoaders } 20 import { githubValidationPlugin } 21 import { IssuesModule } 22 import { PullRequestsModule } 23 import { ReleasesModule } 24 import { RepositoriesModule } 25 import { GithubAuthMiddleware } 26 import { IssueCommentResolver } 27 import { IssueMutationsResolver } 28 import { IssueMutationsService } 29 import { PullRequestMutationsResolver } 30 import { PullRequestMutationsService } 31 import { RepositoryReleasesResolver } 32 import { ReleaseNodesService } 33 import { RepositoryMutationsResolver } 34 import { RepositoryMutationsService } 35 import { SearchResolver } 36 import { GithubSearchService } 37 import { ViewerResolver } 38 import { ViewerService } 39 import { OauthModule } 40 import { GithubGitModule } 41 import { GithubIssuesModule } 42 import { MetaModule } 43 import { GithubPullsModule } 44 import { GithubReleasesModule } 45 import { ReposModule } 46 import { UsersModule } 47 48 @ Module ( { 49 imports : [ 50 GraphQLModule . forRootAsync < ApolloDriverConfig 51 driver : ApolloDriver , 52 imports : [ DatabaseModule ] , 53 inject : [ DATABASE ] , 54 useFactory : ( db : 55 path : ' /graphql ' , 56 useGlobalPrefix : true , 57 autoSchemaFile : 58 process . env . NODE_ENV 59 ? true 60 : path . join ( 61 sortSchema : true , 62 buildSchemaOptions : { 63 dateScalarMode : ' isoDate ' , 64 numberScalarMode : ' integer ' , 65 } , 66 introspection : true , 67 // GitHub's validation lets fragments on different types share a field name with different types, which gh relies on; githubValidationPlugin validates instead. 68 dangerouslyDisableValidation : true , 69 plugins : [ githubValidationPlugin ] , 70 graphiql : { 71 url : ' /api/graphql ' , 72 } , 73 context : ( { req 74 req , 75 res , 76 loaders : createLoaders ( db 77 } ) , 78 formatError : ( formatted : 79 const original = 80 error instanceof GraphQLError 81 if ( ! ( original 82 return { 83 type : graphqlErrorType ( original 84 path : formatted . path 85 locations : formatted . locations 86 message : original . message 87 } ; 88 } , 89 } ) , 90 } ) , 91 MetaModule , 92 UsersModule , 93 ReposModule , 94 GithubIssuesModule , 95 GithubPullsModule , 96 IssuesModule , 97 RepositoriesModule , 98 OauthModule , 99 PullRequestsModule , 100 ReleasesModule , 101 GithubReleasesModule , 102 GithubGitModule , 103 ] , 104 providers : [ 105 ViewerResolver , 106 IssueCommentResolver , 107 SearchResolver , 108 IssueMutationsResolver , 109 RepositoryMutationsResolver , 110 PullRequestMutationsResolver , 111 RepositoryReleasesResolver , 112 ViewerService , 113 GithubSearchService , 114 IssueMutationsService , 115 RepositoryMutationsService , 116 PullRequestMutationsService , 117 ReleaseNodesService , 118 ] , 119 } ) 120 export class GithubModule 121 configure ( consumer : 122 consumer 123 . apply ( GithubAuthMiddleware ) 124 . forRoutes ( 125 { path : ' graphql ' , 126 { path : ' v3 ' , 127 { path : ' v3/*path ' , 128 { path : ' uploads/*path ' , 129 ) ; 130 } 131 }
}
from
'
@ghost/db
'
;
ApolloDriverConfig
}
from
'
@nestjs/apollo
'
;
from
'
@nestjs/graphql
'
;
Response
}
from
'
express
'
;
from
'
graphql
'
;
from
'
graphql/error
'
;
}
from
'
../database/database.module.js
'
;
from
'
../domain/errors.js
'
;
from
'
../lib/github/error-type.js
'
;
from
'
../lib/github/loaders.js
'
;
from
'
../lib/github/validation.js
'
;
from
'
../resources/issues/issues.module.js
'
;
from
'
../resources/pull-requests/pull-requests.module.js
'
;
from
'
../resources/releases/releases.module.js
'
;
from
'
../resources/repositories/repositories.module.js
'
;
from
'
./auth/github-auth.middleware.js
'
;
from
'
./graphql/resolvers/issue-comment/issue-comment.resolver.js
'
;
from
'
./graphql/resolvers/issue-mutations/issue-mutations.resolver.js
'
;
from
'
./graphql/resolvers/issue-mutations/issue-mutations.service.js
'
;
from
'
./graphql/resolvers/pull-request-mutations/pull-request-mutations.resolver.js
'
;
from
'
./graphql/resolvers/pull-request-mutations/pull-request-mutations.service.js
'
;
from
'
./graphql/resolvers/release/release.resolver.js
'
;
from
'
./graphql/resolvers/release/release-nodes.service.js
'
;
from
'
./graphql/resolvers/repository-mutations/repository-mutations.resolver.js
'
;
from
'
./graphql/resolvers/repository-mutations/repository-mutations.service.js
'
;
from
'
./graphql/resolvers/search/search.resolver.js
'
;
from
'
./graphql/resolvers/search/search.service.js
'
;
from
'
./graphql/resolvers/viewer/viewer.resolver.js
'
;
from
'
./graphql/resolvers/viewer/viewer.service.js
'
;
from
'
./oauth/oauth.module.js
'
;
from
'
./rest/git/git.module.js
'
;
from
'
./rest/issues/issues.module.js
'
;
from
'
./rest/meta/meta.module.js
'
;
from
'
./rest/pulls/pulls.module.js
'
;
from
'
./rest/releases/releases.module.js
'
;
from
'
./rest/repos/repos.module.js
'
;
from
'
./rest/users/users.module.js
'
;
>
(
{
Database
)
=>
(
{
===
'
production
'
import
.
meta
.
dirname
,
'
../../github.schema.gql
'
)
,
,
res
}
:
{
req
:
Request
;
res
:
Response
})
=>
(
{
)
,
GraphQLFormattedError
,
error
:
unknown
)
=>
{
?
error
.
cause
:
undefined
;
instanceof
DomainError
))
return
formatted
;
.
status
)
,
,
,
,
implements
NestModule
{
MiddlewareConsumer
)
{
method
:
RequestMethod
.
ALL
}
,
method
:
RequestMethod
.
ALL
}
,
method
:
RequestMethod
.
ALL
}
,
method
:
RequestMethod
.
ALL
}
,