top.ts 830 B

1234567891011121314151617181920212223242526272829303132
  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. import { InstallerService } from '~/services/InstallerService';
  7. const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
  8. @Controller('/')
  9. export class TopCtrl {
  10. @Inject()
  11. installerService: InstallerService;
  12. @Get('/')
  13. @View('top.ejs')
  14. async getTopPage(): Promise<any> {
  15. const url = await this.installerService.installer.generateInstallUrl({
  16. // Add the scopes your app needs
  17. scopes: requiredScopes,
  18. });
  19. // use await import in order to avoid typescript-eslint error
  20. const readPkgUpResult = await readPkgUp();
  21. const growiBotVersion = readPkgUpResult?.packageJson.version;
  22. return { url, isOfficialMode, growiBotVersion };
  23. }
  24. }