1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.ConfigBuilder = void 0;
|
4 | var user_entity_1 = require("./entities/user.entity");
|
5 | var ufs_1 = require("./ufs");
|
6 | var ConfigBuilder = (function () {
|
7 | function ConfigBuilder(basePath) {
|
8 | this.config = {
|
9 | disabledDb: false,
|
10 | disabledGraphQL: false,
|
11 | db: {
|
12 | type: "mysql",
|
13 | host: "localhost",
|
14 | port: 8889,
|
15 | username: "root",
|
16 | password: "root",
|
17 | database: "koa_typescript2",
|
18 | entities: [basePath + "/entities/*.entity.js"],
|
19 | synchronize: true,
|
20 | logging: false
|
21 | },
|
22 | publicFolders: [basePath + "/public"],
|
23 | viewFolders: [basePath + "/views"],
|
24 | translationFolders: [basePath + "/locale"],
|
25 | middlewaresFolders: [basePath + "/middlewares"],
|
26 | controllersFolders: [basePath + "/controllers"],
|
27 | migrationsFolders: [basePath + "/migrations"],
|
28 | disableMigrations: false,
|
29 | sessionSecret: "session_secret",
|
30 | sessionStore: null,
|
31 | tokenSecret: "token_secret",
|
32 | mailer: {
|
33 | sender: 'Lynx Framework <lynx.framework@fakemail.com>',
|
34 | host: '',
|
35 | port: 587,
|
36 | secure: false,
|
37 | auth: {
|
38 | user: '',
|
39 | pass: ''
|
40 | }
|
41 | },
|
42 | defaultLanguage: "it",
|
43 | uploadPath: basePath + "/../uploads",
|
44 | cachePath: basePath + "/../cache",
|
45 | ufs: new ufs_1.LocalUFS(),
|
46 | onDatabaseInit: function () { },
|
47 | chachingImages: false
|
48 | };
|
49 | }
|
50 | ConfigBuilder.prototype.setPublicFolders = function (folders) {
|
51 | this.config.publicFolders = folders;
|
52 | return this;
|
53 | };
|
54 | ConfigBuilder.prototype.setViewFolders = function (folders) {
|
55 | this.config.viewFolders = folders;
|
56 | return this;
|
57 | };
|
58 | ConfigBuilder.prototype.setTranslationFolders = function (folders) {
|
59 | this.config.translationFolders = folders;
|
60 | return this;
|
61 | };
|
62 | ConfigBuilder.prototype.setMiddlewaresFolders = function (folders) {
|
63 | this.config.middlewaresFolders = folders;
|
64 | return this;
|
65 | };
|
66 | ConfigBuilder.prototype.setControllersFolders = function (folders) {
|
67 | this.config.controllersFolders = folders;
|
68 | return this;
|
69 | };
|
70 | ConfigBuilder.prototype.setMigrationsFolders = function (folders) {
|
71 | this.config.migrationsFolders = folders;
|
72 | return this;
|
73 | };
|
74 | ConfigBuilder.prototype.setSessionSecret = function (secret) {
|
75 | this.config.sessionSecret = secret;
|
76 | return this;
|
77 | };
|
78 | ConfigBuilder.prototype.setTokenSecret = function (secret) {
|
79 | this.config.tokenSecret = secret;
|
80 | return this;
|
81 | };
|
82 | ConfigBuilder.prototype.setSessionStore = function (store) {
|
83 | this.config.sessionStore = store;
|
84 | return this;
|
85 | };
|
86 | ConfigBuilder.prototype.setUploadPath = function (path) {
|
87 | this.config.uploadPath = path;
|
88 | return this;
|
89 | };
|
90 | ConfigBuilder.prototype.setCachePath = function (path) {
|
91 | this.config.cachePath = path;
|
92 | return this;
|
93 | };
|
94 | ConfigBuilder.prototype.setDefaultLanguage = function (language) {
|
95 | this.config.defaultLanguage = language;
|
96 | return this;
|
97 | };
|
98 | ConfigBuilder.prototype.setEntitiesFolders = function (folders) {
|
99 | this.config.db.entities = folders;
|
100 | return this;
|
101 | };
|
102 | ConfigBuilder.prototype.setDatabaseType = function (type) {
|
103 | this.config.disabledDb = false;
|
104 | this.config.db.type = type;
|
105 | return this;
|
106 | };
|
107 | ConfigBuilder.prototype.setDatabaseHost = function (host) {
|
108 | this.config.disabledDb = false;
|
109 | this.config.db.host = host;
|
110 | return this;
|
111 | };
|
112 | ConfigBuilder.prototype.setDatabasePort = function (port) {
|
113 | this.config.disabledDb = false;
|
114 | this.config.db.port = port;
|
115 | return this;
|
116 | };
|
117 | ConfigBuilder.prototype.setDatabaseLogin = function (username, password) {
|
118 | this.config.disabledDb = false;
|
119 | this.config.db.username = username;
|
120 | this.config.db.password = password;
|
121 | return this;
|
122 | };
|
123 | ConfigBuilder.prototype.setDatabase = function (database) {
|
124 | this.config.disabledDb = false;
|
125 | this.config.db.database = database;
|
126 | return this;
|
127 | };
|
128 | ConfigBuilder.prototype.disableDB = function () {
|
129 | this.config.disabledDb = true;
|
130 | return this;
|
131 | };
|
132 | ConfigBuilder.prototype.disableMigration = function () {
|
133 | this.config.disableMigrations = true;
|
134 | return this;
|
135 | };
|
136 | ConfigBuilder.prototype.enableMigration = function () {
|
137 | this.config.disableMigrations = false;
|
138 | return this;
|
139 | };
|
140 | ConfigBuilder.prototype.disableGraphQL = function () {
|
141 | this.config.disabledGraphQL = true;
|
142 | return this;
|
143 | };
|
144 | ConfigBuilder.prototype.setMailerSender = function (address) {
|
145 | this.config.mailer.sender = address;
|
146 | return this;
|
147 | };
|
148 | ConfigBuilder.prototype.setMailerAuth = function (user, password) {
|
149 | this.config.mailer.auth.user = user;
|
150 | this.config.mailer.auth.pass = password;
|
151 | return this;
|
152 | };
|
153 | ConfigBuilder.prototype.setMailerServer = function (host, port, secure) {
|
154 | this.config.mailer.host = host;
|
155 | this.config.mailer.port = port;
|
156 | this.config.mailer.secure = secure;
|
157 | return this;
|
158 | };
|
159 | ConfigBuilder.prototype.setCustomUserEntity = function (hasCustom) {
|
160 | user_entity_1.setSkipSync(!hasCustom);
|
161 | return this;
|
162 | };
|
163 | ConfigBuilder.prototype.setJsonLimit = function (limit) {
|
164 | this.config.jsonLimit = limit;
|
165 | return this;
|
166 | };
|
167 | ConfigBuilder.prototype.setUFS = function (ufs) {
|
168 | this.config.ufs = ufs;
|
169 | return this;
|
170 | };
|
171 | ConfigBuilder.prototype.setOnDatabaseInit = function (cb) {
|
172 | this.config.onDatabaseInit = cb;
|
173 | return this;
|
174 | };
|
175 | ConfigBuilder.prototype.enableCachingImages = function () {
|
176 | this.config.chachingImages = true;
|
177 | return this;
|
178 | };
|
179 | ConfigBuilder.prototype.build = function () {
|
180 | return this.config;
|
181 | };
|
182 | return ConfigBuilder;
|
183 | }());
|
184 | exports.ConfigBuilder = ConfigBuilder;
|