aboutsummaryrefslogtreecommitdiffstats
path: root/app/Controllers/Http/StaticController.js
blob: 114e369555ab432151a19abf4eeacd25b4172406 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
 * Controller for routes with static responses
 */
const Helpers = use('Helpers');
const fs = require('fs-extra');
const path = require('path');

class StaticController {
  // Enable all features
  features({
    response,
  }) {
    return response.send({
      needToWaitToProceed: false,
      isSpellcheckerPremiumFeature: false,
      isSpellcheckerIncludedInCurrentPlan: true,
      isServiceProxyEnabled: true,
      isServiceProxyIncludedInCurrentPlan: true,
      isServiceProxyPremiumFeature: true,
      isWorkspacePremiumFeature: false,
      isWorkspaceEnabled: true,
      isAnnouncementsEnabled: true,
      isSettingsWSEnabled: false,
      isServiceLimitEnabled: false,
      serviceLimitCount: 0,
      isCommunityRecipesPremiumFeature: false,
      isCommunityRecipesIncludedInCurrentPlan: true,
      isCustomUrlIncludedInCurrentPlan: true,
      isMagicBarEnabled: true,
      isTeamManagementIncludedInCurrentPlan: true,
      isTodosEnabled: true,
      isTodosIncludedInCurrentPlan: true,
      defaultTrialPlan: 'franz-pro-yearly',
      subscribeURL: 'https://getferdi.com',
      planSelectionURL: 'https://getferdi.com',
      hasInlineCheckout: true,
      isPlanSelectionEnabled: false,
      isTrialStatusBarEnabled: false,
      canSkipTrial: true,
      pricingConfig: {
        currency: '$',
        currencyID: 'USD',
        plans: {
          personal: {
            monthly: {
              id: 'ferdi-free',
              price: 0,
              billed: 0,
            },
            yearly: {
              id: 'ferdi-completely-free',
              price: 0,
              billed: 0,
            },
          },
          pro: {
            monthly: {
              id: 'ferdi-still-free',
              price: 0,
              billed: 0,
            },
            yearly: {
              id: 'ferdi-forever-free',
              price: 0,
              billed: 0,
            },
          },
        },
      },
    });
  }

  // Return an empty array
  emptyArray({
    response,
  }) {
    return response.send([]);
  }

  // Payment plans availible
  plans({
    response,
  }) {
    return response.send({
      month: {
        id: 'franz-supporter-license',
        price: 99,
      },
      year: {
        id: 'franz-supporter-license-year-2019',
        price: 99,
      },
    });
  }

  // Return list of popular recipes (copy of the response Franz's API is returning)
  popularRecipes({
    response,
  }) {
    return response.send(
      fs
        .readJsonSync(path.join(
          Helpers.appRoot(), 'officialrecipes', 'recipes', 'all.json',
        ))
        .filter((recipe) => recipe.featured),
    );
  }

  // Show announcements
  async announcement({
    response,
    params,
  }) {
    const announcement = path.join(Helpers.resourcesPath(), 'announcements', `${params.version}.json`);

    if (await fs.pathExists(announcement)) {
      return response.download(announcement);
    }
    return response.status(404).send('No announcement found.');
  }
}

module.exports = StaticController;