add ssh setup7881b1a21 days ago94 lines · 3.6 KB | 1 | import type { Database } from '@ghost/db'; |
| 2 | import { Module } |
| 3 | import { ConfigModule, ConfigService |
| 4 | import { AuthModule } |
| 5 | |
| 6 | import { AppController } |
| 7 | import { AppService } |
| 8 | import { DATABASE, DatabaseModule |
| 9 | import { GitModule } |
| 10 | import { createAuth } |
| 11 | import { |
| 12 | emailVerificationEnabled, |
| 13 | MailModule, |
| 14 | mailConfigured, |
| 15 | } from './mail/mail.module.js'; |
| 16 | import { MailService } |
| 17 | import { EmailsModule } |
| 18 | import { GpgKeysModule } |
| 19 | import { IssuesModule } |
| 20 | import { PullRequestsModule } |
| 21 | import { RepositoriesModule } |
| 22 | import { SshKeysModule } |
| 23 | import { UserModule } |
| 24 | import { BranchesService } |
| 25 | import { RepositoryAccessService } |
| 26 | import { WalService } |
| 27 | import { S3Service } |
| 28 | import { AppStatsService } |
| 29 | import { UsersService } |
| 30 | |
| 31 | @Module({ |
| 32 | imports: [ |
| 33 | ConfigModule.forRoot({ |
| 34 | isGlobal: true, |
| 35 | // `.env` interpolates values (e.g. BETTER_AUTH_URL=http://localhost:${API_PORT}), which dotenv does not expand on its own. |
| 36 | expandVariables: true, |
| 37 | envFilePath: ['.env.local', |
| 38 | }), |
| 39 | DatabaseModule, |
| 40 | MailModule, |
| 41 | AuthModule.forRootAsync({ |
| 42 | imports: [DatabaseModule, |
| 43 | inject: [DATABASE, |
| 44 | useFactory: (db: |
| 45 | auth: createAuth(db |
| 46 | secret: config.getOrThrow |
| 47 | baseURL: config.getOrThrow |
| 48 | trustedOrigins: config |
| 49 | .get<string>( |
| 50 | .split(',') |
| 51 | .map((origin) |
| 52 | .filter(Boolean), |
| 53 | cookieDomain: config.get |
| 54 | webAppUrl: config.get |
| 55 | sendChangeEmail: mailConfigured(config |
| 56 | ? ({ email, |
| 57 | mail.sendChangeEmailEmail(email |
| 58 | name, |
| 59 | newEmail, |
| 60 | approveUrl: url, |
| 61 | }) |
| 62 | : undefined, |
| 63 | sendResetPassword: mailConfigured(config |
| 64 | ? ({ email, |
| 65 | mail.sendResetPasswordEmail(email |
| 66 | : undefined, |
| 67 | sendVerificationEmail: emailVerificationEnabled(config |
| 68 | ? ({ email, |
| 69 | mail.sendVerificationEmail(email |
| 70 | : undefined, |
| 71 | }), |
| 72 | }), |
| 73 | }), |
| 74 | RepositoriesModule, |
| 75 | PullRequestsModule, |
| 76 | IssuesModule, |
| 77 | EmailsModule, |
| 78 | GpgKeysModule, |
| 79 | SshKeysModule, |
| 80 | GitModule, |
| 81 | UserModule, |
| 82 | ], |
| 83 | controllers: [AppController], |
| 84 | providers: [ |
| 85 | AppService, |
| 86 | AppStatsService, |
| 87 | UsersService, |
| 88 | S3Service, |
| 89 | WalService, |
| 90 | BranchesService, |
| 91 | RepositoryAccessService, |
| 92 | ], |
| 93 | }) |
| 94 | export class AppModule |
from
'
@nestjs/common
'
;
}
from
'
@nestjs/config
'
;
from
'
@thallesp/nestjs-better-auth
'
;
from
'
./app.controller.js
'
;
from
'
./app.service.js
'
;
}
from
'
./database/database.module.js
'
;
from
'
./git/git.module.js
'
;
from
'
./lib/auth.js
'
;
from
'
./mail/mail.service.js
'
;
from
'
./resources/emails/emails.module.js
'
;
from
'
./resources/gpg-keys/gpg-keys.module.js
'
;
from
'
./resources/issues/issues.module.js
'
;
from
'
./resources/pull-requests/pull-requests.module.js
'
;
from
'
./resources/repositories/repositories.module.js
'
;
from
'
./resources/ssh-keys/ssh-keys.module.js
'
;
from
'
./resources/user/user.module.js
'
;
from
'
./services/git/branches/branches.service.js
'
;
from
'
./services/git/repository-access/repository-access.service.js
'
;
from
'
./services/git/wal/wal.service.js
'
;
from
'
./services/s3/s3.service.js
'
;
from
'
./services/stats/app-stats.service.js
'
;
from
'
./services/users/users.service.js
'
;
'
.env
'
,
'
../../.env
'
]
,
MailModule
]
,
ConfigService
,
MailService
]
,
Database
,
config
:
ConfigService
,
mail
:
MailService
)
=>
(
{
,
{
<
string
>
(
'
BETTER_AUTH_SECRET
'
)
,
<
string
>
(
'
BETTER_AUTH_URL
'
)
,
'
AUTH_TRUSTED_ORIGINS
'
,
'
http://localhost:3000
'
)
=>
origin
.
trim
())
<
string
>
(
'
AUTH_COOKIE_DOMAIN
'
)
,
<
string
>
(
'
WEB_APP_URL
'
,
'
http://localhost:3000
'
)
,
)
name
,
newEmail
,
url
}
)
=>
,
{
)
name
,
url
}
)
=>
,
{
name
,
resetUrl
:
url
}
)
)
name
,
url
}
)
=>
,
{
name
,
verifyUrl
:
url
}
)
{}