@stacksjs/config 0.50.0 → 0.58.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/helpers.ts ADDED
@@ -0,0 +1,256 @@
1
+ import type { AppConfig, CacheConfig, CdnConfig, ChatConfig, CliConfig, DatabaseConfig, DependenciesConfig, DnsConfig, EmailConfig, Events, GitConfig, HashingConfig, JobConfig, LibraryConfig, Model, NotificationConfig, PaymentConfig, QueueConfig, SearchEngineConfig, SecurityConfig, ServicesConfig, SmsConfig, StacksConfig, StorageConfig, UiConfig } from '@stacksjs/types'
2
+ import { createLocalTunnel } from '@stacksjs/tunnel'
3
+ import { config } from '.'
4
+
5
+ export type LocalUrlType = 'frontend' | 'backend' | 'api' | 'admin' | 'library' | 'email' | 'docs' | 'inspect' | 'desktop'
6
+
7
+ export async function localUrl({
8
+ domain = config.app.url || 'stacks',
9
+ type = 'frontend' as LocalUrlType,
10
+ localhost = false,
11
+ https = undefined as boolean | undefined,
12
+ network = undefined as boolean | undefined,
13
+ } = {}) {
14
+ // Ensure url starts with http:// or https://
15
+ // if (!url.startsWith('http://') && !url.startsWith('https://'))
16
+ // url = 'https://' + url
17
+ let url
18
+
19
+ switch (type) {
20
+ case 'frontend':
21
+ if (network)
22
+ return await createLocalTunnel(config.app.ports?.frontend || 3333)
23
+
24
+ if (localhost)
25
+ return `http://localhost:${config.app.ports?.frontend}`
26
+
27
+ url = domain.replace(/\.[^\.]+$/, '.localhost')
28
+
29
+ if (https)
30
+ return `https://${url}`
31
+
32
+ return url
33
+ case 'backend':
34
+ if (network)
35
+ return await createLocalTunnel(config.app.ports?.backend || 3334)
36
+
37
+ if (localhost)
38
+ return `http://localhost:${config.app.ports?.backend}`
39
+
40
+ url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
41
+
42
+ if (https)
43
+ return `https://${url}`
44
+
45
+ return url
46
+ case 'api':
47
+ if (network)
48
+ return await createLocalTunnel(config.app.ports?.backend || 3334)
49
+
50
+ if (localhost)
51
+ return `http://localhost:${config.app.ports?.backend}`
52
+
53
+ url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
54
+
55
+ if (https)
56
+ return `https://${url}`
57
+
58
+ return url
59
+ case 'admin':
60
+ if (network)
61
+ return await createLocalTunnel(config.app.ports?.admin || 3335)
62
+
63
+ if (localhost)
64
+ return `http://localhost:${config.app.ports?.admin}`
65
+
66
+ url = domain.replace(/\.[^\.]+$/, '.localhost/admin/')
67
+
68
+ if (https)
69
+ return `https://${url}`
70
+
71
+ return url
72
+ case 'library':
73
+ if (network)
74
+ return await createLocalTunnel(config.app.ports?.library || 3336)
75
+
76
+ if (localhost)
77
+ return `http://localhost:${config.app.ports?.library}`
78
+
79
+ url = domain.replace(/\.[^\.]+$/, '.localhost/libs/')
80
+
81
+ if (https)
82
+ return `https://${url}`
83
+
84
+ return url
85
+ case 'email':
86
+ if (network)
87
+ return await createLocalTunnel(config.app.ports?.email || 3338)
88
+
89
+ if (localhost)
90
+ return `http://localhost:${config.app.ports?.email}`
91
+
92
+ url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
93
+
94
+ if (https)
95
+ return `https://${url}`
96
+
97
+ return url
98
+ case 'desktop':
99
+ if (network)
100
+ return await createLocalTunnel(config.app.ports?.desktop || 3337)
101
+
102
+ if (localhost)
103
+ return `http://localhost:${config.app.ports?.email}`
104
+
105
+ url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
106
+
107
+ if (https)
108
+ return `https://${url}`
109
+
110
+ return url
111
+ case 'docs':
112
+ if (network)
113
+ return await createLocalTunnel(config.app.ports?.desktop || 3339)
114
+
115
+ if (localhost)
116
+ return `http://localhost:${config.app.ports?.docs}`
117
+
118
+ url = domain.replace(/\.[^\.]+$/, '.localhost/docs/')
119
+
120
+ if (https)
121
+ return `https://${url}`
122
+
123
+ return url
124
+ case 'inspect':
125
+ if (network)
126
+ return await createLocalTunnel(config.app.ports?.desktop || 3340)
127
+
128
+ if (localhost)
129
+ return `http://localhost:${config.app.ports?.inspect}`
130
+
131
+ url = domain.replace(/\.[^\.]+$/, '.localhost/__inspect/')
132
+
133
+ if (https)
134
+ return `https://${url}`
135
+
136
+ return url
137
+ default:
138
+ if (localhost)
139
+ return `http://localhost:${config.app.ports?.frontend}`
140
+
141
+ url = domain.replace(/\.[^\.]+$/, '.localhost')
142
+
143
+ if (https)
144
+ return `https://${url}`
145
+
146
+ return url
147
+ }
148
+ }
149
+
150
+ export function defineStacksConfig(config: StacksConfig) {
151
+ return config
152
+ }
153
+
154
+ export function defineApp(config: AppConfig) {
155
+ return config
156
+ }
157
+
158
+ export function defineCache(config: CacheConfig) {
159
+ return config
160
+ }
161
+
162
+ export function defineCdn(config: CdnConfig) {
163
+ return config
164
+ }
165
+
166
+ export function defineChat(config: ChatConfig) {
167
+ return config
168
+ }
169
+
170
+ export function defineCli(config: CliConfig) {
171
+ return config
172
+ }
173
+
174
+ export function defineJob(config: JobConfig) {
175
+ return config
176
+ }
177
+
178
+ export function defineCronJob(config: JobConfig) {
179
+ return config
180
+ }
181
+
182
+ export function defineDatabase(config: DatabaseConfig) {
183
+ return config
184
+ }
185
+
186
+ export function defineDependencies(config: DependenciesConfig) {
187
+ return config
188
+ }
189
+
190
+ export function defineDns(config: DnsConfig) {
191
+ return config
192
+ }
193
+
194
+ export function defineEmailConfig(config: EmailConfig) {
195
+ return config
196
+ }
197
+
198
+ export function defineEmail(config: EmailConfig) {
199
+ return config
200
+ }
201
+
202
+ export function defineGit(config: GitConfig) {
203
+ return config
204
+ }
205
+
206
+ export function defineHashing(config: HashingConfig) {
207
+ return config
208
+ }
209
+
210
+ export function defineLibrary(config: LibraryConfig) {
211
+ return config
212
+ }
213
+
214
+ export function defineNotification(config: NotificationConfig) {
215
+ return config
216
+ }
217
+
218
+ export function definePayment(config: PaymentConfig) {
219
+ return config
220
+ }
221
+
222
+ export function defineQueue(config: QueueConfig) {
223
+ return config
224
+ }
225
+
226
+ export function defineSearchEngine(config: SearchEngineConfig) {
227
+ return config
228
+ }
229
+
230
+ export function defineSecurity(config: SecurityConfig) {
231
+ return config
232
+ }
233
+
234
+ export function defineServices(config: ServicesConfig) {
235
+ return config
236
+ }
237
+
238
+ export function defineSms(config: SmsConfig) {
239
+ return config
240
+ }
241
+
242
+ export function defineStorage(config: StorageConfig) {
243
+ return config
244
+ }
245
+
246
+ export function defineUi(config: UiConfig) {
247
+ return config
248
+ }
249
+
250
+ export function defineModel(config: Model) {
251
+ return config
252
+ }
253
+
254
+ export function defineEvents(config: Events) {
255
+ return config
256
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * as config from './config'
2
+ export * from './config'
@@ -0,0 +1,49 @@
1
+ import type { StacksConfig } from '@stacksjs/types'
2
+ import ai from '../../../../../config/ai'
3
+ import api from '../../../../../config/api'
4
+ import app from '../../../../../config/app'
5
+ import cache from '../../../../../config/cache'
6
+ import binary from '../../../../../config/cli'
7
+ import cloud from '../../../../../config/cloud'
8
+ import database from '../../../../../config/database'
9
+ import dns from '../../../../../config/dns'
10
+ import docs from '../../../../../config/docs'
11
+ import email from '../../../../../config/email'
12
+ import git from '../../../../../config/git'
13
+ import hashing from '../../../../../config/hashing'
14
+ import library from '../../../../../config/library'
15
+ import queue from '../../../../../config/queue'
16
+ import payment from '../../../../../config/payment'
17
+ import notification from '../../../../../config/notification'
18
+ import storage from '../../../../../config/storage'
19
+ import searchEngine from '../../../../../config/search-engine'
20
+ import security from '../../../../../config/security'
21
+ import services from '../../../../../config/services'
22
+ import team from '../../../../../config/team'
23
+ import ui from '../../../../../config/ui'
24
+
25
+ // this "user config" will override the default config options
26
+ export default {
27
+ ai,
28
+ api,
29
+ app,
30
+ binary,
31
+ cache,
32
+ cloud,
33
+ database,
34
+ dns,
35
+ docs,
36
+ email,
37
+ git,
38
+ hashing,
39
+ library,
40
+ notification,
41
+ queue,
42
+ payment,
43
+ searchEngine,
44
+ security,
45
+ services,
46
+ storage,
47
+ team,
48
+ ui,
49
+ } satisfies StacksConfig
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- # MIT License
2
-
3
- Copyright (c) 2022 Open Web Foundation
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/index.d.ts DELETED
@@ -1,204 +0,0 @@
1
- import { CliOptions, AppOptions, DebugOptions, DeployOptions, Events, DocsConfig, GitOptions, HashingOptions, LibraryOptions, NotificationOptions, SearchEngineOptions, UiOptions } from '@stacksjs/types';
2
-
3
- type Config = 'app' | 'cache' | 'database' | 'debug' | 'deploy' | 'docs' | 'git' | 'hashing' | 'library' | 'notification' | 'searchEngine' | 'services' | 'storage' | 'ui';
4
- declare function config(key?: Config, fallback?: any): any;
5
- declare function env(key: string, fallback: any): any;
6
- /**
7
- * Determines the level of debugging.
8
- * @param options
9
- */
10
- declare function determineDebugMode(options?: CliOptions): boolean;
11
-
12
- /**
13
- * **Application Options**
14
- *
15
- * This configuration defines all of your application options. Because Stacks is full-typed,
16
- * you may hover any of the options below and the definitions will be provided. In case
17
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
18
- */
19
- declare const app: AppOptions;
20
-
21
- /**
22
- * **Cache Options**
23
- *
24
- * This configuration defines all of your cache options. Because Stacks is full-typed,
25
- * you may hover any of the options below and the definitions will be provided. In case
26
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
27
- */
28
- declare const cache: {
29
- driver: any;
30
- redis: {
31
- connection: string;
32
- host: any;
33
- port: any;
34
- };
35
- memcached: {
36
- persistent_id: any;
37
- sasl: any[];
38
- options: {};
39
- servers: {
40
- host: any;
41
- port: any;
42
- weight: number;
43
- }[];
44
- };
45
- dynamodb: {
46
- key: any;
47
- secret: any;
48
- region: any;
49
- table: any;
50
- endpoint: any;
51
- };
52
- };
53
-
54
- /**
55
- * **Database Options**
56
- *
57
- * This configuration defines all of your database options. Because Stacks is full-typed,
58
- * you may hover any of the options below and the definitions will be provided. In case
59
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
60
- */
61
- declare const database: {
62
- driver: string;
63
- };
64
-
65
- /**
66
- * **Debug Options**
67
- *
68
- * This configuration defines all of your database options. Because Stacks is full-typed,
69
- * you may hover any of the options below and the definitions will be provided. In case
70
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
71
- */
72
- declare const debug: DebugOptions;
73
-
74
- /**
75
- * **Deployment Options**
76
- *
77
- * This configuration defines all of your deploy options. Because Stacks is full-typed,
78
- * you may hover any of the options below and the definitions will be provided. In case
79
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
80
- */
81
- declare const deploy: DeployOptions;
82
-
83
- /**
84
- * **Events**
85
- *
86
- * This configuration defines all of your events. Because Stacks is full-typed, you may
87
- * hover any of the options below and the definitions will be provided. In case you
88
- * have any questions, feel free to reach out via Discord or GitHub Discussions.
89
- */
90
- declare const events: Events;
91
-
92
- /**
93
- * **Documentation Options**
94
- *
95
- * This configuration defines all of your documentation options. Because Stacks is full-typed,
96
- * you may hover any of the options below and the definitions will be provided. In case
97
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
98
- */
99
- declare const _default: DocsConfig;
100
-
101
- declare namespace docs {
102
- export {
103
- _default as default,
104
- };
105
- }
106
-
107
- /**
108
- * **Git Options**
109
- *
110
- * This configuration defines all of your git options. Because Stacks is full-typed, you may
111
- * hover any of the options below and the definitions will be provided. In case you
112
- * have any questions, feel free to reach out via Discord or GitHub Discussions.
113
- */
114
- declare const git: GitOptions;
115
-
116
- declare const hashing: HashingOptions;
117
-
118
- /**
119
- * **Library Options**
120
- *
121
- * This configuration defines all of your library options. Because Stacks is full-typed, you
122
- * may hover any of the options below and the definitions will be provided. In case you
123
- * have any questions, feel free to reach out via Discord or GitHub Discussions.
124
- */
125
- declare const library: LibraryOptions;
126
-
127
- /**
128
- * **Notification Options**
129
- *
130
- * This configuration defines all of your notification options. Because Stacks is full-typed,
131
- * you may hover any of the options below and the definitions will be provided. In case
132
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
133
- */
134
- declare const notification: NotificationOptions;
135
-
136
- /**
137
- * **Search Engine Options**
138
- *
139
- * This configuration defines all of your search engine options. Because Stacks is full-typed,
140
- * you may hover any of the options below and the definitions will be provided. In case
141
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
142
- */
143
- declare const searchEngine: SearchEngineOptions;
144
-
145
- /**
146
- * **Services**
147
- *
148
- * This configuration defines all of your services. Because Stacks is full-typed, you may
149
- * hover any of the options below and the definitions will be provided. In case you
150
- * have any questions, feel free to reach out via Discord or GitHub Discussions.
151
- */
152
- declare const services: {
153
- algolia: {
154
- appId: string;
155
- apiKey: string;
156
- indexName: string;
157
- };
158
- meilisearch: {
159
- appId: string;
160
- apiKey: string;
161
- indexName: string;
162
- };
163
- stripe: {
164
- appId: string;
165
- apiKey: string;
166
- };
167
- planetscale: {
168
- appId: string;
169
- apiKey: string;
170
- };
171
- supabase: {
172
- appId: string;
173
- apiKey: string;
174
- };
175
- aws: {
176
- appId: string;
177
- apiKey: string;
178
- };
179
- novu: {
180
- key: any;
181
- };
182
- };
183
-
184
- /**
185
- * **Database Options**
186
- *
187
- * This configuration defines all of your database options. Because Stacks is full-typed,
188
- * you may hover any of the options below and the definitions will be provided. In case
189
- * you have any questions, feel free to reach out via Discord or GitHub Discussions.
190
- */
191
- declare const storage: {
192
- driver: string;
193
- };
194
-
195
- /**
196
- * **UI Engine Options**
197
- *
198
- * This configuration defines all of your UI Engine options. Because Stacks is full-typed, you
199
- * may hover any of the options below and the definitions will be provided. In case you
200
- * have any questions, feel free to reach out via Discord or GitHub Discussions.
201
- */
202
- declare const ui: UiOptions;
203
-
204
- export { app, cache, config, database, debug, deploy, determineDebugMode, docs, env, events, git, hashing, library, notification, searchEngine, services, storage, ui };