forked from vendure-ecommerce/vendure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev-config.ts
123 lines (120 loc) · 3.81 KB
/
dev-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* tslint:disable:no-console */
import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
import { AssetServerPlugin } from '@vendure/asset-server-plugin';
import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH } from '@vendure/common/lib/shared-constants';
import {
DefaultLogger,
DefaultSearchPlugin,
examplePaymentHandler,
LogLevel,
VendureConfig,
} from '@vendure/core';
import { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
import path from 'path';
import { ConnectionOptions } from 'typeorm';
import { RestPlugin } from './rest-plugin';
import { UiPlugin } from './ui-plugin/ui-plugin';
/**
* Config settings used during development
*/
export const devConfig: VendureConfig = {
authOptions: {
disableAuth: false,
sessionSecret: 'some-secret',
requireVerification: true,
},
port: API_PORT,
adminApiPath: ADMIN_API_PATH,
shopApiPath: SHOP_API_PATH,
dbConnectionOptions: {
synchronize: false,
logging: false,
...getDbConfig(),
},
paymentOptions: {
paymentMethodHandlers: [examplePaymentHandler],
},
customFields: {
/*Product: [
{ type: 'string', name: 'name' },
{ type: 'datetime', name: 'expires' },
],*/
},
logger: new DefaultLogger({ level: LogLevel.Info }),
importExportOptions: {
importAssetsDir: path.join(__dirname, 'import-assets'),
},
plugins: [
AssetServerPlugin.init({
route: 'assets',
assetUploadDir: path.join(__dirname, 'assets'),
port: 5002,
}),
DefaultSearchPlugin,
// ElasticsearchPlugin.init({
// host: 'http://192.168.99.100',
// port: 9200,
// }),
EmailPlugin.init({
devMode: true,
handlers: defaultEmailHandlers,
templatePath: path.join(__dirname, '../email-plugin/templates'),
outputPath: path.join(__dirname, 'test-emails'),
mailboxPort: 5003,
globalTemplateVars: {
verifyEmailAddressUrl: 'http://localhost:4201/verify',
passwordResetUrl: 'http://localhost:4201/reset-password',
changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
},
}),
UiPlugin,
AdminUiPlugin.init({
port: 5001,
extensions: UiPlugin.uiExtensions,
watch: true,
}),
],
};
function getDbConfig(): ConnectionOptions {
const dbType = process.env.DB || 'mysql';
switch (dbType) {
case 'postgres':
console.log('Using postgres connection');
return {
synchronize: true,
type: 'postgres',
host: '127.0.0.1',
port: 5432,
username: 'postgres',
password: 'Be70',
database: 'vendure',
};
case 'sqlite':
console.log('Using sqlite connection');
return {
type: 'sqlite',
database: path.join(__dirname, 'vendure.sqlite'),
};
case 'sqljs':
console.log('Using sql.js connection');
return {
type: 'sqljs',
autoSave: true,
database: new Uint8Array([]),
location: path.join(__dirname, 'vendure.sqlite'),
};
case 'mysql':
default:
console.log('Using mysql connection');
return {
synchronize: true,
type: 'mysql',
host: '192.168.99.100',
port: 3306,
username: 'root',
password: '',
database: 'vendure-dev',
};
}
}