top.ts 881 B

1234567891011121314151617181920212223242526272829
  1. import { requiredScopes } from '@growi/slack';
  2. import { Controller, Get, Inject, View } from '@tsed/common';
  3. import readPkgUp from 'read-pkg-up';
  4. import { InstallerService } from '~/services/InstallerService';
  5. const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
  6. @Controller('/')
  7. export class TopCtrl {
  8. @Inject()
  9. installerService: InstallerService;
  10. @Get('/')
  11. @View('top.ejs')
  12. // biome-ignore lint/suspicious/noExplicitAny: ignore
  13. async getTopPage(): Promise<any> {
  14. const url = await this.installerService.installer.generateInstallUrl({
  15. // Add the scopes your app needs
  16. scopes: requiredScopes,
  17. });
  18. // use await import in order to avoid typescript-eslint error
  19. const readPkgUpResult = await readPkgUp();
  20. const growiBotVersion = readPkgUpResult?.packageJson.version;
  21. return { url, isOfficialMode, growiBotVersion };
  22. }
  23. }