@etohq/framework 1.0.0
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 +0 -0
- package/dist/build-tools/compiler.d.ts +49 -0
- package/dist/build-tools/compiler.d.ts.map +1 -0
- package/dist/build-tools/compiler.js +291 -0
- package/dist/build-tools/compiler.js.map +1 -0
- package/dist/build-tools/index.d.ts +2 -0
- package/dist/build-tools/index.d.ts.map +1 -0
- package/dist/build-tools/index.js +18 -0
- package/dist/build-tools/index.js.map +1 -0
- package/dist/config/config.d.ts +34 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +132 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +21 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +35 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +901 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -0
- package/dist/container.d.ts +3 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +21 -0
- package/dist/container.js.map +1 -0
- package/dist/database/index.d.ts +3 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +19 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/pg-connection-loader.d.ts +6 -0
- package/dist/database/pg-connection-loader.d.ts.map +1 -0
- package/dist/database/pg-connection-loader.js +37 -0
- package/dist/database/pg-connection-loader.js.map +1 -0
- package/dist/eto-app-loader.d.ts +51 -0
- package/dist/eto-app-loader.d.ts.map +1 -0
- package/dist/eto-app-loader.js +183 -0
- package/dist/eto-app-loader.js.map +1 -0
- package/dist/feature-flags/feature-flag-loader.d.ts +8 -0
- package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -0
- package/dist/feature-flags/feature-flag-loader.js +81 -0
- package/dist/feature-flags/feature-flag-loader.js.map +1 -0
- package/dist/feature-flags/flag-router.d.ts +32 -0
- package/dist/feature-flags/flag-router.d.ts.map +1 -0
- package/dist/feature-flags/flag-router.js +67 -0
- package/dist/feature-flags/flag-router.js.map +1 -0
- package/dist/feature-flags/index.d.ts +5 -0
- package/dist/feature-flags/index.d.ts.map +1 -0
- package/dist/feature-flags/index.js +21 -0
- package/dist/feature-flags/index.js.map +1 -0
- package/dist/feature-flags/types.d.ts +31 -0
- package/dist/feature-flags/types.d.ts.map +1 -0
- package/dist/feature-flags/types.js +3 -0
- package/dist/feature-flags/types.js.map +1 -0
- package/dist/http/express-loader.d.ts +8 -0
- package/dist/http/express-loader.d.ts.map +1 -0
- package/dist/http/express-loader.js +85 -0
- package/dist/http/express-loader.js.map +1 -0
- package/dist/http/index.d.ts +15 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +31 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/middlewares/apply-default-filters.d.ts +3 -0
- package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -0
- package/dist/http/middlewares/apply-default-filters.js +32 -0
- package/dist/http/middlewares/apply-default-filters.js.map +1 -0
- package/dist/http/middlewares/apply-params-as-filters.d.ts +5 -0
- package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -0
- package/dist/http/middlewares/apply-params-as-filters.js +14 -0
- package/dist/http/middlewares/apply-params-as-filters.js.map +1 -0
- package/dist/http/middlewares/authenticate-middleware.d.ts +11 -0
- package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -0
- package/dist/http/middlewares/authenticate-middleware.js +135 -0
- package/dist/http/middlewares/authenticate-middleware.js.map +1 -0
- package/dist/http/middlewares/clear-filters-by-key.d.ts +3 -0
- package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -0
- package/dist/http/middlewares/clear-filters-by-key.js +12 -0
- package/dist/http/middlewares/clear-filters-by-key.js.map +1 -0
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts +3 -0
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -0
- package/dist/http/middlewares/ensure-publishable-api-key.js +49 -0
- package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -0
- package/dist/http/middlewares/error-handler.d.ts +23 -0
- package/dist/http/middlewares/error-handler.d.ts.map +1 -0
- package/dist/http/middlewares/error-handler.js +85 -0
- package/dist/http/middlewares/error-handler.js.map +1 -0
- package/dist/http/middlewares/exception-formatter.d.ts +9 -0
- package/dist/http/middlewares/exception-formatter.d.ts.map +1 -0
- package/dist/http/middlewares/exception-formatter.js +36 -0
- package/dist/http/middlewares/exception-formatter.js.map +1 -0
- package/dist/http/middlewares/index.d.ts +8 -0
- package/dist/http/middlewares/index.d.ts.map +1 -0
- package/dist/http/middlewares/index.js +24 -0
- package/dist/http/middlewares/index.js.map +1 -0
- package/dist/http/middlewares/set-context.d.ts +3 -0
- package/dist/http/middlewares/set-context.d.ts.map +1 -0
- package/dist/http/middlewares/set-context.js +18 -0
- package/dist/http/middlewares/set-context.js.map +1 -0
- package/dist/http/router.d.ts +100 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +764 -0
- package/dist/http/router.js.map +1 -0
- package/dist/http/types.d.ts +141 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +16 -0
- package/dist/http/types.js.map +1 -0
- package/dist/http/utils/define-middlewares.d.ts +18 -0
- package/dist/http/utils/define-middlewares.d.ts.map +1 -0
- package/dist/http/utils/define-middlewares.js +40 -0
- package/dist/http/utils/define-middlewares.js.map +1 -0
- package/dist/http/utils/get-query-config.d.ts +42 -0
- package/dist/http/utils/get-query-config.d.ts.map +1 -0
- package/dist/http/utils/get-query-config.js +183 -0
- package/dist/http/utils/get-query-config.js.map +1 -0
- package/dist/http/utils/http-compression.d.ts +5 -0
- package/dist/http/utils/http-compression.d.ts.map +1 -0
- package/dist/http/utils/http-compression.js +33 -0
- package/dist/http/utils/http-compression.js.map +1 -0
- package/dist/http/utils/maybe-apply-link-filter.d.ts +8 -0
- package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -0
- package/dist/http/utils/maybe-apply-link-filter.js +71 -0
- package/dist/http/utils/maybe-apply-link-filter.js.map +1 -0
- package/dist/http/utils/refetch-entities.d.ts +5 -0
- package/dist/http/utils/refetch-entities.d.ts.map +1 -0
- package/dist/http/utils/refetch-entities.js +29 -0
- package/dist/http/utils/refetch-entities.js.map +1 -0
- package/dist/http/utils/restricted-fields.d.ts +6 -0
- package/dist/http/utils/restricted-fields.d.ts.map +1 -0
- package/dist/http/utils/restricted-fields.js +30 -0
- package/dist/http/utils/restricted-fields.js.map +1 -0
- package/dist/http/utils/unless-path.d.ts +9 -0
- package/dist/http/utils/unless-path.d.ts.map +1 -0
- package/dist/http/utils/unless-path.js +19 -0
- package/dist/http/utils/unless-path.js.map +1 -0
- package/dist/http/utils/validate-body.d.ts +5 -0
- package/dist/http/utils/validate-body.d.ts.map +1 -0
- package/dist/http/utils/validate-body.js +23 -0
- package/dist/http/utils/validate-body.js.map +1 -0
- package/dist/http/utils/validate-query.d.ts +6 -0
- package/dist/http/utils/validate-query.d.ts.map +1 -0
- package/dist/http/utils/validate-query.js +79 -0
- package/dist/http/utils/validate-query.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/index.d.ts +2 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +18 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/job-loader.d.ts +37 -0
- package/dist/jobs/job-loader.d.ts.map +1 -0
- package/dist/jobs/job-loader.js +130 -0
- package/dist/jobs/job-loader.js.map +1 -0
- package/dist/links/index.d.ts +2 -0
- package/dist/links/index.d.ts.map +1 -0
- package/dist/links/index.js +18 -0
- package/dist/links/index.js.map +1 -0
- package/dist/links/link-loader.d.ts +10 -0
- package/dist/links/link-loader.d.ts.map +1 -0
- package/dist/links/link-loader.js +74 -0
- package/dist/links/link-loader.js.map +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +9 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/mikro-orm-cli/bin.d.ts +14 -0
- package/dist/mikro-orm-cli/bin.d.ts.map +1 -0
- package/dist/mikro-orm-cli/bin.js +54 -0
- package/dist/mikro-orm-cli/bin.js.map +1 -0
- package/dist/modules-sdk/index.d.ts +2 -0
- package/dist/modules-sdk/index.d.ts.map +1 -0
- package/dist/modules-sdk/index.js +18 -0
- package/dist/modules-sdk/index.js.map +1 -0
- package/dist/orchestration/index.d.ts +2 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +18 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/subscribers/index.d.ts +3 -0
- package/dist/subscribers/index.d.ts.map +1 -0
- package/dist/subscribers/index.js +19 -0
- package/dist/subscribers/index.js.map +1 -0
- package/dist/subscribers/subscriber-loader.d.ts +11 -0
- package/dist/subscribers/subscriber-loader.d.ts.map +1 -0
- package/dist/subscribers/subscriber-loader.js +196 -0
- package/dist/subscribers/subscriber-loader.js.map +1 -0
- package/dist/subscribers/types.d.ts +15 -0
- package/dist/subscribers/types.d.ts.map +1 -0
- package/dist/subscribers/types.js +3 -0
- package/dist/subscribers/types.js.map +1 -0
- package/dist/telemetry/index.d.ts +50 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +81 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/types/container.d.ts +62 -0
- package/dist/types/container.d.ts.map +1 -0
- package/dist/types/container.js +3 -0
- package/dist/types/container.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/workflows/index.d.ts +3 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +19 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/workflow-loader.d.ts +10 -0
- package/dist/workflows/workflow-loader.d.ts.map +1 -0
- package/dist/workflows/workflow-loader.js +74 -0
- package/dist/workflows/workflow-loader.js.map +1 -0
- package/dist/workflows-sdk/composer.d.ts +2 -0
- package/dist/workflows-sdk/composer.d.ts.map +1 -0
- package/dist/workflows-sdk/composer.js +18 -0
- package/dist/workflows-sdk/composer.js.map +1 -0
- package/dist/workflows-sdk/index.d.ts +3 -0
- package/dist/workflows-sdk/index.d.ts.map +1 -0
- package/dist/workflows-sdk/index.js +19 -0
- package/dist/workflows-sdk/index.js.map +1 -0
- package/dist/zod/index.d.ts +2 -0
- package/dist/zod/index.d.ts.map +1 -0
- package/dist/zod/index.js +18 -0
- package/dist/zod/index.js.map +1 -0
- package/dist/zod/zod-helpers.d.ts +3 -0
- package/dist/zod/zod-helpers.d.ts.map +1 -0
- package/dist/zod/zod-helpers.js +95 -0
- package/dist/zod/zod-helpers.js.map +1 -0
- package/package.json +120 -0
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@etohq/types";
|
|
2
|
+
import type { RedisOptions } from "ioredis";
|
|
3
|
+
import type { InlineConfig } from "vite";
|
|
4
|
+
/**
|
|
5
|
+
* @interface
|
|
6
|
+
*
|
|
7
|
+
* Admin dashboard configurations.
|
|
8
|
+
*/
|
|
9
|
+
export type AdminOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to disable the admin dashboard. If set to `true`, the admin dashboard is disabled,
|
|
12
|
+
* in both development and production environments. The default value is `false`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts title="eto-config.ts"
|
|
16
|
+
* module.exports = defineConfig({
|
|
17
|
+
* admin: {
|
|
18
|
+
* disable: process.env.ADMIN_DISABLED === "true" ||
|
|
19
|
+
* false
|
|
20
|
+
* },
|
|
21
|
+
* // ...
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
disable?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The path to the admin dashboard. The default value is `/app`.
|
|
28
|
+
*
|
|
29
|
+
* The value cannot be one of the reserved paths:
|
|
30
|
+
* - `/admin`
|
|
31
|
+
* - `/store`
|
|
32
|
+
* - `/auth`
|
|
33
|
+
* - `/`
|
|
34
|
+
*
|
|
35
|
+
* :::note
|
|
36
|
+
*
|
|
37
|
+
* When using Docker, make sure that the root path of the Docker image doesn't path the admin's `path`. For example, if the Docker image's root path is `/app`, change
|
|
38
|
+
* the value of the `path` configuration, as it's `/app` by default.
|
|
39
|
+
*
|
|
40
|
+
* :::
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts title="eto-config.ts"
|
|
44
|
+
* module.exports = defineConfig({
|
|
45
|
+
* admin: {
|
|
46
|
+
* path: process.env.ADMIN_PATH || `/app`,
|
|
47
|
+
* },
|
|
48
|
+
* // ...
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
path?: `/${string}`;
|
|
53
|
+
/**
|
|
54
|
+
* The directory where the admin build is outputted when you run the `build` command.
|
|
55
|
+
* The default value is `./build`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts title="eto-config.ts"
|
|
59
|
+
* module.exports = defineConfig({
|
|
60
|
+
* admin: {
|
|
61
|
+
* outDir: process.env.ADMIN_BUILD_DIR || `./build`,
|
|
62
|
+
* },
|
|
63
|
+
* // ...
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
outDir?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The URL of your Eto application. Defaults to the browser origin. This is useful to set when running the admin on a separate domain.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts title="eto-config.ts"
|
|
73
|
+
* module.exports = defineConfig({
|
|
74
|
+
* admin: {
|
|
75
|
+
* backendUrl: process.env.ETO_BACKEND_URL ||
|
|
76
|
+
* "http://localhost:9000"
|
|
77
|
+
* },
|
|
78
|
+
* // ...
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
backendUrl?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Configure the Vite configuration for the admin dashboard. This function receives the default Vite configuration
|
|
85
|
+
* and returns the modified configuration. The default value is `undefined`.
|
|
86
|
+
*
|
|
87
|
+
* @privateRemarks TODO Add example
|
|
88
|
+
*/
|
|
89
|
+
vite?: (config: InlineConfig) => InlineConfig;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* @interface
|
|
93
|
+
*
|
|
94
|
+
* Options to pass to `express-session`.
|
|
95
|
+
*/
|
|
96
|
+
type SessionOptions = {
|
|
97
|
+
/**
|
|
98
|
+
* The name of the session ID cookie to set in the response (and read from in the request). The default value is `connect.sid`.
|
|
99
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#name) for more details.
|
|
100
|
+
*/
|
|
101
|
+
name?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the session should be saved back to the session store, even if the session was never modified during the request. The default value is `true`.
|
|
104
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#resave) for more details.
|
|
105
|
+
*/
|
|
106
|
+
resave?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the session identifier cookie should be force-set on every response. The default value is `false`.
|
|
109
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#rolling) for more details.
|
|
110
|
+
*/
|
|
111
|
+
rolling?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether a session that is "uninitialized" is forced to be saved to the store. The default value is `true`.
|
|
114
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#saveUninitialized) for more details.
|
|
115
|
+
*/
|
|
116
|
+
saveUninitialized?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The secret to sign the session ID cookie. By default, the value of `http.cookieSecret` is used.
|
|
119
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#secret) for details.
|
|
120
|
+
*/
|
|
121
|
+
secret?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Used when calculating the `Expires` `Set-Cookie` attribute of cookies. By default, its value is `10 * 60 * 60 * 1000`.
|
|
124
|
+
* Refer to [express-session’s documentation](https://www.npmjs.com/package/express-session#cookiemaxage) for details.
|
|
125
|
+
*/
|
|
126
|
+
ttl?: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* @interface
|
|
130
|
+
*
|
|
131
|
+
* HTTP compression configurations.
|
|
132
|
+
*/
|
|
133
|
+
export type HttpCompressionOptions = {
|
|
134
|
+
/**
|
|
135
|
+
* Whether HTTP compression is enabled. By default, it's `false`.
|
|
136
|
+
*/
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The level of zlib compression to apply to responses. A higher level will result in better compression but will take longer to complete.
|
|
140
|
+
* A lower level will result in less compression but will be much faster. The default value is `6`.
|
|
141
|
+
*/
|
|
142
|
+
level?: number;
|
|
143
|
+
/**
|
|
144
|
+
* How much memory should be allocated to the internal compression state. It's an integer in the range of 1 (minimum level) and 9 (maximum level).
|
|
145
|
+
* The default value is `8`.
|
|
146
|
+
*/
|
|
147
|
+
memLevel?: number;
|
|
148
|
+
/**
|
|
149
|
+
* The minimum response body size that compression is applied on. Its value can be the number of bytes or any string accepted by the
|
|
150
|
+
* [bytes](https://www.npmjs.com/package/bytes) module. The default value is `1024`.
|
|
151
|
+
*/
|
|
152
|
+
threshold?: number | string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @interface
|
|
156
|
+
*
|
|
157
|
+
* Essential configurations related to the Eto application, such as database and CORS configurations.
|
|
158
|
+
*/
|
|
159
|
+
export type ProjectConfigOptions = {
|
|
160
|
+
/**
|
|
161
|
+
* The name of the database to connect to. If the name is specified in `databaseUrl`, then you don't have to use this configuration.
|
|
162
|
+
*
|
|
163
|
+
* Make sure to create the PostgreSQL database before using it. You can check how to create a database in
|
|
164
|
+
* [PostgreSQL's documentation](https://www.postgresql.org/docs/current/sql-createdatabase.html).
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts title="eto-config.ts"
|
|
168
|
+
* module.exports = defineConfig({
|
|
169
|
+
* projectConfig: {
|
|
170
|
+
* databaseName: process.env.DATABASE_NAME ||
|
|
171
|
+
* "eto-store",
|
|
172
|
+
* // ...
|
|
173
|
+
* },
|
|
174
|
+
* // ...
|
|
175
|
+
* })
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
databaseName?: string;
|
|
179
|
+
/**
|
|
180
|
+
* The PostgreSQL connection URL of the database, which is of the following format:
|
|
181
|
+
*
|
|
182
|
+
* ```bash
|
|
183
|
+
* postgres://[user][:password]@[host][:port]/[dbname]
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* Where:
|
|
187
|
+
*
|
|
188
|
+
* - `[user]`: (required) your PostgreSQL username. If not specified, the system's username is used by default. The database user that you use must have create privileges. If you're using the `postgres` superuser, then it should have these privileges by default. Otherwise, make sure to grant your user create privileges. You can learn how to do that in [PostgreSQL's documentation](https://www.postgresql.org/docs/current/ddl-priv.html).
|
|
189
|
+
* - `[:password]`: an optional password for the user. When provided, make sure to put `:` before the password.
|
|
190
|
+
* - `[host]`: (required) your PostgreSQL host. When run locally, it should be `localhost`.
|
|
191
|
+
* - `[:port]`: an optional port that the PostgreSQL server is listening on. By default, it's `5432`. When provided, make sure to put `:` before the port.
|
|
192
|
+
* - `[dbname]`: (required) the name of the database.
|
|
193
|
+
*
|
|
194
|
+
* You can learn more about the connection URL format in [PostgreSQL’s documentation](https://www.postgresql.org/docs/current/libpq-connect.html).
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* For example, set the following database URL in your environment variables:
|
|
198
|
+
*
|
|
199
|
+
* ```bash
|
|
200
|
+
* DATABASE_URL=postgres://postgres@localhost/eto-store
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* Then, use the value in `eto-config.ts`:
|
|
204
|
+
*
|
|
205
|
+
* ```ts title="eto-config.ts"
|
|
206
|
+
* module.exports = defineConfig({
|
|
207
|
+
* projectConfig: {
|
|
208
|
+
* databaseUrl: process.env.DATABASE_URL,
|
|
209
|
+
* // ...
|
|
210
|
+
* },
|
|
211
|
+
* // ...
|
|
212
|
+
* })
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
databaseUrl?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The database schema to connect to. This is not required to provide if you’re using the default schema, which is `public`.
|
|
218
|
+
*
|
|
219
|
+
* ```ts title="eto-config.ts"
|
|
220
|
+
* module.exports = defineConfig({
|
|
221
|
+
* projectConfig: {
|
|
222
|
+
* databaseSchema: process.env.DATABASE_SCHEMA ||
|
|
223
|
+
* "custom",
|
|
224
|
+
* // ...
|
|
225
|
+
* },
|
|
226
|
+
* // ...
|
|
227
|
+
* })
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
databaseSchema?: string;
|
|
231
|
+
/**
|
|
232
|
+
* This configuration specifies whether database messages should be logged.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts title="eto-config.ts"
|
|
236
|
+
* module.exports = defineConfig({
|
|
237
|
+
* projectConfig: {
|
|
238
|
+
* databaseLogging: false
|
|
239
|
+
* // ...
|
|
240
|
+
* },
|
|
241
|
+
* // ...
|
|
242
|
+
* })
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
databaseLogging?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* This configuration is used to pass additional options to the database connection. You can pass any configuration. For example, pass the
|
|
248
|
+
* `ssl` property that enables support for TLS/SSL connections.
|
|
249
|
+
*
|
|
250
|
+
* This is useful for production databases, which can be supported by setting the `rejectUnauthorized` attribute of `ssl` object to `false`.
|
|
251
|
+
* During development, it’s recommended not to pass this option.
|
|
252
|
+
*
|
|
253
|
+
* :::note
|
|
254
|
+
*
|
|
255
|
+
* Make sure to add to the end of the database URL `?ssl_mode=disable` as well when disabling `rejectUnauthorized`.
|
|
256
|
+
*
|
|
257
|
+
* :::
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts title="eto-config.ts"
|
|
261
|
+
* module.exports = defineConfig({
|
|
262
|
+
* projectConfig: {
|
|
263
|
+
* databaseDriverOptions: process.env.NODE_ENV !== "development" ?
|
|
264
|
+
* { connection: { ssl: { rejectUnauthorized: false } } } : {}
|
|
265
|
+
* // ...
|
|
266
|
+
* },
|
|
267
|
+
* // ...
|
|
268
|
+
* })
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
databaseDriverOptions?: Record<string, any> & {
|
|
272
|
+
connection?: {
|
|
273
|
+
/**
|
|
274
|
+
* Configure support for TLS/SSL connection
|
|
275
|
+
*/
|
|
276
|
+
ssl?: {
|
|
277
|
+
/**
|
|
278
|
+
* Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.
|
|
279
|
+
*/
|
|
280
|
+
rejectUnauthorized?: false;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* This configuration specifies the connection URL to Redis to store the Eto server's session.
|
|
286
|
+
*
|
|
287
|
+
* :::note
|
|
288
|
+
*
|
|
289
|
+
* You must first have Redis installed. You can refer to [Redis's installation guide](https://redis.io/docs/getting-started/installation/).
|
|
290
|
+
*
|
|
291
|
+
* :::
|
|
292
|
+
*
|
|
293
|
+
* The Redis connection URL has the following format:
|
|
294
|
+
*
|
|
295
|
+
* ```bash
|
|
296
|
+
* redis[s]://[[username][:password]@][host][:port][/db-number]
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* For a local Redis installation, the connection URL should be `redis://localhost:6379` unless you’ve made any changes to the Redis configuration during installation.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts title="eto-config.ts"
|
|
303
|
+
* module.exports = defineConfig({
|
|
304
|
+
* projectConfig: {
|
|
305
|
+
* redisUrl: process.env.REDIS_URL ||
|
|
306
|
+
* "redis://localhost:6379",
|
|
307
|
+
* // ...
|
|
308
|
+
* },
|
|
309
|
+
* // ...
|
|
310
|
+
* })
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
redisUrl?: string;
|
|
314
|
+
/**
|
|
315
|
+
* This configuration defines a prefix on all keys stored in Redis for the Eto server's session. The default value is `sess:`.
|
|
316
|
+
*
|
|
317
|
+
* If this configuration option is provided, it is prepended to `sess:`.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts title="eto-config.ts"
|
|
321
|
+
* module.exports = defineConfig({
|
|
322
|
+
* projectConfig: {
|
|
323
|
+
* redisPrefix: process.env.REDIS_URL || "eto:",
|
|
324
|
+
* // ...
|
|
325
|
+
* },
|
|
326
|
+
* // ...
|
|
327
|
+
* })
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
redisPrefix?: string;
|
|
331
|
+
/**
|
|
332
|
+
* This configuration defines options to pass ioredis for the Redis connection used to store the Eto server's session. Refer to [ioredis’s RedisOptions documentation](https://redis.github.io/ioredis/index.html#RedisOptions)
|
|
333
|
+
* for the list of available options.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts title="eto-config.ts"
|
|
337
|
+
* module.exports = defineConfig({
|
|
338
|
+
* projectConfig: {
|
|
339
|
+
* redisOptions: {
|
|
340
|
+
* connectionName: process.env.REDIS_CONNECTION_NAME ||
|
|
341
|
+
* "eto",
|
|
342
|
+
* }
|
|
343
|
+
* // ...
|
|
344
|
+
* },
|
|
345
|
+
* // ...
|
|
346
|
+
* })
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
redisOptions?: RedisOptions;
|
|
350
|
+
/**
|
|
351
|
+
* This configuration defines additional options to pass to [express-session](https://www.npmjs.com/package/express-session), which is used to store the Eto server's session.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts title="eto-config.ts"
|
|
355
|
+
* module.exports = defineConfig({
|
|
356
|
+
* projectConfig: {
|
|
357
|
+
* sessionOptions: {
|
|
358
|
+
* name: process.env.SESSION_NAME || "custom",
|
|
359
|
+
* }
|
|
360
|
+
* // ...
|
|
361
|
+
* },
|
|
362
|
+
* // ...
|
|
363
|
+
* })
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
sessionOptions?: SessionOptions;
|
|
367
|
+
/**
|
|
368
|
+
* Configure the number of staged jobs that are polled from the database. Default is `1000`.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts title="eto-config.ts"
|
|
372
|
+
* module.exports = defineConfig({
|
|
373
|
+
* projectConfig: {
|
|
374
|
+
* jobsBatchSize: 100
|
|
375
|
+
* // ...
|
|
376
|
+
* },
|
|
377
|
+
* // ...
|
|
378
|
+
* })
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @ignore
|
|
382
|
+
*
|
|
383
|
+
* @privateRemarks
|
|
384
|
+
* Couldn't find any use for this option.
|
|
385
|
+
*/
|
|
386
|
+
jobsBatchSize?: number;
|
|
387
|
+
/**
|
|
388
|
+
* Configure the application's worker mode.
|
|
389
|
+
*
|
|
390
|
+
* Workers are processes running separately from the main application. They're useful for executing long-running or resource-heavy tasks in the background, such as importing products.
|
|
391
|
+
*
|
|
392
|
+
* With a worker, these tasks are offloaded to a separate process. So, they won't affect the performance of the main application.
|
|
393
|
+
*
|
|
394
|
+
* 
|
|
395
|
+
*
|
|
396
|
+
* Eto has three runtime modes:
|
|
397
|
+
*
|
|
398
|
+
* - Use `shared` to run the application in a single process.
|
|
399
|
+
* - Use `worker` to run the a worker process only.
|
|
400
|
+
* - Use `server` to run the application server only.
|
|
401
|
+
*
|
|
402
|
+
* In production, it's recommended to deploy two instances:
|
|
403
|
+
*
|
|
404
|
+
* 1. One having the `workerMode` configuration set to `server`.
|
|
405
|
+
* 2. Another having the `workerMode` configuration set to `worker`.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```ts title="eto-config.ts"
|
|
409
|
+
* module.exports = defineConfig({
|
|
410
|
+
* projectConfig: {
|
|
411
|
+
* workerMode: process.env.WORKER_MODE || "shared"
|
|
412
|
+
* // ...
|
|
413
|
+
* },
|
|
414
|
+
* // ...
|
|
415
|
+
* })
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
workerMode?: "shared" | "worker" | "server";
|
|
419
|
+
/**
|
|
420
|
+
* This property configures the application's http-specific settings.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts title="eto-config.ts"
|
|
424
|
+
* module.exports = defineConfig({
|
|
425
|
+
* projectConfig: {
|
|
426
|
+
* http: {
|
|
427
|
+
* cookieSecret: "supersecret",
|
|
428
|
+
* compression: {
|
|
429
|
+
* // ...
|
|
430
|
+
* }
|
|
431
|
+
* }
|
|
432
|
+
* // ...
|
|
433
|
+
* },
|
|
434
|
+
* // ...
|
|
435
|
+
* })
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
http: {
|
|
439
|
+
/**
|
|
440
|
+
* A random string used to create authentication tokens in the http layer. Although this configuration option is not required, it’s highly recommended to set it for better security.
|
|
441
|
+
*
|
|
442
|
+
* In a development environment, if this option is not set the default secret is `supersecret`. However, in production, if this configuration is not set, an
|
|
443
|
+
* error is thrown and the application crashes.
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts title="eto-config.ts"
|
|
447
|
+
* module.exports = defineConfig({
|
|
448
|
+
* projectConfig: {
|
|
449
|
+
* http: {
|
|
450
|
+
* jwtSecret: "supersecret",
|
|
451
|
+
* }
|
|
452
|
+
* // ...
|
|
453
|
+
* },
|
|
454
|
+
* // ...
|
|
455
|
+
* })
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
jwtSecret?: string;
|
|
459
|
+
/**
|
|
460
|
+
* The expiration time for the JWT token. Its format is based off the [ms package](https://github.com/vercel/ms).
|
|
461
|
+
*
|
|
462
|
+
* If not provided, the default value is `24h`.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```ts title="eto-config.ts"
|
|
466
|
+
* module.exports = defineConfig({
|
|
467
|
+
* projectConfig: {
|
|
468
|
+
* http: {
|
|
469
|
+
* jwtExpiresIn: "2d"
|
|
470
|
+
* }
|
|
471
|
+
* // ...
|
|
472
|
+
* },
|
|
473
|
+
* // ...
|
|
474
|
+
* })
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
jwtExpiresIn?: string;
|
|
478
|
+
/**
|
|
479
|
+
* A random string used to create cookie tokens in the http layer. Although this configuration option is not required, it’s highly recommended to set it for better security.
|
|
480
|
+
*
|
|
481
|
+
* In a development environment, if this option is not set, the default secret is `supersecret`. However, in production, if this configuration is not set, an error is thrown and
|
|
482
|
+
* the application crashes.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts title="eto-config.ts"
|
|
486
|
+
* module.exports = defineConfig({
|
|
487
|
+
* projectConfig: {
|
|
488
|
+
* http: {
|
|
489
|
+
* cookieSecret: "supersecret"
|
|
490
|
+
* }
|
|
491
|
+
* // ...
|
|
492
|
+
* },
|
|
493
|
+
* // ...
|
|
494
|
+
* })
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
cookieSecret?: string;
|
|
498
|
+
/**
|
|
499
|
+
* The Eto application's API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backend’s API Routes.
|
|
500
|
+
*
|
|
501
|
+
* `cors` is a string used to specify the accepted URLs or patterns for API Routes starting with `/auth`. It can either be one accepted origin, or a comma-separated list of accepted origins.
|
|
502
|
+
*
|
|
503
|
+
* Every origin in that list must either be:
|
|
504
|
+
*
|
|
505
|
+
* 1. A URL. For example, `http://localhost:7001`. The URL must not end with a backslash;
|
|
506
|
+
* 2. Or a regular expression pattern that can match more than one origin. For example, `.example.com`. The regex pattern that Eto tests for is `^([\/~@;%#'])(.*?)\1([gimsuy]*)$`.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* Some example values of common use cases:
|
|
510
|
+
*
|
|
511
|
+
* ```bash
|
|
512
|
+
* # Allow different ports locally starting with 700
|
|
513
|
+
* AUTH_CORS=/http:\/\/localhost:700\d+$/
|
|
514
|
+
*
|
|
515
|
+
* # Allow any origin ending with vercel.app. For example, admin.vercel.app
|
|
516
|
+
* AUTH_CORS=/vercel\.app$/
|
|
517
|
+
*
|
|
518
|
+
* # Allow all HTTP requests
|
|
519
|
+
* AUTH_CORS=/http:\/\/.+/
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* Then, set the configuration in `eto-config.ts`:
|
|
523
|
+
*
|
|
524
|
+
* ```ts title="eto-config.ts"
|
|
525
|
+
* module.exports = defineConfig({
|
|
526
|
+
* projectConfig: {
|
|
527
|
+
* http: {
|
|
528
|
+
* authCors: process.env.AUTH_CORS
|
|
529
|
+
* }
|
|
530
|
+
* // ...
|
|
531
|
+
* },
|
|
532
|
+
* // ...
|
|
533
|
+
* })
|
|
534
|
+
* ```
|
|
535
|
+
*
|
|
536
|
+
* If you’re adding the value directly within `eto-config.ts`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
|
537
|
+
*
|
|
538
|
+
* ```ts title="eto-config.ts"
|
|
539
|
+
* module.exports = defineConfig({
|
|
540
|
+
* projectConfig: {
|
|
541
|
+
* http: {
|
|
542
|
+
* authCors: "/http:\\/\\/localhost:700\\d+$/",
|
|
543
|
+
* }
|
|
544
|
+
* // ...
|
|
545
|
+
* },
|
|
546
|
+
* // ...
|
|
547
|
+
* })
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
authCors: string;
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
* Configure HTTP compression from the application layer. If you have access to the HTTP server, the recommended approach would be to enable it there.
|
|
554
|
+
* However, some platforms don't offer access to the HTTP layer and in those cases, this is a good alternative.
|
|
555
|
+
*
|
|
556
|
+
* If you enable HTTP compression and you want to disable it for specific API Routes, you can pass in the request header `"x-no-compression": true`.
|
|
557
|
+
* Learn more in the [API Reference](https://docs.etohq.com/api/store#http-compression).
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```ts title="eto-config.ts"
|
|
561
|
+
* module.exports = defineConfig({
|
|
562
|
+
* projectConfig: {
|
|
563
|
+
* http: {
|
|
564
|
+
* compression: {
|
|
565
|
+
* enabled: true,
|
|
566
|
+
* level: 6,
|
|
567
|
+
* memLevel: 8,
|
|
568
|
+
* threshold: 1024
|
|
569
|
+
* }
|
|
570
|
+
* }
|
|
571
|
+
* // ...
|
|
572
|
+
* },
|
|
573
|
+
* // ...
|
|
574
|
+
* })
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
compression?: HttpCompressionOptions;
|
|
578
|
+
/**
|
|
579
|
+
* The Eto application's API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backend’s API Routes.
|
|
580
|
+
*
|
|
581
|
+
* `store_cors` is a string used to specify the accepted URLs or patterns for store API Routes. It can either be one accepted origin, or a comma-separated list of accepted origins.
|
|
582
|
+
*
|
|
583
|
+
* Every origin in that list must either be:
|
|
584
|
+
*
|
|
585
|
+
* 1. A URL. For example, `http://localhost:8000`. The URL must not end with a backslash;
|
|
586
|
+
* 2. Or a regular expression pattern that can match more than one origin. For example, `.example.com`. The regex pattern that the backend tests for is `^([\/~@;%#'])(.*?)\1([gimsuy]*)$`.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* Some example values of common use cases:
|
|
590
|
+
*
|
|
591
|
+
* ```bash
|
|
592
|
+
* # Allow different ports locally starting with 800
|
|
593
|
+
* STORE_CORS=/http:\/\/localhost:800\d+$/
|
|
594
|
+
*
|
|
595
|
+
* # Allow any origin ending with vercel.app. For example, storefront.vercel.app
|
|
596
|
+
* STORE_CORS=/vercel\.app$/
|
|
597
|
+
*
|
|
598
|
+
* # Allow all HTTP requests
|
|
599
|
+
* STORE_CORS=/http:\/\/.+/
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* Then, set the configuration in `eto-config.ts`:
|
|
603
|
+
*
|
|
604
|
+
* ```ts title="eto-config.ts"
|
|
605
|
+
* module.exports = defineConfig({
|
|
606
|
+
* projectConfig: {
|
|
607
|
+
* http: {
|
|
608
|
+
* storeCors: process.env.STORE_CORS,
|
|
609
|
+
* }
|
|
610
|
+
* // ...
|
|
611
|
+
* },
|
|
612
|
+
* // ...
|
|
613
|
+
* })
|
|
614
|
+
* ```
|
|
615
|
+
*
|
|
616
|
+
* If you’re adding the value directly within `eto-config.ts`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
|
617
|
+
*
|
|
618
|
+
* ```ts title="eto-config.ts"
|
|
619
|
+
* module.exports = defineConfig({
|
|
620
|
+
* projectConfig: {
|
|
621
|
+
* http: {
|
|
622
|
+
* storeCors: "/vercel\\.app$/",
|
|
623
|
+
* }
|
|
624
|
+
* // ...
|
|
625
|
+
* },
|
|
626
|
+
* // ...
|
|
627
|
+
* })
|
|
628
|
+
* ```
|
|
629
|
+
*/
|
|
630
|
+
storeCors: string;
|
|
631
|
+
/**
|
|
632
|
+
* The Eto application's API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backend’s API Routes.
|
|
633
|
+
*
|
|
634
|
+
* `admin_cors` is a string used to specify the accepted URLs or patterns for admin API Routes. It can either be one accepted origin, or a comma-separated list of accepted origins.
|
|
635
|
+
*
|
|
636
|
+
* Every origin in that list must either be:
|
|
637
|
+
*
|
|
638
|
+
* 1. A URL. For example, `http://localhost:7001`. The URL must not end with a backslash;
|
|
639
|
+
* 2. Or a regular expression pattern that can match more than one origin. For example, `.example.com`. The regex pattern that the backend tests for is `^([\/~@;%#'])(.*?)\1([gimsuy]*)$`.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* Some example values of common use cases:
|
|
643
|
+
*
|
|
644
|
+
* ```bash
|
|
645
|
+
* # Allow different ports locally starting with 700
|
|
646
|
+
* ADMIN_CORS=/http:\/\/localhost:700\d+$/
|
|
647
|
+
*
|
|
648
|
+
* # Allow any origin ending with vercel.app. For example, admin.vercel.app
|
|
649
|
+
* ADMIN_CORS=/vercel\.app$/
|
|
650
|
+
*
|
|
651
|
+
* # Allow all HTTP requests
|
|
652
|
+
* ADMIN_CORS=/http:\/\/.+/
|
|
653
|
+
* ```
|
|
654
|
+
*
|
|
655
|
+
* Then, set the configuration in `eto-config.ts`:
|
|
656
|
+
*
|
|
657
|
+
* ```ts title="eto-config.ts"
|
|
658
|
+
* module.exports = defineConfig({
|
|
659
|
+
* projectConfig: {
|
|
660
|
+
* http: {
|
|
661
|
+
* adminCors: process.env.ADMIN_CORS,
|
|
662
|
+
* }
|
|
663
|
+
* // ...
|
|
664
|
+
* },
|
|
665
|
+
* // ...
|
|
666
|
+
* })
|
|
667
|
+
* ```
|
|
668
|
+
*
|
|
669
|
+
* If you’re adding the value directly within `eto-config.ts`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
|
670
|
+
*
|
|
671
|
+
* ```ts title="eto-config.ts"
|
|
672
|
+
* module.exports = defineConfig({
|
|
673
|
+
* projectConfig: {
|
|
674
|
+
* http: {
|
|
675
|
+
* adminCors: "/vercel\\.app$/",
|
|
676
|
+
* }
|
|
677
|
+
* // ...
|
|
678
|
+
* },
|
|
679
|
+
* // ...
|
|
680
|
+
* })
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
adminCors: string;
|
|
684
|
+
/**
|
|
685
|
+
* This configuration specifies the supported authentication providers per actor type (such as `user`, `customer`, or any custom actors).
|
|
686
|
+
* For example, you only want to allow SSO logins for `users`, while you want to allow email/password logins for `customers` to the storefront.
|
|
687
|
+
*
|
|
688
|
+
* `authMethodsPerActor` is a a map where the actor type (eg. 'user') is the key, and the value is an array of supported auth provider IDs.
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* Some example values of common use cases:
|
|
692
|
+
*
|
|
693
|
+
* Then, set the configuration in `eto-config.ts`:
|
|
694
|
+
*
|
|
695
|
+
* ```ts title="eto-config.ts"
|
|
696
|
+
* module.exports = defineConfig({
|
|
697
|
+
* projectConfig: {
|
|
698
|
+
* http: {
|
|
699
|
+
* authMethodsPerActor: {
|
|
700
|
+
* user: ["email"],
|
|
701
|
+
* customer: ["emailpass", "google"]
|
|
702
|
+
* }
|
|
703
|
+
* }
|
|
704
|
+
* // ...
|
|
705
|
+
* },
|
|
706
|
+
* // ...
|
|
707
|
+
* })
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
authMethodsPerActor?: Record<string, string[]>;
|
|
711
|
+
/**
|
|
712
|
+
* Specifies the fields that can't be selected in the response unless specified in the allowed query config.
|
|
713
|
+
* This is useful to restrict sensitive fields from being exposed in the API.
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
*
|
|
717
|
+
* ```js title="eto-config.js"
|
|
718
|
+
* module.exports = defineConfig({
|
|
719
|
+
* projectConfig: {
|
|
720
|
+
* http: {
|
|
721
|
+
* restrictedFields: {
|
|
722
|
+
* store: ["order", "orders"],
|
|
723
|
+
* }
|
|
724
|
+
* }
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
restrictedFields?: {
|
|
728
|
+
store?: string[];
|
|
729
|
+
};
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* @interface
|
|
734
|
+
*
|
|
735
|
+
* The configurations for your Eto application are in `eto-config.ts` located in the root of your Eto project. The configurations include configurations for database, modules, and more.
|
|
736
|
+
*
|
|
737
|
+
* `eto-config.ts` exports the value returned by the `defineConfig` utility function imported from `@etohq/framework/utils`.
|
|
738
|
+
*
|
|
739
|
+
* `defineConfig` accepts as a parameter an object with the following properties:
|
|
740
|
+
*
|
|
741
|
+
* - {@link ConfigModule.projectConfig | projectConfig} (required): An object that holds general configurations related to the Eto application, such as database or CORS configurations.
|
|
742
|
+
* - {@link ConfigModule.admin | admin}: An object that holds admin-related configurations.
|
|
743
|
+
* - {@link ConfigModule.modules | modules}: An object that configures the Eto application's modules.
|
|
744
|
+
* - {@link ConfigModule.featureFlags | featureFlags}: An object that enables or disables features guarded by a feature flag.
|
|
745
|
+
*
|
|
746
|
+
* For example:
|
|
747
|
+
*
|
|
748
|
+
* ```ts title="eto-config.ts"
|
|
749
|
+
* module.exports = defineConfig({
|
|
750
|
+
* projectConfig: {
|
|
751
|
+
* // ...
|
|
752
|
+
* },
|
|
753
|
+
* admin: {
|
|
754
|
+
* // ...
|
|
755
|
+
* },
|
|
756
|
+
* modules: {
|
|
757
|
+
* // ...
|
|
758
|
+
* },
|
|
759
|
+
* featureFlags: {
|
|
760
|
+
* // ...
|
|
761
|
+
* }
|
|
762
|
+
* })
|
|
763
|
+
* ```
|
|
764
|
+
*
|
|
765
|
+
* ---
|
|
766
|
+
*
|
|
767
|
+
* ## Environment Variables
|
|
768
|
+
*
|
|
769
|
+
* It's highly recommended to store the values of configurations in environment variables, then reference them within `eto-config.ts`.
|
|
770
|
+
*
|
|
771
|
+
* During development, you can set your environment variables in the `.env` file at the root of your Eto application project. In production,
|
|
772
|
+
* setting the environment variables depends on the hosting provider.
|
|
773
|
+
*
|
|
774
|
+
* ---
|
|
775
|
+
*/
|
|
776
|
+
export type ConfigModule = {
|
|
777
|
+
/**
|
|
778
|
+
* This property holds essential configurations related to the Eto application, such as database and CORS configurations.
|
|
779
|
+
*/
|
|
780
|
+
projectConfig: ProjectConfigOptions;
|
|
781
|
+
/**
|
|
782
|
+
* This property holds configurations for the Eto Admin dashboard.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```ts title="eto-config.ts"
|
|
786
|
+
* module.exports = defineConfig({
|
|
787
|
+
* admin: {
|
|
788
|
+
* backendUrl: process.env.ETO_BACKEND_URL ||
|
|
789
|
+
* "http://localhost:9000"
|
|
790
|
+
* },
|
|
791
|
+
* // ...
|
|
792
|
+
* })
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
admin?: AdminOptions;
|
|
796
|
+
/**
|
|
797
|
+
* On your Eto backend, you can use [Plugins](https://docs.etohq.com/development/plugins/overview) to add custom features or integrate third-party services.
|
|
798
|
+
* For example, installing a plugin to use Stripe as a payment processor.
|
|
799
|
+
*
|
|
800
|
+
* Aside from installing the plugin with NPM, you need to pass the plugin you installed into the `plugins` array defined in `eto-config.ts`.
|
|
801
|
+
*
|
|
802
|
+
* The items in the array can either be:
|
|
803
|
+
*
|
|
804
|
+
* - A string, which is the name of the plugin to add. You can pass a plugin as a string if it doesn’t require any configurations.
|
|
805
|
+
* - An object having the following properties:
|
|
806
|
+
* - `resolve`: The name of the plugin.
|
|
807
|
+
* - `options`: An object that includes the plugin’s options. These options vary for each plugin, and you should refer to the plugin’s documentation for available options.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* ```ts title="eto-config.ts"
|
|
811
|
+
* module.exports = {
|
|
812
|
+
* plugins: [
|
|
813
|
+
* `eto-my-plugin-1`,
|
|
814
|
+
* {
|
|
815
|
+
* resolve: `eto-my-plugin`,
|
|
816
|
+
* options: {
|
|
817
|
+
* apiKey: process.env.MY_API_KEY ||
|
|
818
|
+
* `test`,
|
|
819
|
+
* },
|
|
820
|
+
* },
|
|
821
|
+
* // ...
|
|
822
|
+
* ],
|
|
823
|
+
* // ...
|
|
824
|
+
* }
|
|
825
|
+
* ```
|
|
826
|
+
*
|
|
827
|
+
* @ignore
|
|
828
|
+
*
|
|
829
|
+
* @privateRemarks
|
|
830
|
+
* Added the `@\ignore` tag for now so it's not generated in the main docs until we figure out what to do with plugins
|
|
831
|
+
*/
|
|
832
|
+
plugins: ({
|
|
833
|
+
resolve: string;
|
|
834
|
+
options: Record<string, unknown>;
|
|
835
|
+
} | string)[];
|
|
836
|
+
/**
|
|
837
|
+
* This property holds all custom modules installed in your Eto application.
|
|
838
|
+
*
|
|
839
|
+
* :::note
|
|
840
|
+
*
|
|
841
|
+
* Eto's commerce modules are configured by default, so only
|
|
842
|
+
* add them to this property if you're changing their configurations or adding providers to a module.
|
|
843
|
+
*
|
|
844
|
+
* :::
|
|
845
|
+
*
|
|
846
|
+
* `modules` is an array of objects, each holding a module's registration configurations. Each object has the following properties:
|
|
847
|
+
*
|
|
848
|
+
* 1. `resolve`: a string indicating the path to the module relative to `src`, or the module's NPM package name. For example, `./modules/my-module`.
|
|
849
|
+
* 2. `options`: (optional) an object indicating the options to pass to the module.
|
|
850
|
+
*
|
|
851
|
+
* @example
|
|
852
|
+
* ```ts title="eto-config.ts"
|
|
853
|
+
* module.exports = defineConfig({
|
|
854
|
+
* modules: [
|
|
855
|
+
* {
|
|
856
|
+
* resolve: "./modules/hello"
|
|
857
|
+
* }
|
|
858
|
+
* ]
|
|
859
|
+
* // ...
|
|
860
|
+
* })
|
|
861
|
+
* ```
|
|
862
|
+
*/
|
|
863
|
+
modules?: Record<string, boolean | Partial<InternalModuleDeclaration | ExternalModuleDeclaration>>;
|
|
864
|
+
/**
|
|
865
|
+
* Some features in the Eto application are guarded by a feature flag. This ensures constant shipping of new features while maintaining the engine’s stability.
|
|
866
|
+
*
|
|
867
|
+
* You can enable a feature in your application by enabling its feature flag. Feature flags are enabled through either environment
|
|
868
|
+
* variables or through this configuration property exported in `eto-config.ts`.
|
|
869
|
+
*
|
|
870
|
+
* The `featureFlags`'s value is an object. Its properties are the names of the feature flags, and their value is a boolean indicating whether the feature flag is enabled.
|
|
871
|
+
*
|
|
872
|
+
* You can find available feature flags and their key name [here](https://github.com/etohq/eto/tree/develop/packages/eto/src/loaders/feature-flags).
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```ts title="eto-config.ts"
|
|
876
|
+
* module.exports = defineConfig({
|
|
877
|
+
* featureFlags: {
|
|
878
|
+
* analytics: true,
|
|
879
|
+
* // ...
|
|
880
|
+
* }
|
|
881
|
+
* // ...
|
|
882
|
+
* })
|
|
883
|
+
* ```
|
|
884
|
+
*
|
|
885
|
+
* :::note
|
|
886
|
+
*
|
|
887
|
+
* After enabling a feature flag, make sure to run migrations as it may require making changes to the database.
|
|
888
|
+
*
|
|
889
|
+
* :::
|
|
890
|
+
*/
|
|
891
|
+
featureFlags: Record<string, boolean | string | Record<string, boolean>>;
|
|
892
|
+
};
|
|
893
|
+
export type PluginDetails = {
|
|
894
|
+
resolve: string;
|
|
895
|
+
name: string;
|
|
896
|
+
id: string;
|
|
897
|
+
options: Record<string, unknown>;
|
|
898
|
+
version: string;
|
|
899
|
+
};
|
|
900
|
+
export {};
|
|
901
|
+
//# sourceMappingURL=types.d.ts.map
|