Răsfoiți Sursa

implement ejs

itizawa 4 ani în urmă
părinte
comite
6ce3d7265e

+ 8 - 0
packages/slackbot-proxy/src/Server.ts

@@ -88,6 +88,14 @@ const helmetOptions = isProduction ? {} : {
   exclude: [
   exclude: [
     '**/*.spec.ts',
     '**/*.spec.ts',
   ],
   ],
+  viewsDir: `${rootDir}/views`,
+  views: {
+    root: `${rootDir}/views`,
+    viewEngine: 'ejs',
+    extensions: {
+      ejs: 'ejs',
+    },
+  },
 })
 })
 export class Server {
 export class Server {
 
 

+ 1 - 1
packages/slackbot-proxy/src/controllers/privacy.ts

@@ -4,7 +4,7 @@ import { Request, Response } from 'express';
 const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
 const isOfficialMode = process.env.OFFICIAL_MODE === 'true';
 
 
 @Controller('/privacy')
 @Controller('/privacy')
-export class SlackCtrl {
+export class PrivacyCtrl {
 
 
   constructor(router: PlatformRouter) {
   constructor(router: PlatformRouter) {
     if (isOfficialMode) {
     if (isOfficialMode) {

+ 0 - 21
packages/slackbot-proxy/src/controllers/slack.ts

@@ -53,27 +53,6 @@ export class SlackCtrl {
   @Inject()
   @Inject()
   unregisterService: UnregisterService;
   unregisterService: UnregisterService;
 
 
-  @Get('/install')
-  async install(): Promise<string> {
-    const url = await this.installerService.installer.generateInstallUrl({
-      // Add the scopes your app needs
-      scopes: [
-        'channels:history',
-        'commands',
-        'groups:history',
-        'im:history',
-        'mpim:history',
-        'chat:write',
-        'team:read',
-      ],
-    });
-
-    return `<a href="${url}">`
-      // eslint-disable-next-line max-len
-      + '<img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" />'
-      + '</a>';
-  }
-
   /**
   /**
    * Send command to specified GROWIs
    * Send command to specified GROWIs
    * @param growiCommand
    * @param growiCommand

+ 42 - 0
packages/slackbot-proxy/src/controllers/top.ts

@@ -0,0 +1,42 @@
+import {
+  Controller, Get, Inject, View,
+} from '@tsed/common';
+
+import { InstallerService } from '~/services/InstallerService';
+import loggerFactory from '~/utils/logger';
+
+
+const logger = loggerFactory('slackbot-proxy:controllers:index');
+
+
+@Controller('/')
+export class TopCtrl {
+
+  @Inject()
+  installerService: InstallerService;
+
+  @Get('/')
+  @View('top.ejs')
+  async getTopPage(): Promise<any> {
+    const url = await this.installerService.installer.generateInstallUrl({
+      // Add the scopes your app needs
+      scopes: [
+        'channels:history',
+        'commands',
+        'groups:history',
+        'im:history',
+        'mpim:history',
+        'chat:write',
+        'team:read',
+      ],
+    });
+
+    return { startDate: new Date(), name: 'MyEvent' };
+
+    return `<a href="${url}">`
+      // eslint-disable-next-line max-len
+      + '<img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" />'
+      + '</a>';
+  }
+
+}

+ 4 - 0
packages/slackbot-proxy/src/views/top.ejs

@@ -0,0 +1,4 @@
+<h1><%- name %></h1>
+<div>
+    Start: hoge
+</div>