254 lines
8.7 KiB
TypeScript
Executable File
254 lines
8.7 KiB
TypeScript
Executable File
/* tslint:disable:no-console */
|
|
import { AssetServerPlugin } from '@phoenix/asset-server-plugin';
|
|
import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH, SUPER_ADMIN_USER_IDENTIFIER } from '@phoenix/common';
|
|
import { DefaultJobQueuePlugin, WinstonLogger, LogLevel, RedisSessionCachePlugin, SystemConfig, TypeOrmLogger } from '@phoenix/core';
|
|
import { EmailPlugin, EmailPluginOptions, FileBasedTemplateLoader, defaultEmailHandlers } from '@phoenix/email-plugin';
|
|
import path from 'path';
|
|
import { ConnectionOptions } from 'typeorm';
|
|
// Import EmailSettingsService
|
|
|
|
//DEV for now
|
|
// import { BonnEmailEventHandler } from './plugins/bonn-api-plugin/handler/bonn-email-handler';
|
|
|
|
/**
|
|
* Config settings used during development
|
|
*/
|
|
export const devConfig: SystemConfig = {
|
|
apiOptions: {
|
|
port: API_PORT,
|
|
// sslPort: API_SSL_PORT,
|
|
//sslCertPath: path.join(__dirname, './secrets/certificate.crt'),
|
|
//sslKeyPath: path.join(__dirname, './secrets/certificate.key'),
|
|
adminApiPath: ADMIN_API_PATH,
|
|
shopApiPath: SHOP_API_PATH,
|
|
cors: {
|
|
origin: true,
|
|
credentials: true,
|
|
},
|
|
adminApiPlayground: true
|
|
},
|
|
authOptions: {
|
|
disableAuth: true,
|
|
sessionSecret: 'some-secret',
|
|
requireVerification: false,
|
|
tokenMethod: "bearer",
|
|
superadminCredentials: {
|
|
identifier: SUPER_ADMIN_USER_IDENTIFIER,
|
|
password: process.env.SUPER_ADMIN_USER_PASSWORD || 'superadmin'
|
|
}
|
|
},
|
|
dbConnectionOptions: {
|
|
// synchronize: true,
|
|
// logging: true,
|
|
logger: new TypeOrmLogger(),
|
|
migrations: [path.join(__dirname, 'migrations/*.ts')],
|
|
...getDbConfig(),
|
|
// migrationsRun: true,
|
|
// migrations: ["migration/*.js"],
|
|
// cli: {
|
|
// migrationsDir: "migration"
|
|
// }
|
|
// logging: ["error"]
|
|
},
|
|
// dbConnectionOptionsEx: [{
|
|
// name: "sl",
|
|
// synchronize: false,
|
|
// host: 'localhost',
|
|
// username: 'sa',
|
|
// password: 'sa',
|
|
// database: 'SL_MWAWI',
|
|
// options: { encrypt: false, instanceName: "" },
|
|
// extra: { trustedConnection: false },
|
|
// logger: new TypeOrmLogger(),
|
|
// type: 'mssql'
|
|
// } as any],
|
|
// paymentOptions: {
|
|
// // paymentMethodHandlers: [examplePaymentHandler],
|
|
// },
|
|
customFields: {
|
|
|
|
Product: [
|
|
// {
|
|
// name: 'customFieldx',
|
|
// type: 'string',
|
|
// }
|
|
|
|
],
|
|
DocumentLineItem: [
|
|
|
|
],
|
|
},
|
|
searchableFields: {
|
|
processResource: [
|
|
"scanId"
|
|
]
|
|
},
|
|
logger: new WinstonLogger({ level: LogLevel.Debug }),
|
|
workerLogger: new WinstonLogger({ level: LogLevel.Info }),
|
|
importExportOptions: {
|
|
importProductAssetsDir: path.join(__dirname, 'import', 'product-assets'),
|
|
},
|
|
defaults: {
|
|
defaultTakeNumber: 100,
|
|
},
|
|
plugins: [
|
|
// not needed for local dev
|
|
RedisSessionCachePlugin.init({
|
|
namespace: 'phx-session',
|
|
redisOptions: {
|
|
host: process.env.REDIS_HOST || 'redis',
|
|
port: process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : 6379,
|
|
db: process.env.REDIS_DB ? parseInt(process.env.REDIS_DB) : 0,
|
|
password: process.env.REDIS_PASSWORD || 'admin'
|
|
}
|
|
}),
|
|
AssetServerPlugin.init({
|
|
route: 'remote-assets',
|
|
assetUploadDir: path.join(__dirname, 'assets'),
|
|
port: 5002,
|
|
assetUrlPrefix: "\\remote-assets\\" // to make it relative for client
|
|
}),
|
|
// only 4 dev
|
|
// BonnAPIPlugin.init({
|
|
// callerID: 'b64f845c-e4ed-43e9-b1f8-2e0b274afde0',
|
|
// apikey: 'ab9748dd-ac5f-40d8-954c-5c6d01092d80',
|
|
// XAccessToken: '48jerefi21r9itwp7ax88fxv2v20blhh',
|
|
// lotInfoUrl: 'https://api.zf.com/ZFMessTraceAuxSvc/v2.0/bptrace/lot-info',
|
|
// emailReceiver: 'ds@cts-schmid.de',
|
|
// autoBelegReportId: "9d77ddff-afec-4412-97dd-9272b497e0c3",
|
|
// printerHost: 'DESKTOP-OEEV0PG',
|
|
// MESAssignLotUrl: ""
|
|
// }),
|
|
// BonnAPIPlugin.init({
|
|
// callerID: '18265a9e-7792-4671-88b2-8fa2ac4af5d4',
|
|
// apikey: '83997009-248c-472d-8579-5ec681c29daa',
|
|
// XAccessToken: 'gjyntdym13u7hsb8wxnk0bfwnxko52xo',
|
|
// lotInfoUrl: 'https://apidev.zf.com/ZFMessTraceAuxSvc/v1.0/bptrace/lot-info'
|
|
// }),
|
|
// ReinerSCTPlugin.init(
|
|
// {
|
|
// hostname: 'https://timecard.bonn-unternehmensgruppe.de',
|
|
// username: 'ctsapi',
|
|
// password: 'Tje6tiuEsY'
|
|
// }
|
|
// )
|
|
// ,
|
|
//just for dev for now
|
|
// EdiTransusPlugin.init({
|
|
// url: "https://webconnect.transus.com/exchange.asmx",
|
|
// clientId: "10904548",
|
|
// clientKey: "R304WGXHKBZG"
|
|
// }),
|
|
DefaultJobQueuePlugin.init({}),
|
|
// DefaultStoragePlaceRankPlugin.init({})
|
|
// new DefaultSearchPlugin(),
|
|
// new ElasticsearchPlugin({
|
|
// host: 'http://192.168.99.100',
|
|
// port: 9200,
|
|
// }),
|
|
// DocusignPlugin.init({
|
|
// devMode:true,
|
|
// handlers: defaultDocusignHandlers,
|
|
// assetDownloadDir: path.join(__dirname, 'docusign'),
|
|
// assetUploadDir: path.join(__dirname, 'docusign'),
|
|
// port: API_PORT,
|
|
// route: "docusign"
|
|
// }),
|
|
EmailPlugin.init({
|
|
route: 'mailbox',
|
|
handlers: [...defaultEmailHandlers],
|
|
// Dynamic Email Templates
|
|
templateLoader: new FileBasedTemplateLoader(path.join(__dirname, '../email-plugin/templates')),
|
|
outputPath: path.join(__dirname, 'test-emails'),
|
|
globalTemplateVars: {
|
|
verifyEmailAddressUrl: 'http://localhost:4201/verify',
|
|
passwordResetUrl: 'http://localhost:4201/reset-password',
|
|
changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
|
|
},
|
|
// transport: {
|
|
// type: 'smtp',
|
|
// host: '',
|
|
// port: null,
|
|
// secure: false,
|
|
// auth: {
|
|
// user: '',
|
|
// pass: '',
|
|
// },
|
|
// tls: {
|
|
// rejectUnauthorized: false,
|
|
// },
|
|
// }
|
|
} as EmailPluginOptions),
|
|
],
|
|
};
|
|
|
|
function getDbConfig(): ConnectionOptions {
|
|
const dbType = process.env.DB || 'postgres';
|
|
const dbHost = process.env.DB_HOST || 'localhost';
|
|
const dbPort = +process.env.DB_PORT || 5432;
|
|
|
|
const connectionPoolMax = process.env.CONNECTION_POOL_MAX ?? 20;
|
|
|
|
const dbUsername = process.env.DB_USERNAME || 'postgres';
|
|
const password = process.env.DB_PASSWORD || 'admin';
|
|
const database = process.env.DB_NAME || 'phoenix'
|
|
|
|
if (password == "admin")
|
|
console.warn("default postgres password is used!");
|
|
|
|
if (process.env.DB_HOST)
|
|
console.log(`using DB Host ${dbHost} from env`);
|
|
|
|
console.log(`using Database ${database}`);
|
|
console.log(`using User ${dbUsername}`);
|
|
|
|
switch (dbType) {
|
|
case 'postgres':
|
|
console.log('Using postgres connection at ' + dbHost);
|
|
return {
|
|
synchronize: true,
|
|
type: 'postgres',
|
|
//host: '127.0.0.1',
|
|
host: dbHost,
|
|
port: dbPort,
|
|
username: dbUsername,
|
|
password: password,
|
|
database: database,
|
|
// logging: "all",
|
|
extra: {
|
|
max: connectionPoolMax
|
|
},
|
|
cache: {
|
|
alwaysEnabled: false,
|
|
duration: 10000
|
|
}
|
|
};
|
|
case 'sqlite':
|
|
console.log('Using sqlite connection');
|
|
return {
|
|
type: 'sqlite',
|
|
database: path.join(__dirname, 'phoenix.sqlite'),
|
|
};
|
|
case 'sqljs':
|
|
console.log('Using sql.js connection');
|
|
return {
|
|
type: 'sqljs',
|
|
autoSave: true,
|
|
database: new Uint8Array([]),
|
|
location: path.join(__dirname, 'phoenix.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: 'phoenix-dev',
|
|
};
|
|
}
|
|
}
|