@reldens/cms 0.6.0 → 0.8.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.
Files changed (40) hide show
  1. package/admin/reldens-admin-client.css +29 -30
  2. package/admin/templates/dashboard.html +1 -1
  3. package/bin/reldens-cms.js +1 -1
  4. package/install/index.html +23 -9
  5. package/install/success.html +36 -0
  6. package/lib/admin-manager.js +41 -4
  7. package/lib/admin-templates-loader.js +37 -0
  8. package/lib/admin-translations.js +4 -218
  9. package/lib/allowed-extensions.js +11 -0
  10. package/lib/entities-loader.js +2 -6
  11. package/lib/frontend.js +25 -17
  12. package/lib/installer.js +144 -116
  13. package/lib/loaded-entities-processor.js +30 -0
  14. package/lib/manager.js +223 -56
  15. package/lib/mime-types.js +35 -0
  16. package/lib/templates-list.js +0 -9
  17. package/lib/templates-to-path-mapper.js +28 -0
  18. package/migrations/default-homepage.sql +10 -0
  19. package/migrations/install.sql +1 -23
  20. package/migrations/users-authentication.sql +16 -0
  21. package/package.json +2 -2
  22. package/templates/.env.dist +11 -11
  23. package/templates/assets/favicons/android-icon-144x144.png +0 -0
  24. package/templates/assets/favicons/android-icon-192x192.png +0 -0
  25. package/templates/assets/favicons/android-icon-512x512.png +0 -0
  26. package/templates/assets/favicons/apple-touch-icon.png +0 -0
  27. package/templates/assets/favicons/favicon-16x16.png +0 -0
  28. package/templates/assets/favicons/favicon-32x32.png +0 -0
  29. package/templates/assets/favicons/mstile-150x150.png +0 -0
  30. package/templates/assets/favicons/safari-pinned-tab.svg +121 -0
  31. package/templates/assets/web/loading.gif +0 -0
  32. package/templates/assets/web/reldens-your-logo-mage.png +0 -0
  33. package/templates/browserconfig.xml +9 -0
  34. package/templates/favicon.ico +0 -0
  35. package/templates/index.js.dist +2 -2
  36. package/templates/site.webmanifest +27 -0
  37. package/admin/templates/maps-wizard-maps-selection.html +0 -85
  38. package/admin/templates/maps-wizard.html +0 -341
  39. package/admin/templates/objects-import.html +0 -143
  40. package/admin/templates/skills-import.html +0 -201
package/lib/manager.js CHANGED
@@ -4,12 +4,21 @@
4
4
  *
5
5
  */
6
6
 
7
- const { AppServerFactory, FileHandler, Encryptor } = require('@reldens/server-utils');
8
- const { DriversMap } = require('@reldens/storage');
7
+ const { TemplatesList } = require('./templates-list');
8
+ const { AdminTranslations } = require('./admin-translations');
9
+ const { AdminTemplatesLoader } = require('./admin-templates-loader');
10
+ const { AdminManagerValidator } = require('./admin-manager-validator');
11
+ const { MimeTypes } = require('./mime-types');
12
+ const { AllowedExtensions } = require('./allowed-extensions');
13
+ const { TemplatesToPathMapper } = require('./templates-to-path-mapper');
14
+ const { AdminEntitiesGenerator } = require('./admin-entities-generator');
15
+ const { LoadedEntitiesProcessor } = require('./loaded-entities-processor');
9
16
  const { AdminManager } = require('./admin-manager');
10
17
  const { Installer } = require('./installer');
11
18
  const { Frontend } = require('./frontend');
12
19
  const { EventsManagerSingleton, Logger, sc } = require('@reldens/utils');
20
+ const { DriversMap } = require('@reldens/storage');
21
+ const { AppServerFactory, FileHandler, Encryptor } = require('@reldens/server-utils');
13
22
  const dotenv = require('dotenv');
14
23
  const mustache = require('mustache');
15
24
 
@@ -23,41 +32,117 @@ class Manager
23
32
  this.installLockPath = FileHandler.joinPaths(this.projectRoot, 'install.lock');
24
33
  dotenv.config({path: this.envFilePath});
25
34
  this.config = this.loadConfigFromEnv();
26
- this.entities = sc.get(props, 'entities', {});
27
- this.rawEntities = sc.get(props, 'rawEntities', {});
28
- this.entitiesConfig = sc.get(props, 'entitiesConfig', {});
35
+ this.adminEntities = sc.get(props, 'adminEntities', {});
36
+ this.rawRegisteredEntities = sc.get(props, 'rawRegisteredEntities', {});
29
37
  this.entitiesTranslations = sc.get(props, 'entitiesTranslations', {});
38
+ this.entitiesConfig = sc.get(props, 'entitiesConfig', {});
39
+ this.processedEntities = sc.get(props, 'processedEntities', {});
30
40
  this.authenticationMethod = sc.get(props, 'authenticationMethod', 'db-users');
31
41
  this.authenticationCallback = sc.get(props, 'authenticationCallback', false);
32
42
  this.events = sc.get(props, 'events', EventsManagerSingleton);
43
+ this.adminTemplatesList = sc.get(props, 'adminTemplatesList', TemplatesList);
44
+ this.projectAdminPath = FileHandler.joinPaths(this.projectRoot, 'admin');
45
+ this.projectAdminTemplatesPath = FileHandler.joinPaths(this.projectAdminPath, 'templates');
46
+ this.mimeTypes = sc.get(props, 'mimeTypes', MimeTypes);
47
+ this.allowedExtensions = sc.get(props, 'allowedExtensions', AllowedExtensions)
48
+ this.adminRoleId = sc.get(props, 'adminRoleId', 99);
49
+ this.stylesFilePath = sc.get(props, 'stylesFilePath', '/css/reldens-admin-client.css');
50
+ this.scriptsFilePath = sc.get(props, 'scriptsFilePath', '/js/reldens-admin-client.js');
51
+ this.companyName = sc.get(props, 'companyName', 'Reldens - CMS');
52
+ this.logo = sc.get(props, 'logo', '/assets/web/reldens-your-logo-mage.png');
53
+ this.favicon = sc.get(props, 'favicon', '/assets/web/favicon.ico');
54
+ this.app = sc.get(props, 'app', false);
55
+ this.appServer = sc.get(props, 'appServer', false);
56
+ this.dataServer = sc.get(props, 'dataServer', false);
57
+ this.adminManager = sc.get(props, 'adminManager', false);
58
+ this.frontend = sc.get(props, 'frontend', false);
33
59
  this.appServerFactory = new AppServerFactory();
60
+ this.adminEntitiesGenerator = new AdminEntitiesGenerator();
34
61
  this.installer = new Installer({
35
62
  projectRoot: this.projectRoot,
36
63
  postInstallCallback: this.initializeCmsAfterInstall.bind(this)
37
64
  });
38
- this.dataServer = false;
39
- this.app = false;
40
- this.appServer = false;
41
- this.adminManager = false;
42
- this.frontend = false;
65
+ this.useProvidedServer = this.validateProvidedServer();
66
+ this.useProvidedDataServer = this.validateProvidedDataServer();
67
+ this.useProvidedAdminManager = this.validateProvidedAdminManager();
68
+ this.useProvidedFrontend = this.validateProvidedFrontend();
69
+ }
70
+
71
+ validateProvidedServer()
72
+ {
73
+ if(!this.app){
74
+ return false;
75
+ }
76
+ if(!this.appServer){
77
+ return false;
78
+ }
79
+ if('function' !== typeof this.app.use){
80
+ Logger.critical('Invalid app instance provided - missing use method.');
81
+ return false;
82
+ }
83
+ if('function' !== typeof this.appServer.listen){
84
+ Logger.critical('Invalid appServer instance provided - missing listen method.');
85
+ return false;
86
+ }
87
+ return true;
88
+ }
89
+
90
+ validateProvidedDataServer()
91
+ {
92
+ if(!this.dataServer){
93
+ return false;
94
+ }
95
+ if('function' !== typeof this.dataServer.connect){
96
+ Logger.critical('Invalid dataServer instance provided - missing connect method.');
97
+ return false;
98
+ }
99
+ if('function' !== typeof this.dataServer.generateEntities){
100
+ Logger.critical('Invalid dataServer instance provided - missing generateEntities method.');
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+
106
+ validateProvidedAdminManager()
107
+ {
108
+ if(!this.adminManager){
109
+ return false;
110
+ }
111
+ if('function' !== typeof this.adminManager.setupAdmin){
112
+ Logger.critical('Invalid adminManager instance provided - missing setupAdmin method.');
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+
118
+ validateProvidedFrontend()
119
+ {
120
+ if(!this.frontend){
121
+ return false;
122
+ }
123
+ if('function' !== typeof this.frontend.initialize){
124
+ Logger.critical('Invalid frontend instance provided - missing initialize method.');
125
+ return false;
126
+ }
127
+ return true;
43
128
  }
44
129
 
45
130
  loadConfigFromEnv()
46
131
  {
47
132
  let envVars = process.env;
48
133
  return {
49
- host: sc.get(envVars, 'RELDENS_CMS_HOST', 'http://localhost'),
50
- port: Number(sc.get(envVars, 'RELDENS_CMS_PORT', 8000)),
51
- adminPath: sc.get(envVars, 'RELDENS_CMS_ADMIN_PATH', '/reldens-admin'),
52
- adminSecret: sc.get(envVars, 'RELDENS_CMS_ADMIN_SECRET', ''),
134
+ host: sc.get(envVars, 'RELDENS_APP_HOST', 'http://localhost'),
135
+ port: Number(sc.get(envVars, 'RELDENS_APP_PORT', 8080)),
136
+ adminPath: sc.get(envVars, 'RELDENS_ADMIN_ROUTE_PATH', '/reldens-admin'),
137
+ adminSecret: sc.get(envVars, 'RELDENS_ADMIN_SECRET', ''),
53
138
  database: {
54
- client: sc.get(envVars, 'RELDENS_CMS_DB_CLIENT', 'mysql'),
55
- host: sc.get(envVars, 'RELDENS_CMS_DB_HOST', 'localhost'),
56
- port: Number(sc.get(envVars, 'RELDENS_CMS_DB_PORT', 3306)),
57
- name: sc.get(envVars, 'RELDENS_CMS_DB_NAME', 'reldens_cms'),
58
- user: sc.get(envVars, 'RELDENS_CMS_DB_USER', ''),
59
- password: sc.get(envVars, 'RELDENS_CMS_DB_PASSWORD', ''),
60
- driver: sc.get(envVars, 'RELDENS_CMS_DB_DRIVER', 'prisma')
139
+ client: sc.get(envVars, 'RELDENS_DB_CLIENT', 'mysql'),
140
+ host: sc.get(envVars, 'RELDENS_DB_HOST', 'localhost'),
141
+ port: Number(sc.get(envVars, 'RELDENS_DB_PORT', 3306)),
142
+ name: sc.get(envVars, 'RELDENS_DB_NAME', 'reldens_cms'),
143
+ user: sc.get(envVars, 'RELDENS_DB_USER', ''),
144
+ password: sc.get(envVars, 'RELDENS_DB_PASSWORD', ''),
145
+ driver: sc.get(envVars, 'RELDENS_STORAGE_DRIVER', 'prisma')
61
146
  }
62
147
  };
63
148
  }
@@ -69,57 +154,115 @@ class Manager
69
154
 
70
155
  async start()
71
156
  {
72
- let createdAppServer = this.appServerFactory.createAppServer();
73
- if(this.appServerFactory.error.message){
74
- Logger.error('App server error: '+this.appServerFactory.error.message);
75
- return false;
157
+ if(!this.useProvidedServer){
158
+ let createdAppServer = this.appServerFactory.createAppServer();
159
+ if(this.appServerFactory.error.message){
160
+ Logger.error('App server error: '+this.appServerFactory.error.message);
161
+ return false;
162
+ }
163
+ this.app = createdAppServer.app;
164
+ this.appServer = createdAppServer.appServer;
76
165
  }
77
- this.app = createdAppServer.app;
78
- this.appServer = createdAppServer.appServer;
79
166
  if(!this.isInstalled()){
80
167
  Logger.info('CMS not installed, preparing setup');
81
168
  await this.installer.prepareSetup(this.app, this.appServer, this.appServerFactory);
82
- await this.appServer.listen(this.config.port);
169
+ if(!this.useProvidedServer){
170
+ await this.appServer.listen(this.config.port);
171
+ }
83
172
  Logger.info('Installer running on '+this.config.host+':'+this.config.port);
84
173
  return true;
85
174
  }
86
175
  try {
87
- await this.initializeDataServer();
88
- await this.initializeAdminManager();
89
- await this.initializeFrontend();
90
- await this.appServer.listen(this.config.port);
176
+ await this.initializeServices();
91
177
  Logger.info('CMS running on '+this.config.host+':'+this.config.port);
92
178
  return true;
93
179
  } catch (error) {
94
- Logger.error('Failed to start CMS: '+error.message);
180
+ Logger.critical('Failed to start CMS: '+error.message);
95
181
  return false;
96
182
  }
97
183
  }
98
184
 
99
- async initializeCmsAfterInstall(entitiesData)
185
+ async initializeCmsAfterInstall(props)
100
186
  {
101
187
  try {
102
- if(entitiesData){
103
- this.entities = sc.get(entitiesData, 'entities', this.entities);
104
- this.rawEntities = sc.get(entitiesData, 'rawEntities', this.rawEntities);
105
- this.entitiesConfig = sc.get(entitiesData, 'entitiesConfig', this.entitiesConfig);
106
- this.entitiesTranslations = sc.get(entitiesData, 'entitiesTranslations', this.entitiesTranslations);
188
+ //Logger.debug('Loaded entities post install.', props.loadedEntities);
189
+ this.rawRegisteredEntities = props.loadedEntities.rawRegisteredEntities;
190
+ this.entitiesTranslations = props.loadedEntities.entitiesTranslations;
191
+ this.entitiesConfig = props.loadedEntities.entitiesConfig;
192
+ this.config = props.mappedVariablesForConfig;
193
+ await this.initializeServices();
194
+ Logger.info('CMS initialized after installation on '+this.config.host+':'+this.config.port);
195
+ return true;
196
+ } catch (error) {
197
+ Logger.critical('Failed to initialize CMS after installation: '+error.message);
198
+ return false;
199
+ }
200
+ }
201
+
202
+ async initializeServices()
203
+ {
204
+ if(!this.useProvidedDataServer){
205
+ if(!await this.initializeDataServer()){
206
+ return false;
107
207
  }
108
- this.config = this.loadConfigFromEnv();
109
- if(this.appServerFactory.error.message){
110
- Logger.critical('App server creation failed: '+this.appServerFactory.error.message);
208
+ }
209
+ if(!this.loadProcessedEntities()){
210
+ return false;
211
+ }
212
+ if(!await this.generateAdminEntities()){
213
+ return false;
214
+ }
215
+ if(!this.useProvidedAdminManager){
216
+ if(!await this.initializeAdminManager()){
217
+ return false;
218
+ }
219
+ }
220
+ if(!this.useProvidedFrontend){
221
+ if(!await this.initializeFrontend()){
111
222
  return false;
112
223
  }
113
- await this.initializeDataServer();
114
- await this.initializeAdminManager();
115
- await this.initializeFrontend();
224
+ }
225
+ if(!this.useProvidedServer){
116
226
  await this.appServer.listen(this.config.port);
117
- Logger.info('CMS initialized after installation on '+this.config.host+':'+this.config.port);
227
+ }
228
+ return true;
229
+ }
230
+
231
+ loadProcessedEntities()
232
+ {
233
+ if(0 === Object.keys(this.processedEntities).length){
234
+ this.processedEntities = LoadedEntitiesProcessor.process(
235
+ this.rawRegisteredEntities,
236
+ this.entitiesTranslations,
237
+ this.entitiesConfig
238
+ );
239
+ }
240
+ if(!this.processedEntities?.entities){
241
+ Logger.critical('Processed entities undefined.');
242
+ return false;
243
+ }
244
+ return true;
245
+ }
246
+
247
+ async generateAdminEntities()
248
+ {
249
+ if(0 < Object.keys(this.adminEntities).length){
118
250
  return true;
119
- } catch (error) {
120
- Logger.critical('Failed to initialize CMS after installation: '+error.message);
251
+ }
252
+ if(!this.dataServer.rawEntities && this.rawRegisteredEntities){
253
+ this.dataServer.rawEntities = this.rawRegisteredEntities;
254
+ }
255
+ Logger.debug('Generate entities count: '+Object.keys(this.rawRegisteredEntities).length);
256
+ await this.dataServer.generateEntities();
257
+ this.adminEntities = this.adminEntitiesGenerator.generate(
258
+ this.processedEntities.entities,
259
+ this.dataServer.entityManager.entities
260
+ );
261
+ if(0 === Object.keys(this.adminEntities).length){
262
+ Logger.warning('Admin entities not found.');
121
263
  return false;
122
264
  }
265
+ return true;
123
266
  }
124
267
 
125
268
  async initializeDataServer()
@@ -133,7 +276,7 @@ class Manager
133
276
  user: this.config.database.user,
134
277
  password: this.config.database.password
135
278
  },
136
- rawEntities: this.rawEntities
279
+ rawEntities: this.rawRegisteredEntities
137
280
  };
138
281
  let DriverClass = DriversMap[this.config.database.driver];
139
282
  if(!DriverClass){
@@ -145,6 +288,7 @@ class Manager
145
288
  Logger.critical('Failed to connect to database.');
146
289
  return false;
147
290
  }
291
+ Logger.debug('Entities count: '+Object.keys(this.rawRegisteredEntities).length);
148
292
  await this.dataServer.generateEntities();
149
293
  return true;
150
294
  }
@@ -152,35 +296,58 @@ class Manager
152
296
  async initializeAdminManager()
153
297
  {
154
298
  let authenticationCallback = this.authenticationCallback;
155
- if('db-users' === this.authenticationMethod){
299
+ if('db-users' === this.authenticationMethod && !authenticationCallback){
156
300
  authenticationCallback = async (email, password, roleId) => {
301
+ Logger.debug('Running default "db-users" authentication.');
157
302
  let usersEntity = this.dataServer.getEntity('users');
158
303
  if(!usersEntity){
304
+ Logger.critical('No users entity found.');
159
305
  return false;
160
306
  }
161
307
  let user = await usersEntity.loadOneBy('email', email);
162
308
  if(!user){
309
+ Logger.debug('User not found by email: '+email+'.', user);
163
310
  return false;
164
311
  }
165
312
  if(Number(user.role_id) !== Number(roleId)){
313
+ Logger.debug('Invalid user role ID: '+roleId+' / '+user.role_id+'.');
166
314
  return false;
167
315
  }
168
- return Encryptor.validatePassword(password, user.password) ? user : false;
316
+ let passwordResult = Encryptor.validatePassword(password, user.password) ? user : false;
317
+ if(!passwordResult){
318
+ Logger.debug('Invalid user password for: '+email+'.');
319
+ }
320
+ return passwordResult;
169
321
  };
170
322
  }
171
323
  let adminConfig = {
172
324
  events: this.events,
173
- renderCallback: this.renderCallback.bind(this),
174
325
  dataServer: this.dataServer,
175
326
  authenticationCallback,
176
327
  app: this.app,
177
328
  appServerFactory: this.appServerFactory,
329
+ entities: this.adminEntities,
330
+ validator: new AdminManagerValidator(),
331
+ renderCallback: this.renderCallback.bind(this),
178
332
  secret: this.config.adminSecret,
179
333
  rootPath: this.config.adminPath,
180
- adminRoleId: 99,
181
- entities: this.entities,
182
- entitiesConfig: this.entitiesConfig,
183
- translations: this.entitiesTranslations
334
+ translations: AdminTranslations.appendTranslations(this.entitiesTranslations || {}),
335
+ adminFilesContents: await AdminTemplatesLoader.fetchAdminFilesContents(
336
+ TemplatesToPathMapper.map(this.adminTemplatesList, this.projectAdminTemplatesPath)
337
+ ),
338
+ mimeTypes: this.mimeTypes,
339
+ allowedExtensions: this.allowedExtensions,
340
+ adminRoleId: this.adminRoleId,
341
+ stylesFilePath: this.stylesFilePath,
342
+ scriptsFilePath: this.scriptsFilePath,
343
+ branding: {
344
+ companyName: this.companyName,
345
+ logo: this.logo,
346
+ favicon: this.favicon,
347
+ copyRight: await FileHandler.fetchFileContents(
348
+ FileHandler.joinPaths(this.projectAdminTemplatesPath, this.adminTemplatesList.defaultCopyRight)
349
+ )
350
+ }
184
351
  };
185
352
  this.adminManager = new AdminManager(adminConfig);
186
353
  await this.adminManager.setupAdmin();
@@ -0,0 +1,35 @@
1
+ /**
2
+ *
3
+ * Reldens - MimeTypes
4
+ *
5
+ */
6
+
7
+ module.exports.MimeTypes = {
8
+ audio: [
9
+ 'audio/aac',
10
+ 'audio/midi',
11
+ 'audio/x-midi',
12
+ 'audio/mpeg',
13
+ 'audio/ogg',
14
+ 'application/ogg',
15
+ 'audio/opus',
16
+ 'audio/wav',
17
+ 'audio/webm',
18
+ 'audio/3gpp2'
19
+ ],
20
+ image: [
21
+ 'image/bmp',
22
+ 'image/gif',
23
+ 'image/jpeg',
24
+ 'image/png',
25
+ 'image/svg+xml',
26
+ 'image/vnd.microsoft.icon',
27
+ 'image/tiff',
28
+ 'image/webp'
29
+ ],
30
+ text: [
31
+ 'application/json',
32
+ 'application/ld+json',
33
+ 'text/plain',
34
+ ]
35
+ };
@@ -8,10 +8,6 @@ module.exports.TemplatesList = {
8
8
  login: 'login.html',
9
9
  dashboard: 'dashboard.html',
10
10
  management: 'management.html',
11
- mapsWizard: 'maps-wizard.html',
12
- mapsWizardMapsSelection: 'maps-wizard-maps-selection.html',
13
- objectsImport: 'objects-import.html',
14
- skillsImport: 'skills-import.html',
15
11
  list: 'list.html',
16
12
  listContent: 'list-content.html',
17
13
  view: 'view.html',
@@ -41,10 +37,5 @@ module.exports.TemplatesList = {
41
37
  button: 'button.html',
42
38
  file: 'file.html'
43
39
  }
44
- },
45
- sections: {
46
- view: {
47
- rooms: 'rooms.html'
48
- }
49
40
  }
50
41
  };
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * Reldens - TemplatesToPathMapper
4
+ *
5
+ */
6
+
7
+ const { sc } = require('@reldens/utils');
8
+ const { FileHandler } = require('@reldens/server-utils');
9
+
10
+ class TemplatesToPathMapper
11
+ {
12
+
13
+ map(templateList, path)
14
+ {
15
+ let result = {};
16
+ for(let templateName of Object.keys(templateList)){
17
+ if(sc.isObject(templateList[templateName])){
18
+ result[templateName] = this.map(templateList[templateName], FileHandler.joinPaths(path, templateName));
19
+ continue;
20
+ }
21
+ result[templateName] = FileHandler.joinPaths(path, templateList[templateName]);
22
+ }
23
+ return result;
24
+ }
25
+
26
+ }
27
+
28
+ module.exports.TemplatesToPathMapper = new TemplatesToPathMapper();
@@ -0,0 +1,10 @@
1
+
2
+ -- Default homepage:
3
+
4
+ -- Create a default homepage route if not exists
5
+ REPLACE INTO `cms_pages` (`id`, `title`, `content`, `template`, `created_at`) VALUES
6
+ (1, 'Home', '<h1>Welcome to Reldens CMS</h1><p>This is your homepage. Edit this content in the admin panel.</p>', 'page', NOW());
7
+
8
+ -- Create a default route to the homepage
9
+ REPLACE INTO `routes` (`id`, `path`, `router`, `content_id`, `title`, `meta_description`, `status`, `created_at`) VALUES
10
+ (1, '/home', 'cmsPages', 1, 'Home', 'Welcome to Reldens CMS', 'published', NOW());
@@ -1,19 +1,5 @@
1
1
 
2
- -- Install SQL for Reldens CMS
3
-
4
- CREATE TABLE IF NOT EXISTS `users` (
5
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
6
- `email` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
7
- `username` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
8
- `password` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
9
- `role_id` INT(10) UNSIGNED NOT NULL,
10
- `status` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
11
- `created_at` TIMESTAMP NOT NULL DEFAULT (NOW()),
12
- `updated_at` TIMESTAMP NOT NULL DEFAULT (NOW()) ON UPDATE CURRENT_TIMESTAMP,
13
- PRIMARY KEY (`id`) USING BTREE,
14
- UNIQUE KEY `email` (`email`) USING BTREE,
15
- UNIQUE KEY `username` (`username`) USING BTREE
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2
+ -- Install Reldens CMS
17
3
 
18
4
  CREATE TABLE IF NOT EXISTS `routes` (
19
5
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -74,11 +60,3 @@ CREATE TABLE IF NOT EXISTS `entities_meta` (
74
60
  PRIMARY KEY (`id`) USING BTREE,
75
61
  UNIQUE KEY `entity_meta` (`entity_name`, `entity_id`, `meta_key`) USING BTREE
76
62
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
77
-
78
- -- Create a default homepage route if not exists
79
- INSERT IGNORE INTO `cms_pages` (`id`, `title`, `content`, `template`, `created_at`) VALUES
80
- (1, 'Home', '<h1>Welcome to Reldens CMS</h1><p>This is your homepage. Edit this content in the admin panel.</p>', 'page', NOW());
81
-
82
- -- Create a default route to the homepage
83
- INSERT IGNORE INTO `routes` (`path`, `router`, `content_id`, `title`, `meta_description`, `status`, `created_at`) VALUES
84
- ('/home', 'cms_pages', 1, 'Home', 'Welcome to Reldens CMS', 'published', NOW());
@@ -0,0 +1,16 @@
1
+
2
+ -- Default db-users authentication:
3
+
4
+ CREATE TABLE IF NOT EXISTS `users` (
5
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
6
+ `email` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
7
+ `username` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
8
+ `password` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
9
+ `role_id` INT(10) UNSIGNED NOT NULL,
10
+ `status` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
11
+ `created_at` TIMESTAMP NOT NULL DEFAULT (NOW()),
12
+ `updated_at` TIMESTAMP NOT NULL DEFAULT (NOW()) ON UPDATE CURRENT_TIMESTAMP,
13
+ PRIMARY KEY (`id`) USING BTREE,
14
+ UNIQUE KEY `email` (`email`) USING BTREE,
15
+ UNIQUE KEY `username` (`username`) USING BTREE
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/cms",
3
3
  "scope": "@reldens",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "description": "Reldens - CMS",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@reldens/server-utils": "^0.16.0",
36
- "@reldens/storage": "^0.43.0",
36
+ "@reldens/storage": "^0.45.0",
37
37
  "@reldens/utils": "^0.47.0",
38
38
  "dotenv": "^16.5.0",
39
39
  "mustache": "^4.2.0"
@@ -1,16 +1,16 @@
1
1
  # Database Configuration
2
- RELDENS_CMS_DB_CLIENT={{&dbClient}}
3
- RELDENS_CMS_DB_HOST={{&dbHost}}
4
- RELDENS_CMS_DB_PORT={{&dbPort}}
5
- RELDENS_CMS_DB_NAME={{&dbName}}
6
- RELDENS_CMS_DB_USER={{&dbUser}}
7
- RELDENS_CMS_DB_PASSWORD={{&dbPassword}}
8
- RELDENS_CMS_DB_DRIVER={{&dbDriver}}
2
+ RELDENS_DB_CLIENT={{&dbClient}}
3
+ RELDENS_DB_HOST={{&dbHost}}
4
+ RELDENS_DB_PORT={{&dbPort}}
5
+ RELDENS_DB_NAME={{&dbName}}
6
+ RELDENS_DB_USER={{&dbUser}}
7
+ RELDENS_DB_PASSWORD={{&dbPassword}}
8
+ RELDENS_DB_DRIVER={{&dbDriver}}
9
9
 
10
10
  # Admin Panel Configuration
11
- RELDENS_CMS_ADMIN_PATH={{&adminPath}}
12
- RELDENS_CMS_ADMIN_SECRET={{&adminSecret}}
11
+ RELDENS_ADMIN_ROUTE_PATH={{&adminPath}}
12
+ RELDENS_ADMIN_SECRET={{&adminSecret}}
13
13
 
14
14
  # Server Configuration
15
- RELDENS_CMS_HOST={{&host}}
16
- RELDENS_CMS_PORT={{&port}}
15
+ RELDENS_APP_HOST={{&host}}
16
+ RELDENS_APP_PORT={{&port}}