InstallerService.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {
  2. Installation, InstallationQuery, InstallationStore, InstallProvider,
  3. } from '@slack/oauth';
  4. import { Service } from '@tsed/di';
  5. const installationStore: InstallationStore = {
  6. storeInstallation: async(installation: Installation<'v1' | 'v2', boolean>) => {
  7. },
  8. fetchInstallation: async(installQuery: InstallationQuery<boolean>) => {
  9. const installation: Installation<'v1' | 'v2', boolean> = {
  10. team: undefined,
  11. enterprise: undefined,
  12. user: {
  13. id: '',
  14. token: undefined,
  15. scopes: undefined,
  16. },
  17. };
  18. return installation;
  19. },
  20. };
  21. @Service()
  22. export class InstallerService {
  23. installer: InstallProvider;
  24. $onInit(): Promise<any> | void {
  25. const clientId = process.env.SLACK_CLIENT_ID;
  26. const clientSecret = process.env.SLACK_CLIENT_SECRET;
  27. const stateSecret = process.env.SLACK_INSTALLPROVIDER_STATE_SECRET;
  28. if (clientId === undefined) {
  29. throw new Error('The environment variable \'SLACK_CLIENT_ID\' must be defined.');
  30. }
  31. if (clientSecret === undefined) {
  32. throw new Error('The environment variable \'SLACK_CLIENT_SECRET\' must be defined.');
  33. }
  34. this.installer = new InstallProvider({
  35. clientId,
  36. clientSecret,
  37. stateSecret,
  38. // installationStore,
  39. });
  40. }
  41. }