top.ts 735 B

123456789101112131415161718192021222324252627282930
  1. import {
  2. Controller, Get, Inject, View,
  3. } from '@tsed/common';
  4. import { requiredScopes } from '@growi/slack';
  5. import { InstallerService } from '~/services/InstallerService';
  6. const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
  7. const fs = require('fs');
  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. const growiBotVersion = JSON.parse(fs.readFileSync('../../package.json', 'utf8')).version;
  20. return { url, isOfficialMode, growiBotVersion };
  21. }
  22. }