top.ts 957 B

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