2021-08-13 19:22:15 +02:00
|
|
|
import { start } from './lib/server-impl';
|
2021-04-22 15:04:08 +02:00
|
|
|
import { createConfig } from './lib/create-config';
|
2021-04-23 15:31:12 +02:00
|
|
|
import { LogLevel } from './lib/logger';
|
2022-01-05 10:00:59 +01:00
|
|
|
import { ApiTokenType } from './lib/types/models/api-token';
|
2020-04-13 22:38:46 +02:00
|
|
|
|
2021-06-17 20:33:34 +02:00
|
|
|
process.nextTick(async () => {
|
|
|
|
try {
|
2021-08-13 19:22:15 +02:00
|
|
|
await start(
|
2021-06-17 20:33:34 +02:00
|
|
|
createConfig({
|
|
|
|
db: {
|
|
|
|
user: 'unleash_user',
|
2023-04-19 13:29:18 +02:00
|
|
|
password: 'password',
|
2021-06-17 20:33:34 +02:00
|
|
|
host: 'localhost',
|
|
|
|
port: 5432,
|
2022-03-29 14:59:14 +02:00
|
|
|
database: process.env.UNLEASH_DATABASE_NAME || 'unleash',
|
|
|
|
schema: process.env.UNLEASH_DATABASE_SCHEMA,
|
2021-06-17 20:33:34 +02:00
|
|
|
ssl: false,
|
2022-04-07 20:55:56 +02:00
|
|
|
applicationName: 'unleash',
|
2021-06-17 20:33:34 +02:00
|
|
|
},
|
|
|
|
server: {
|
|
|
|
enableRequestLogger: true,
|
|
|
|
baseUriPath: '',
|
|
|
|
// keepAliveTimeout: 1,
|
|
|
|
gracefulShutdownEnable: true,
|
2022-01-06 10:31:00 +01:00
|
|
|
// cdnPrefix: 'https://cdn.getunleash.io/unleash/v4.4.1',
|
2022-12-08 11:25:39 +01:00
|
|
|
enableHeapSnapshotEnpoint: true,
|
2021-06-17 20:33:34 +02:00
|
|
|
},
|
|
|
|
logLevel: LogLevel.debug,
|
2023-12-08 19:51:12 +01:00
|
|
|
secureHeaders: false,
|
2021-06-17 20:33:34 +02:00
|
|
|
versionCheck: {
|
|
|
|
enable: false,
|
|
|
|
},
|
2021-10-08 10:09:22 +02:00
|
|
|
experimental: {
|
2022-08-26 08:22:42 +02:00
|
|
|
// externalResolver: unleash,
|
|
|
|
flags: {
|
|
|
|
embedProxy: true,
|
2022-08-26 15:16:29 +02:00
|
|
|
embedProxyFrontend: true,
|
2022-08-26 08:22:42 +02:00
|
|
|
anonymiseEventLog: false,
|
2023-02-22 10:10:06 +01:00
|
|
|
responseTimeWithAppNameKillSwitch: false,
|
2023-09-20 09:35:30 +02:00
|
|
|
privateProjects: true,
|
2023-10-25 15:18:52 +02:00
|
|
|
featureSearchAPI: true,
|
2023-12-05 17:31:23 +01:00
|
|
|
featureSearchFrontend: true,
|
2023-12-08 12:14:37 +01:00
|
|
|
stripClientHeadersOn304: true,
|
2023-12-11 12:23:18 +01:00
|
|
|
newStrategyConfiguration: true,
|
2022-08-26 08:22:42 +02:00
|
|
|
},
|
2021-10-08 10:09:22 +02:00
|
|
|
},
|
2022-01-05 10:00:59 +01:00
|
|
|
authentication: {
|
|
|
|
initApiTokens: [
|
|
|
|
{
|
|
|
|
environment: '*',
|
|
|
|
project: '*',
|
2022-01-05 10:40:22 +01:00
|
|
|
secret: '*:*.964a287e1b728cb5f4f3e0120df92cb5',
|
2022-01-05 10:00:59 +01:00
|
|
|
type: ApiTokenType.ADMIN,
|
2023-05-04 09:56:00 +02:00
|
|
|
tokenName: 'some-user',
|
2022-01-05 10:00:59 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-03-17 14:10:21 +01:00
|
|
|
/* can be tweaked to control configuration caching for /api/client/features
|
|
|
|
clientFeatureCaching: {
|
|
|
|
enabled: true,
|
|
|
|
maxAge: 4000,
|
|
|
|
},
|
|
|
|
*/
|
2021-06-17 20:33:34 +02:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
} catch (error) {
|
|
|
|
if (error.code === 'EADDRINUSE') {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.warn('Port in use. You might want to reload once more.');
|
|
|
|
} else {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error(error);
|
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 0);
|