@shellapps/config 1.0.1

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/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # @shellapps/config
2
+
3
+ Configuration management for the ShellApps ecosystem. This package provides environment-specific configuration for all ShellApps and ShellLabs services.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @shellapps/config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Usage
14
+
15
+ ```typescript
16
+ import { getConfig } from '@shellapps/config';
17
+
18
+ const config = getConfig();
19
+ console.log(config.serviceUrls.apps); // https://apps.shellapps.com (in production)
20
+ ```
21
+
22
+ ### Environment Configuration
23
+
24
+ The package reads the `SHELLAPPS_ENV` environment variable to determine which configuration to load:
25
+
26
+ - `development` (default) - Local development with localhost URLs
27
+ - `staging` - Staging environment with *.shellapps.net / *.shelllabs.net domains
28
+ - `production` - Production environment with *.shellapps.com / *.shelllabs.net domains
29
+
30
+ ```bash
31
+ # Set environment
32
+ export SHELLAPPS_ENV=production
33
+
34
+ # Or inline
35
+ SHELLAPPS_ENV=staging node app.js
36
+ ```
37
+
38
+ ### Specific Configuration Getters
39
+
40
+ ```typescript
41
+ import {
42
+ getServiceUrls,
43
+ getS3Config,
44
+ getMongoConfig,
45
+ getFeatureFlags,
46
+ getEnvironment
47
+ } from '@shellapps/config';
48
+
49
+ // Get current environment
50
+ const env = getEnvironment(); // 'development' | 'staging' | 'production'
51
+
52
+ // Get service URLs
53
+ const urls = getServiceUrls();
54
+ console.log(urls.auth); // Auth service URL
55
+ console.log(urls.apps); // Main apps URL
56
+ console.log(urls.blog); // Blog URL
57
+ console.log(urls.admin); // ShellLabs admin URL
58
+
59
+ // Get S3 configuration
60
+ const s3 = getS3Config();
61
+ console.log(s3.buckets.assets); // Asset bucket name
62
+ console.log(s3.buckets.uploads); // Upload bucket name
63
+
64
+ // Get MongoDB configuration
65
+ const mongo = getMongoConfig();
66
+ console.log(mongo.database); // Database name
67
+ console.log(mongo.authDatabase); // Auth database name
68
+
69
+ // Get feature flags
70
+ const flags = getFeatureFlags();
71
+ console.log(flags.someFeature); // boolean value
72
+ ```
73
+
74
+ ### Default Export
75
+
76
+ ```typescript
77
+ import config from '@shellapps/config';
78
+
79
+ const appConfig = config.getConfig();
80
+ const serviceUrls = config.getServiceUrls();
81
+ const s3Config = config.getS3Config();
82
+ ```
83
+
84
+ ### TypeScript Types
85
+
86
+ All configuration objects are fully typed:
87
+
88
+ ```typescript
89
+ import type {
90
+ Config,
91
+ Environment,
92
+ ServiceUrls,
93
+ S3Config,
94
+ MongoConfig,
95
+ FeatureFlags
96
+ } from '@shellapps/config';
97
+
98
+ function setupApp(config: Config) {
99
+ // TypeScript will provide full intellisense and type checking
100
+ const authUrl = config.serviceUrls.auth;
101
+ const assetBucket = config.s3.buckets.assets;
102
+ }
103
+ ```
104
+
105
+ ## Configuration Structure
106
+
107
+ ### Service URLs
108
+
109
+ - **Development**: All services run on localhost with different ports
110
+ - **Staging**: Uses *.shellapps.net and *.shelllabs.net domains
111
+ - **Production**: Uses *.shellapps.com and *.shelllabs.net domains
112
+
113
+ ### S3 Buckets
114
+
115
+ Environment-specific bucket names:
116
+ - Assets bucket: `shellapps-{env}-assets`
117
+ - Uploads bucket: `shellapps-{env}-uploads`
118
+ - Backups bucket: `shellapps-{env}-backups`
119
+
120
+ ### MongoDB
121
+
122
+ Environment-specific database names:
123
+ - Development: `shellapps_dev`
124
+ - Staging: `shellapps_staging`
125
+ - Production: `shellapps_production`
126
+
127
+ ### Feature Flags
128
+
129
+ Object structure for enabling/disabling features per environment. Add flags as needed:
130
+
131
+ ```typescript
132
+ // In your app code
133
+ const flags = getFeatureFlags();
134
+ if (flags.newDashboard) {
135
+ // Show new dashboard
136
+ }
137
+ ```
138
+
139
+ ## Error Handling
140
+
141
+ The package throws descriptive errors for invalid configurations:
142
+
143
+ ```typescript
144
+ // If SHELLAPPS_ENV=invalid
145
+ try {
146
+ const config = getConfig();
147
+ } catch (error) {
148
+ console.error(error.message);
149
+ // "Invalid environment: invalid. Must be one of: development, staging, production"
150
+ }
151
+ ```
152
+
153
+ ## Development
154
+
155
+ ```bash
156
+ # Install dependencies
157
+ npm install
158
+
159
+ # Build the package
160
+ npm run build
161
+
162
+ # Watch for changes during development
163
+ npm run dev
164
+
165
+ # Clean build artifacts
166
+ npm run clean
167
+ ```
168
+
169
+ ## License
170
+
171
+ MIT
@@ -0,0 +1,45 @@
1
+ type Environment = 'development' | 'staging' | 'production';
2
+ interface ServiceUrls {
3
+ auth: string;
4
+ apps: string;
5
+ blog: string;
6
+ engineering: string;
7
+ admin: string;
8
+ }
9
+ interface S3Config {
10
+ buckets: {
11
+ assets: string;
12
+ uploads: string;
13
+ backups: string;
14
+ };
15
+ }
16
+ interface MongoConfig {
17
+ database: string;
18
+ authDatabase?: string;
19
+ }
20
+ interface FeatureFlags {
21
+ [key: string]: boolean;
22
+ }
23
+ interface Config {
24
+ environment: Environment;
25
+ serviceUrls: ServiceUrls;
26
+ s3: S3Config;
27
+ mongodb: MongoConfig;
28
+ featureFlags: FeatureFlags;
29
+ }
30
+ declare function getConfig(): Config;
31
+ declare function getEnvironment(): Environment;
32
+ declare function getServiceUrls(): ServiceUrls;
33
+ declare function getS3Config(): S3Config;
34
+ declare function getMongoConfig(): MongoConfig;
35
+ declare function getFeatureFlags(): FeatureFlags;
36
+ declare const _default: {
37
+ getConfig: typeof getConfig;
38
+ getEnvironment: typeof getEnvironment;
39
+ getServiceUrls: typeof getServiceUrls;
40
+ getS3Config: typeof getS3Config;
41
+ getMongoConfig: typeof getMongoConfig;
42
+ getFeatureFlags: typeof getFeatureFlags;
43
+ };
44
+
45
+ export { type Config, type Environment, type FeatureFlags, type MongoConfig, type S3Config, type ServiceUrls, _default as default, getConfig, getEnvironment, getFeatureFlags, getMongoConfig, getS3Config, getServiceUrls };
@@ -0,0 +1,45 @@
1
+ type Environment = 'development' | 'staging' | 'production';
2
+ interface ServiceUrls {
3
+ auth: string;
4
+ apps: string;
5
+ blog: string;
6
+ engineering: string;
7
+ admin: string;
8
+ }
9
+ interface S3Config {
10
+ buckets: {
11
+ assets: string;
12
+ uploads: string;
13
+ backups: string;
14
+ };
15
+ }
16
+ interface MongoConfig {
17
+ database: string;
18
+ authDatabase?: string;
19
+ }
20
+ interface FeatureFlags {
21
+ [key: string]: boolean;
22
+ }
23
+ interface Config {
24
+ environment: Environment;
25
+ serviceUrls: ServiceUrls;
26
+ s3: S3Config;
27
+ mongodb: MongoConfig;
28
+ featureFlags: FeatureFlags;
29
+ }
30
+ declare function getConfig(): Config;
31
+ declare function getEnvironment(): Environment;
32
+ declare function getServiceUrls(): ServiceUrls;
33
+ declare function getS3Config(): S3Config;
34
+ declare function getMongoConfig(): MongoConfig;
35
+ declare function getFeatureFlags(): FeatureFlags;
36
+ declare const _default: {
37
+ getConfig: typeof getConfig;
38
+ getEnvironment: typeof getEnvironment;
39
+ getServiceUrls: typeof getServiceUrls;
40
+ getS3Config: typeof getS3Config;
41
+ getMongoConfig: typeof getMongoConfig;
42
+ getFeatureFlags: typeof getFeatureFlags;
43
+ };
44
+
45
+ export { type Config, type Environment, type FeatureFlags, type MongoConfig, type S3Config, type ServiceUrls, _default as default, getConfig, getEnvironment, getFeatureFlags, getMongoConfig, getS3Config, getServiceUrls };
package/dist/index.js ADDED
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default,
24
+ getConfig: () => getConfig,
25
+ getEnvironment: () => getEnvironment,
26
+ getFeatureFlags: () => getFeatureFlags,
27
+ getMongoConfig: () => getMongoConfig,
28
+ getS3Config: () => getS3Config,
29
+ getServiceUrls: () => getServiceUrls
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+ var configs = {
33
+ development: {
34
+ environment: "development",
35
+ serviceUrls: {
36
+ auth: "http://localhost:3001",
37
+ apps: "http://localhost:3000",
38
+ blog: "http://localhost:3002",
39
+ engineering: "http://localhost:3003",
40
+ admin: "http://localhost:3004"
41
+ // ShellLabs admin
42
+ },
43
+ s3: {
44
+ buckets: {
45
+ assets: "shellapps-dev-assets",
46
+ uploads: "shellapps-dev-uploads",
47
+ backups: "shellapps-dev-backups"
48
+ }
49
+ },
50
+ mongodb: {
51
+ database: "shellapps_dev",
52
+ authDatabase: "admin"
53
+ },
54
+ featureFlags: {
55
+ // Add feature flags as needed
56
+ }
57
+ },
58
+ staging: {
59
+ environment: "staging",
60
+ serviceUrls: {
61
+ auth: "https://auth.shelllabs.net",
62
+ apps: "https://apps.shellapps.net",
63
+ blog: "https://blog.shellapps.net",
64
+ engineering: "https://engineering.shellapps.net",
65
+ admin: "https://admin.shelllabs.net"
66
+ // ShellLabs admin
67
+ },
68
+ s3: {
69
+ buckets: {
70
+ assets: "shellapps-staging-assets",
71
+ uploads: "shellapps-staging-uploads",
72
+ backups: "shellapps-staging-backups"
73
+ }
74
+ },
75
+ mongodb: {
76
+ database: "shellapps_staging",
77
+ authDatabase: "admin"
78
+ },
79
+ featureFlags: {
80
+ // Add feature flags as needed
81
+ }
82
+ },
83
+ production: {
84
+ environment: "production",
85
+ serviceUrls: {
86
+ auth: "https://auth.shelllabs.net",
87
+ apps: "https://apps.shellapps.com",
88
+ blog: "https://blog.shellapps.com",
89
+ engineering: "https://engineering.shellapps.com",
90
+ admin: "https://admin.shelllabs.net"
91
+ // ShellLabs admin
92
+ },
93
+ s3: {
94
+ buckets: {
95
+ assets: "shellapps-prod-assets",
96
+ uploads: "shellapps-prod-uploads",
97
+ backups: "shellapps-prod-backups"
98
+ }
99
+ },
100
+ mongodb: {
101
+ database: "shellapps_production",
102
+ authDatabase: "admin"
103
+ },
104
+ featureFlags: {
105
+ // Add feature flags as needed
106
+ }
107
+ }
108
+ };
109
+ function getConfig() {
110
+ const env = process.env.SHELLAPPS_ENV || "development";
111
+ if (!configs[env]) {
112
+ throw new Error(`Invalid environment: ${env}. Must be one of: development, staging, production`);
113
+ }
114
+ return configs[env];
115
+ }
116
+ function getEnvironment() {
117
+ return getConfig().environment;
118
+ }
119
+ function getServiceUrls() {
120
+ return getConfig().serviceUrls;
121
+ }
122
+ function getS3Config() {
123
+ return getConfig().s3;
124
+ }
125
+ function getMongoConfig() {
126
+ return getConfig().mongodb;
127
+ }
128
+ function getFeatureFlags() {
129
+ return getConfig().featureFlags;
130
+ }
131
+ var index_default = {
132
+ getConfig,
133
+ getEnvironment,
134
+ getServiceUrls,
135
+ getS3Config,
136
+ getMongoConfig,
137
+ getFeatureFlags
138
+ };
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ getConfig,
142
+ getEnvironment,
143
+ getFeatureFlags,
144
+ getMongoConfig,
145
+ getS3Config,
146
+ getServiceUrls
147
+ });
148
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type Environment = 'development' | 'staging' | 'production';\n\nexport interface ServiceUrls {\n auth: string;\n apps: string;\n blog: string;\n engineering: string;\n admin: string; // ShellLabs\n}\n\nexport interface S3Config {\n buckets: {\n assets: string;\n uploads: string;\n backups: string;\n };\n}\n\nexport interface MongoConfig {\n database: string;\n authDatabase?: string;\n}\n\nexport interface FeatureFlags {\n [key: string]: boolean;\n}\n\nexport interface Config {\n environment: Environment;\n serviceUrls: ServiceUrls;\n s3: S3Config;\n mongodb: MongoConfig;\n featureFlags: FeatureFlags;\n}\n\nconst configs: Record<Environment, Config> = {\n development: {\n environment: 'development',\n serviceUrls: {\n auth: 'http://localhost:3001',\n apps: 'http://localhost:3000',\n blog: 'http://localhost:3002',\n engineering: 'http://localhost:3003',\n admin: 'http://localhost:3004', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-dev-assets',\n uploads: 'shellapps-dev-uploads',\n backups: 'shellapps-dev-backups',\n },\n },\n mongodb: {\n database: 'shellapps_dev',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n staging: {\n environment: 'staging',\n serviceUrls: {\n auth: 'https://auth.shelllabs.net',\n apps: 'https://apps.shellapps.net',\n blog: 'https://blog.shellapps.net',\n engineering: 'https://engineering.shellapps.net',\n admin: 'https://admin.shelllabs.net', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-staging-assets',\n uploads: 'shellapps-staging-uploads',\n backups: 'shellapps-staging-backups',\n },\n },\n mongodb: {\n database: 'shellapps_staging',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n production: {\n environment: 'production',\n serviceUrls: {\n auth: 'https://auth.shelllabs.net',\n apps: 'https://apps.shellapps.com',\n blog: 'https://blog.shellapps.com',\n engineering: 'https://engineering.shellapps.com',\n admin: 'https://admin.shelllabs.net', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-prod-assets',\n uploads: 'shellapps-prod-uploads',\n backups: 'shellapps-prod-backups',\n },\n },\n mongodb: {\n database: 'shellapps_production',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n};\n\nexport function getConfig(): Config {\n const env = (process.env.SHELLAPPS_ENV || 'development') as Environment;\n \n if (!configs[env]) {\n throw new Error(`Invalid environment: ${env}. Must be one of: development, staging, production`);\n }\n \n return configs[env];\n}\n\n// Export individual getters for convenience\nexport function getEnvironment(): Environment {\n return getConfig().environment;\n}\n\nexport function getServiceUrls(): ServiceUrls {\n return getConfig().serviceUrls;\n}\n\nexport function getS3Config(): S3Config {\n return getConfig().s3;\n}\n\nexport function getMongoConfig(): MongoConfig {\n return getConfig().mongodb;\n}\n\nexport function getFeatureFlags(): FeatureFlags {\n return getConfig().featureFlags;\n}\n\n// Default export\nexport default {\n getConfig,\n getEnvironment,\n getServiceUrls,\n getS3Config,\n getMongoConfig,\n getFeatureFlags,\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCA,IAAM,UAAuC;AAAA,EAC3C,aAAa;AAAA,IACX,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AACF;AAEO,SAAS,YAAoB;AAClC,QAAM,MAAO,QAAQ,IAAI,iBAAiB;AAE1C,MAAI,CAAC,QAAQ,GAAG,GAAG;AACjB,UAAM,IAAI,MAAM,wBAAwB,GAAG,oDAAoD;AAAA,EACjG;AAEA,SAAO,QAAQ,GAAG;AACpB;AAGO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,cAAwB;AACtC,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,kBAAgC;AAC9C,SAAO,UAAU,EAAE;AACrB;AAGA,IAAO,gBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,118 @@
1
+ // src/index.ts
2
+ var configs = {
3
+ development: {
4
+ environment: "development",
5
+ serviceUrls: {
6
+ auth: "http://localhost:3001",
7
+ apps: "http://localhost:3000",
8
+ blog: "http://localhost:3002",
9
+ engineering: "http://localhost:3003",
10
+ admin: "http://localhost:3004"
11
+ // ShellLabs admin
12
+ },
13
+ s3: {
14
+ buckets: {
15
+ assets: "shellapps-dev-assets",
16
+ uploads: "shellapps-dev-uploads",
17
+ backups: "shellapps-dev-backups"
18
+ }
19
+ },
20
+ mongodb: {
21
+ database: "shellapps_dev",
22
+ authDatabase: "admin"
23
+ },
24
+ featureFlags: {
25
+ // Add feature flags as needed
26
+ }
27
+ },
28
+ staging: {
29
+ environment: "staging",
30
+ serviceUrls: {
31
+ auth: "https://auth.shelllabs.net",
32
+ apps: "https://apps.shellapps.net",
33
+ blog: "https://blog.shellapps.net",
34
+ engineering: "https://engineering.shellapps.net",
35
+ admin: "https://admin.shelllabs.net"
36
+ // ShellLabs admin
37
+ },
38
+ s3: {
39
+ buckets: {
40
+ assets: "shellapps-staging-assets",
41
+ uploads: "shellapps-staging-uploads",
42
+ backups: "shellapps-staging-backups"
43
+ }
44
+ },
45
+ mongodb: {
46
+ database: "shellapps_staging",
47
+ authDatabase: "admin"
48
+ },
49
+ featureFlags: {
50
+ // Add feature flags as needed
51
+ }
52
+ },
53
+ production: {
54
+ environment: "production",
55
+ serviceUrls: {
56
+ auth: "https://auth.shelllabs.net",
57
+ apps: "https://apps.shellapps.com",
58
+ blog: "https://blog.shellapps.com",
59
+ engineering: "https://engineering.shellapps.com",
60
+ admin: "https://admin.shelllabs.net"
61
+ // ShellLabs admin
62
+ },
63
+ s3: {
64
+ buckets: {
65
+ assets: "shellapps-prod-assets",
66
+ uploads: "shellapps-prod-uploads",
67
+ backups: "shellapps-prod-backups"
68
+ }
69
+ },
70
+ mongodb: {
71
+ database: "shellapps_production",
72
+ authDatabase: "admin"
73
+ },
74
+ featureFlags: {
75
+ // Add feature flags as needed
76
+ }
77
+ }
78
+ };
79
+ function getConfig() {
80
+ const env = process.env.SHELLAPPS_ENV || "development";
81
+ if (!configs[env]) {
82
+ throw new Error(`Invalid environment: ${env}. Must be one of: development, staging, production`);
83
+ }
84
+ return configs[env];
85
+ }
86
+ function getEnvironment() {
87
+ return getConfig().environment;
88
+ }
89
+ function getServiceUrls() {
90
+ return getConfig().serviceUrls;
91
+ }
92
+ function getS3Config() {
93
+ return getConfig().s3;
94
+ }
95
+ function getMongoConfig() {
96
+ return getConfig().mongodb;
97
+ }
98
+ function getFeatureFlags() {
99
+ return getConfig().featureFlags;
100
+ }
101
+ var index_default = {
102
+ getConfig,
103
+ getEnvironment,
104
+ getServiceUrls,
105
+ getS3Config,
106
+ getMongoConfig,
107
+ getFeatureFlags
108
+ };
109
+ export {
110
+ index_default as default,
111
+ getConfig,
112
+ getEnvironment,
113
+ getFeatureFlags,
114
+ getMongoConfig,
115
+ getS3Config,
116
+ getServiceUrls
117
+ };
118
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type Environment = 'development' | 'staging' | 'production';\n\nexport interface ServiceUrls {\n auth: string;\n apps: string;\n blog: string;\n engineering: string;\n admin: string; // ShellLabs\n}\n\nexport interface S3Config {\n buckets: {\n assets: string;\n uploads: string;\n backups: string;\n };\n}\n\nexport interface MongoConfig {\n database: string;\n authDatabase?: string;\n}\n\nexport interface FeatureFlags {\n [key: string]: boolean;\n}\n\nexport interface Config {\n environment: Environment;\n serviceUrls: ServiceUrls;\n s3: S3Config;\n mongodb: MongoConfig;\n featureFlags: FeatureFlags;\n}\n\nconst configs: Record<Environment, Config> = {\n development: {\n environment: 'development',\n serviceUrls: {\n auth: 'http://localhost:3001',\n apps: 'http://localhost:3000',\n blog: 'http://localhost:3002',\n engineering: 'http://localhost:3003',\n admin: 'http://localhost:3004', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-dev-assets',\n uploads: 'shellapps-dev-uploads',\n backups: 'shellapps-dev-backups',\n },\n },\n mongodb: {\n database: 'shellapps_dev',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n staging: {\n environment: 'staging',\n serviceUrls: {\n auth: 'https://auth.shelllabs.net',\n apps: 'https://apps.shellapps.net',\n blog: 'https://blog.shellapps.net',\n engineering: 'https://engineering.shellapps.net',\n admin: 'https://admin.shelllabs.net', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-staging-assets',\n uploads: 'shellapps-staging-uploads',\n backups: 'shellapps-staging-backups',\n },\n },\n mongodb: {\n database: 'shellapps_staging',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n production: {\n environment: 'production',\n serviceUrls: {\n auth: 'https://auth.shelllabs.net',\n apps: 'https://apps.shellapps.com',\n blog: 'https://blog.shellapps.com',\n engineering: 'https://engineering.shellapps.com',\n admin: 'https://admin.shelllabs.net', // ShellLabs admin\n },\n s3: {\n buckets: {\n assets: 'shellapps-prod-assets',\n uploads: 'shellapps-prod-uploads',\n backups: 'shellapps-prod-backups',\n },\n },\n mongodb: {\n database: 'shellapps_production',\n authDatabase: 'admin',\n },\n featureFlags: {\n // Add feature flags as needed\n },\n },\n};\n\nexport function getConfig(): Config {\n const env = (process.env.SHELLAPPS_ENV || 'development') as Environment;\n \n if (!configs[env]) {\n throw new Error(`Invalid environment: ${env}. Must be one of: development, staging, production`);\n }\n \n return configs[env];\n}\n\n// Export individual getters for convenience\nexport function getEnvironment(): Environment {\n return getConfig().environment;\n}\n\nexport function getServiceUrls(): ServiceUrls {\n return getConfig().serviceUrls;\n}\n\nexport function getS3Config(): S3Config {\n return getConfig().s3;\n}\n\nexport function getMongoConfig(): MongoConfig {\n return getConfig().mongodb;\n}\n\nexport function getFeatureFlags(): FeatureFlags {\n return getConfig().featureFlags;\n}\n\n// Default export\nexport default {\n getConfig,\n getEnvironment,\n getServiceUrls,\n getS3Config,\n getMongoConfig,\n getFeatureFlags,\n};"],"mappings":";AAmCA,IAAM,UAAuC;AAAA,EAC3C,aAAa;AAAA,IACX,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA;AAAA,IACT;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,IAChB;AAAA,IACA,cAAc;AAAA;AAAA,IAEd;AAAA,EACF;AACF;AAEO,SAAS,YAAoB;AAClC,QAAM,MAAO,QAAQ,IAAI,iBAAiB;AAE1C,MAAI,CAAC,QAAQ,GAAG,GAAG;AACjB,UAAM,IAAI,MAAM,wBAAwB,GAAG,oDAAoD;AAAA,EACjG;AAEA,SAAO,QAAQ,GAAG;AACpB;AAGO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,cAAwB;AACtC,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,iBAA8B;AAC5C,SAAO,UAAU,EAAE;AACrB;AAEO,SAAS,kBAAgC;AAC9C,SAAO,UAAU,EAAE;AACrB;AAGA,IAAO,gBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@shellapps/config",
3
+ "version": "1.0.1",
4
+ "description": "Configuration management for ShellApps ecosystem",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "clean": "rm -rf dist"
23
+ },
24
+ "keywords": [
25
+ "config",
26
+ "shellapps",
27
+ "environment",
28
+ "typescript"
29
+ ],
30
+ "author": "Alex Hewitt-Procter <alexhp@hotmail.co.uk>",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "tsup": "^8.0.1",
34
+ "typescript": "^5.3.3"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/ShellTechnology/shellapps-js.git",
39
+ "directory": "packages/config"
40
+ },
41
+ "homepage": "https://github.com/ShellTechnology/shellapps-js/tree/main/packages/config#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/ShellTechnology/shellapps-js/issues"
44
+ },
45
+ "gitHead": "3fbf2bc1b038af2703b175af1ff1e22525189592"
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,150 @@
1
+ export type Environment = 'development' | 'staging' | 'production';
2
+
3
+ export interface ServiceUrls {
4
+ auth: string;
5
+ apps: string;
6
+ blog: string;
7
+ engineering: string;
8
+ admin: string; // ShellLabs
9
+ }
10
+
11
+ export interface S3Config {
12
+ buckets: {
13
+ assets: string;
14
+ uploads: string;
15
+ backups: string;
16
+ };
17
+ }
18
+
19
+ export interface MongoConfig {
20
+ database: string;
21
+ authDatabase?: string;
22
+ }
23
+
24
+ export interface FeatureFlags {
25
+ [key: string]: boolean;
26
+ }
27
+
28
+ export interface Config {
29
+ environment: Environment;
30
+ serviceUrls: ServiceUrls;
31
+ s3: S3Config;
32
+ mongodb: MongoConfig;
33
+ featureFlags: FeatureFlags;
34
+ }
35
+
36
+ const configs: Record<Environment, Config> = {
37
+ development: {
38
+ environment: 'development',
39
+ serviceUrls: {
40
+ auth: 'http://localhost:3001',
41
+ apps: 'http://localhost:3000',
42
+ blog: 'http://localhost:3002',
43
+ engineering: 'http://localhost:3003',
44
+ admin: 'http://localhost:3004', // ShellLabs admin
45
+ },
46
+ s3: {
47
+ buckets: {
48
+ assets: 'shellapps-dev-assets',
49
+ uploads: 'shellapps-dev-uploads',
50
+ backups: 'shellapps-dev-backups',
51
+ },
52
+ },
53
+ mongodb: {
54
+ database: 'shellapps_dev',
55
+ authDatabase: 'admin',
56
+ },
57
+ featureFlags: {
58
+ // Add feature flags as needed
59
+ },
60
+ },
61
+ staging: {
62
+ environment: 'staging',
63
+ serviceUrls: {
64
+ auth: 'https://auth.shelllabs.net',
65
+ apps: 'https://apps.shellapps.net',
66
+ blog: 'https://blog.shellapps.net',
67
+ engineering: 'https://engineering.shellapps.net',
68
+ admin: 'https://admin.shelllabs.net', // ShellLabs admin
69
+ },
70
+ s3: {
71
+ buckets: {
72
+ assets: 'shellapps-staging-assets',
73
+ uploads: 'shellapps-staging-uploads',
74
+ backups: 'shellapps-staging-backups',
75
+ },
76
+ },
77
+ mongodb: {
78
+ database: 'shellapps_staging',
79
+ authDatabase: 'admin',
80
+ },
81
+ featureFlags: {
82
+ // Add feature flags as needed
83
+ },
84
+ },
85
+ production: {
86
+ environment: 'production',
87
+ serviceUrls: {
88
+ auth: 'https://auth.shelllabs.net',
89
+ apps: 'https://apps.shellapps.com',
90
+ blog: 'https://blog.shellapps.com',
91
+ engineering: 'https://engineering.shellapps.com',
92
+ admin: 'https://admin.shelllabs.net', // ShellLabs admin
93
+ },
94
+ s3: {
95
+ buckets: {
96
+ assets: 'shellapps-prod-assets',
97
+ uploads: 'shellapps-prod-uploads',
98
+ backups: 'shellapps-prod-backups',
99
+ },
100
+ },
101
+ mongodb: {
102
+ database: 'shellapps_production',
103
+ authDatabase: 'admin',
104
+ },
105
+ featureFlags: {
106
+ // Add feature flags as needed
107
+ },
108
+ },
109
+ };
110
+
111
+ export function getConfig(): Config {
112
+ const env = (process.env.SHELLAPPS_ENV || 'development') as Environment;
113
+
114
+ if (!configs[env]) {
115
+ throw new Error(`Invalid environment: ${env}. Must be one of: development, staging, production`);
116
+ }
117
+
118
+ return configs[env];
119
+ }
120
+
121
+ // Export individual getters for convenience
122
+ export function getEnvironment(): Environment {
123
+ return getConfig().environment;
124
+ }
125
+
126
+ export function getServiceUrls(): ServiceUrls {
127
+ return getConfig().serviceUrls;
128
+ }
129
+
130
+ export function getS3Config(): S3Config {
131
+ return getConfig().s3;
132
+ }
133
+
134
+ export function getMongoConfig(): MongoConfig {
135
+ return getConfig().mongodb;
136
+ }
137
+
138
+ export function getFeatureFlags(): FeatureFlags {
139
+ return getConfig().featureFlags;
140
+ }
141
+
142
+ // Default export
143
+ export default {
144
+ getConfig,
145
+ getEnvironment,
146
+ getServiceUrls,
147
+ getS3Config,
148
+ getMongoConfig,
149
+ getFeatureFlags,
150
+ };