@knovator/pagecreator-node 0.0.6 → 0.2.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 (116) hide show
  1. package/README.md +230 -161
  2. package/package.json +3 -6
  3. package/src/constants/index.ts +26 -0
  4. package/src/controllers/ItemController.ts +139 -0
  5. package/src/controllers/PageController.ts +65 -0
  6. package/src/controllers/UserController.ts +265 -0
  7. package/src/controllers/WidgetController.ts +165 -0
  8. package/src/index.ts +29 -0
  9. package/src/models/Item.ts +29 -0
  10. package/src/models/Page.ts +17 -0
  11. package/src/models/SrcSet.ts +16 -0
  12. package/src/models/Widget.ts +44 -0
  13. package/src/models/index.ts +6 -0
  14. package/src/plugins/softDelete.ts +84 -0
  15. package/src/routes/ItemRoute.ts +32 -0
  16. package/src/routes/PageRoute.ts +31 -0
  17. package/src/routes/UserRoute.ts +32 -0
  18. package/src/routes/WidgetRoute.ts +56 -0
  19. package/src/services/dbService.ts +82 -0
  20. package/src/types/{IRequest.d.ts → IRequest.ts} +4 -3
  21. package/src/types/{IResponse.d.ts → IResponse.ts} +4 -3
  22. package/src/types/{Router.d.ts → Router.ts} +2 -1
  23. package/src/types/common.ts +130 -0
  24. package/src/types/enums.ts +13 -0
  25. package/src/types/{index.d.ts → index.ts} +0 -0
  26. package/src/utils/defaults.ts +30 -0
  27. package/src/utils/helper.ts +133 -0
  28. package/src/utils/responseHandlers.ts +54 -0
  29. package/src/utils/validate.ts +22 -0
  30. package/src/utils/validations/item.ts +51 -0
  31. package/src/utils/validations/page.ts +59 -0
  32. package/src/utils/validations/user.ts +9 -0
  33. package/src/utils/validations/widget.ts +118 -0
  34. package/src/constants/index.d.ts +0 -16
  35. package/src/constants/index.js +0 -30
  36. package/src/constants/index.js.map +0 -1
  37. package/src/controllers/PageController.d.ts +0 -4
  38. package/src/controllers/PageController.js +0 -61
  39. package/src/controllers/PageController.js.map +0 -1
  40. package/src/controllers/TileController.d.ts +0 -4
  41. package/src/controllers/TileController.js +0 -45
  42. package/src/controllers/TileController.js.map +0 -1
  43. package/src/controllers/UserController.d.ts +0 -2
  44. package/src/controllers/UserController.js +0 -174
  45. package/src/controllers/UserController.js.map +0 -1
  46. package/src/controllers/WidgetController.d.ts +0 -8
  47. package/src/controllers/WidgetController.js +0 -129
  48. package/src/controllers/WidgetController.js.map +0 -1
  49. package/src/index.d.ts +0 -8
  50. package/src/index.js +0 -29
  51. package/src/index.js.map +0 -1
  52. package/src/models/Page.d.ts +0 -3
  53. package/src/models/Page.js +0 -16
  54. package/src/models/Page.js.map +0 -1
  55. package/src/models/Tile.d.ts +0 -3
  56. package/src/models/Tile.js +0 -29
  57. package/src/models/Tile.js.map +0 -1
  58. package/src/models/Widget.d.ts +0 -3
  59. package/src/models/Widget.js +0 -41
  60. package/src/models/Widget.js.map +0 -1
  61. package/src/models/index.d.ts +0 -4
  62. package/src/models/index.js +0 -11
  63. package/src/models/index.js.map +0 -1
  64. package/src/plugins/softDelete.d.ts +0 -7
  65. package/src/plugins/softDelete.js +0 -64
  66. package/src/plugins/softDelete.js.map +0 -1
  67. package/src/routes/PageRoute.d.ts +0 -3
  68. package/src/routes/PageRoute.js +0 -30
  69. package/src/routes/PageRoute.js.map +0 -1
  70. package/src/routes/TileRoute.d.ts +0 -3
  71. package/src/routes/TileRoute.js +0 -31
  72. package/src/routes/TileRoute.js.map +0 -1
  73. package/src/routes/UserRoute.d.ts +0 -3
  74. package/src/routes/UserRoute.js +0 -22
  75. package/src/routes/UserRoute.js.map +0 -1
  76. package/src/routes/WidgetRoute.d.ts +0 -3
  77. package/src/routes/WidgetRoute.js +0 -47
  78. package/src/routes/WidgetRoute.js.map +0 -1
  79. package/src/services/dbService.d.ts +0 -8
  80. package/src/services/dbService.js +0 -60
  81. package/src/services/dbService.js.map +0 -1
  82. package/src/types/IRequest.js +0 -3
  83. package/src/types/IRequest.js.map +0 -1
  84. package/src/types/IResponse.js +0 -3
  85. package/src/types/IResponse.js.map +0 -1
  86. package/src/types/Router.js +0 -3
  87. package/src/types/Router.js.map +0 -1
  88. package/src/types/common.d.ts +0 -66
  89. package/src/types/common.js +0 -3
  90. package/src/types/common.js.map +0 -1
  91. package/src/types/enums.d.ts +0 -11
  92. package/src/types/enums.js +0 -18
  93. package/src/types/enums.js.map +0 -1
  94. package/src/types/index.js +0 -9
  95. package/src/types/index.js.map +0 -1
  96. package/src/utils/defaults.d.ts +0 -2
  97. package/src/utils/defaults.js +0 -23
  98. package/src/utils/defaults.js.map +0 -1
  99. package/src/utils/responseHandlers.d.ts +0 -6
  100. package/src/utils/responseHandlers.js +0 -57
  101. package/src/utils/responseHandlers.js.map +0 -1
  102. package/src/utils/validate.d.ts +0 -4
  103. package/src/utils/validate.js +0 -24
  104. package/src/utils/validate.js.map +0 -1
  105. package/src/utils/validations/page.d.ts +0 -7
  106. package/src/utils/validations/page.js +0 -58
  107. package/src/utils/validations/page.js.map +0 -1
  108. package/src/utils/validations/tile.d.ts +0 -7
  109. package/src/utils/validations/tile.js +0 -43
  110. package/src/utils/validations/tile.js.map +0 -1
  111. package/src/utils/validations/user.d.ts +0 -3
  112. package/src/utils/validations/user.js +0 -12
  113. package/src/utils/validations/user.js.map +0 -1
  114. package/src/utils/validations/widget.d.ts +0 -9
  115. package/src/utils/validations/widget.js +0 -108
  116. package/src/utils/validations/widget.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  <!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->
2
+
2
3
  <a name="readme-top"></a>
3
4
 
4
5
  [![Contributors][contributors-shield]][contributors-url]
@@ -7,8 +8,6 @@
7
8
  [![Issues][issues-shield]][issues-url]
8
9
  [![MIT License][license-shield]][license-url]
9
10
 
10
-
11
-
12
11
  <!-- PROJECT LOGO -->
13
12
  <br />
14
13
  <div align="center">
@@ -32,8 +31,6 @@
32
31
  </p>
33
32
  </div>
34
33
 
35
-
36
-
37
34
  <!-- TABLE OF CONTENTS -->
38
35
  <details>
39
36
  <summary>Table of Contents</summary>
@@ -59,34 +56,35 @@
59
56
  </ol>
60
57
  </details>
61
58
 
62
-
63
-
64
59
  <!-- ABOUT THE PROJECT -->
60
+
65
61
  ## About The Project
66
62
 
67
63
  `@knovator/pagecreator-node` is built with intent to build pages that are depend on backend data, and admin can change how page will look like.
68
64
 
69
65
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
70
66
 
71
-
72
67
  ### Built With
73
68
 
74
- * [Typescript](https://www.typescriptlang.org/)
75
- * [mongoose](https://mongoosejs.com/)
76
- * [express](https://expressjs.com/)
77
- * [mongoose-paginate-v2](https://www.npmjs.com/package/mongoose-paginate-v2)
78
- * [joi](https://www.npmjs.com/package/joi)
69
+ - [Typescript](https://www.typescriptlang.org/)
70
+ - [mongoose](https://mongoosejs.com/)
71
+ - [express](https://expressjs.com/)
72
+ - [mongoose-paginate-v2](https://www.npmjs.com/package/mongoose-paginate-v2)
73
+ - [joi](https://www.npmjs.com/package/joi)
79
74
 
80
75
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
81
76
 
82
77
  <!-- GETTING STARTED -->
78
+
83
79
  ## Getting Started
84
80
 
85
- To integrate `@knovator/pagecreator-node`, you should be having basic nodejs application up and running with express (optionally using mongoose for mongodb database). `@knovator/pagecreator-node` provides routes for `widget`, `page`, `tile` and `user` to use in application.
81
+ To integrate `@knovator/pagecreator-node`, you should be having basic nodejs application up and running with express (optionally using mongoose for mongodb database). `@knovator/pagecreator-node` provides routes for `widget`, `page`, `item` and `user` to use in application.
86
82
 
87
83
  ### Prerequisites
84
+
88
85
  - It's good start to have `nodejs` application up and running with `express`. Good to have used [i18next](https://www.npmjs.com/package/i18next) to add message in response codes.
89
86
  - `routes` uses `mongoose` connection established by application, so it's required to connect to database before using package. Example,
87
+
90
88
  ```js
91
89
  // db.js
92
90
  const mongoose = require('mongoose');
@@ -100,57 +98,58 @@ To integrate `@knovator/pagecreator-node`, you should be having basic nodejs app
100
98
 
101
99
  module.exports = mongoose;
102
100
  ```
101
+
103
102
  - Image upload route for `upload` & `remove` is needed to declare externally. Example,
103
+
104
104
  ```js
105
105
  // fileRoute.js
106
106
  const express = require('express');
107
107
  const router = express.Router();
108
108
 
109
109
  router.post(`/files/upload`, (req, res) => {
110
- // TO DO: some file storage operation
111
- let uri = "/image.jpg";
112
- let id = "62c54b15524b6b59d2313c02";
113
- res.json({
114
- code: 'SUCCESS',
115
- data: { id, uri },
116
- message: 'File uploaded successfully'
117
- });
110
+ // TO DO: some file storage operation
111
+ let uri = '/image.jpg';
112
+ let id = '62c54b15524b6b59d2313c02';
113
+ res.json({
114
+ code: 'SUCCESS',
115
+ data: { id, uri },
116
+ message: 'File uploaded successfully',
117
+ });
118
118
  });
119
119
 
120
120
  router.delete(`/files/remove/:id`, (req, res) => {
121
- // TO DO: some file remove operation
122
- res.json({
123
- code: 'SUCCESS',
124
- data: {},
125
- message: 'File removed successfully'
126
- })
127
- })
121
+ // TO DO: some file remove operation
122
+ res.json({
123
+ code: 'SUCCESS',
124
+ data: {},
125
+ message: 'File removed successfully',
126
+ });
127
+ });
128
128
 
129
129
  module.exports = router;
130
130
  ```
131
131
 
132
-
133
-
134
132
  **Sample App file**
135
- ```js
136
- require('./src/db');
137
- require('./src/models/file');
138
-
139
- const cors = require('cors');
140
- const express = require("express");
141
- const fileRoutes = require('./fileRoute.js');
142
- const PORT = 8080;
143
-
144
- const app = express();
145
- app.use(cors());
146
- app.use(express.static("public"));
147
- app.use(fileRoutes);
148
-
149
- // ...
150
- app.listen(PORT, () => {
151
- console.log(`App started on ${PORT}`);
152
- });
153
- ```
133
+
134
+ ```js
135
+ require('./src/db');
136
+ require('./src/models/file');
137
+
138
+ const cors = require('cors');
139
+ const express = require('express');
140
+ const fileRoutes = require('./fileRoute.js');
141
+ const PORT = 8080;
142
+
143
+ const app = express();
144
+ app.use(cors());
145
+ app.use(express.static('public'));
146
+ app.use(fileRoutes);
147
+
148
+ // ...
149
+ app.listen(PORT, () => {
150
+ console.log(`App started on ${PORT}`);
151
+ });
152
+ ```
154
153
 
155
154
  ### Installation
156
155
 
@@ -163,76 +162,137 @@ To integrate `@knovator/pagecreator-node`, you should be having basic nodejs app
163
162
 
164
163
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
165
164
 
166
-
167
-
168
165
  <!-- USAGE EXAMPLES -->
166
+
169
167
  ## Usage
170
168
 
171
169
  App/Main file is a good place to use `@knovator/pagecreator-node`
172
- ```js
173
- const { setConfig, WidgetRoutes, TileRoutes, FileUploadRoute, PageRoutes, UserRoutes } = require('@knovator/pagecreator-node');
174
-
175
- setConfig({
176
- collections: [
177
- {
178
- title: 'Notifications',
179
- collectionName: 'notifications',
180
- filters: { isDeleted: false, isActive: true },
181
- searchColumns: ['name', 'code'],
182
- },
183
- ],
184
- });
185
-
186
- app.use('/widgets', WidgetRoutes);
187
- app.use('/tiles', TileRoutes);
188
- app.use('/media', FileUploadRoute);
189
- app.use('/pages', PageRoutes);
190
- app.use('/users', UserRoutes);
191
170
 
192
- app.listen(PORT, () => {
193
- console.log(`App started on ${PORT}`);
194
- });
171
+ ```js
172
+ const {
173
+ setConfig,
174
+ WidgetRoutes,
175
+ ItemRoutes,
176
+ FileUploadRoute,
177
+ PageRoutes,
178
+ UserRoutes,
179
+ } = require('@knovator/pagecreator-node');
180
+
181
+ setConfig({
182
+ collections: [
183
+ {
184
+ title: 'Notifications',
185
+ collectionName: 'notifications',
186
+ filters: { isDeleted: false, isActive: true },
187
+ searchColumns: ['name', 'code'],
188
+ },
189
+ ],
190
+ });
191
+
192
+ app.use('/widgets', WidgetRoutes);
193
+ app.use('/items', ItemRoutes);
194
+ app.use('/media', FileUploadRoute);
195
+ app.use('/pages', PageRoutes);
196
+ app.use('/users', UserRoutes);
197
+
198
+ app.listen(PORT, () => {
199
+ console.log(`App started on ${PORT}`);
200
+ });
195
201
  ```
196
202
 
197
203
  Through `setConfig` function e can set `logger`, `collections` and `catchAsync` functions as parameters. By `collections`, we can add reference of application collections.
204
+
198
205
  ### parameter explanations
206
+
199
207
  - `logger`
200
208
  - Provides ability to add logging for Database and Validation
201
209
  ```js
202
210
  // default
203
- console
211
+ console;
204
212
  ```
205
213
  - `catchAsync`
206
214
  - Wraps functions to handle async errors
207
- ```js
208
- // default
209
- function catchAsync(fn) {
210
- return function (req, res, next) {
211
- Promise.resolve(fn(req, res, next)).catch((err) => {
212
- // this.logger.error(err.message);
213
- res.status(internalServerError).json({
214
- code: RESPONSE_CODE.ERROR,
215
- message: err.message,
216
- data: {},
217
- });
215
+ ```js
216
+ // default
217
+ function catchAsync(fn) {
218
+ return function (req, res, next) {
219
+ Promise.resolve(fn(req, res, next)).catch((err) => {
220
+ // this.logger.error(err.message);
221
+ res.status(internalServerError).json({
222
+ code: RESPONSE_CODE.ERROR,
223
+ message: err.message,
224
+ data: {},
218
225
  });
219
- };
220
- }
221
- ```
226
+ });
227
+ };
228
+ }
229
+ ```
222
230
  - `collections`
223
- - Array of collection items to add reference of collections in package.
231
+ - Array of collection items to add reference of collections in package.
224
232
 
225
233
  #### Collection Item Format
226
- | Code | Description |
227
- | --- | ----------- |
228
- | title | Title of collection name to show in UI |
229
- | collectionName | Collection name specified in database |
230
- | filters | Filter object to apply while getting data, like `{ isDeleted: false, isActive: true }` |
231
- | searchColumns | Array of fields to to perform search |
234
+
235
+ | Code | Description |
236
+ | -------------- | -------------------------------------------------------------------------------------- |
237
+ | title | Title of collection name to show in UI |
238
+ | collectionName | Collection name specified in database |
239
+ | filters | Filter object to apply while getting data, like `{ isDeleted: false, isActive: true }` |
240
+ | searchColumns | Array of fields to to perform search |
241
+ | lookup | `$lookup` object to apply while getting data through aggregation |
242
+ | project | `$project` object to apply while getting data through aggregation |
243
+ | match | `$match` object to apply while getting data through aggregation |
244
+
245
+ **Example**,
246
+
247
+ ```js
248
+ setConfig({
249
+ collections: [
250
+ {
251
+ title: 'Notifications',
252
+ collectionName: 'notifications',
253
+ filters: { isDeleted: false, isActive: true },
254
+ searchColumns: ['name', 'code'],
255
+ lookup: {
256
+ from: 'file',
257
+ let: {
258
+ id: '$fileId',
259
+ },
260
+ pipeline: [
261
+ {
262
+ $match: {
263
+ $expr: {
264
+ $eq: ['$_id', '$$id'],
265
+ },
266
+ },
267
+ },
268
+ {
269
+ $project: {
270
+ _id: 1,
271
+ nm: 1,
272
+ uri: 1,
273
+ mimeType: 1,
274
+ },
275
+ },
276
+ ],
277
+ as: 'fileId',
278
+ },
279
+ project: {
280
+ _id: 1,
281
+ nm: 1,
282
+ fileId: 1,
283
+ },
284
+ match: {
285
+ deletedAt: { $exists: false },
286
+ },
287
+ },
288
+ ],
289
+ });
290
+ ```
232
291
 
233
292
  ## Routes Infomration
234
293
 
235
294
  Response follows following structure
295
+
236
296
  ```js
237
297
  {
238
298
  code: RESPONSE_CODES,
@@ -242,93 +302,102 @@ Response follows following structure
242
302
  ```
243
303
 
244
304
  ### Response Codes
245
- | Code | Description |
246
- | --- | ----------- |
305
+
306
+ | Code | Description |
307
+ | ------- | ------------------------------------ |
247
308
  | SUCCESS | When request fullfiled without error |
248
- | ERROR | When request fullfiled with error |
309
+ | ERROR | When request fullfiled with error |
249
310
 
250
311
  ### Custom Validation messages
251
- | Message | Description |
252
- | --- | ----------- |
312
+
313
+ | Message | Description |
314
+ | ---------------------------------- | ----------------------------------------------- |
253
315
  | Widget with same code is available | When widget with same code is exist in database |
254
316
 
255
317
  ### HTTP Status Codes
256
- | HTTP | Description |
257
- | --- | ----------- |
258
- | 200 | When request fullfiled without error |
259
- | 201 | When document is created |
260
- | 500 | When internal server occurred |
261
- | 422 | When Validation error occurred |
318
+
319
+ | HTTP | Description |
320
+ | ---- | ------------------------------------ |
321
+ | 200 | When request fullfiled without error |
322
+ | 201 | When document is created |
323
+ | 500 | When internal server occurred |
324
+ | 422 | When Validation error occurred |
262
325
 
263
326
  ### Routes
327
+
264
328
  This are the routes that gets integrated by `@knovator/pagecreator-node`,
329
+
265
330
  #### Widget
266
- | Route | Method | Description |
267
- | --- | ----- | ----------- |
268
- | `/widget-types` | **GET** | Get widget-types like `Image` and provided `collections` |
269
- | `/selection-types` | **GET** | Get Selection types like `Fixed Card` and `Carousel` |
270
- | `/list` | **POST** | List widget data in pagination |
271
- | `/` | **POST** | Create `widget` |
272
- | `/:id` | **PUT** | Update `widget` |
273
- | `/:id` | **PATCH** | Partial Update `widget` |
274
- | `/:id` | **DELETE** | Delete widget whose `id` send in body |
275
- | `/collection-data` | **POST** | Get collection data |
331
+
332
+ | Route | Method | Description |
333
+ | ------------------ | ---------- | -------------------------------------------------------- |
334
+ | `/widget-types` | **GET** | Get widget-types like `Image` and provided `collections` |
335
+ | `/selection-types` | **GET** | Get Selection types like `Fixed Card` and `Carousel` |
336
+ | `/list` | **POST** | List widget data in pagination |
337
+ | `/` | **POST** | Create `widget` |
338
+ | `/:id` | **PUT** | Update `widget` |
339
+ | `/:id` | **PATCH** | Partial Update `widget` |
340
+ | `/:id` | **DELETE** | Delete widget whose `id` send in body |
341
+ | `/collection-data` | **POST** | Get collection data |
276
342
 
277
343
  #### Page
278
- | Route | Method | Description |
279
- | --- | ----- | ----------- |
280
- | `/list` | **POST** | List page data in pagination |
281
- | `/` | **POST** | Create `page` |
282
- | `/:id` | **PUT** | Update `page` |
283
- | `/:id` | **DELETE** | Delete page whose `id` send in body |
284
-
285
- #### Tile
286
- | Route | Method | Description |
287
- | --- | ----- | ----------- |
288
- | `/:widgetId` | **GET** | Get Tiles data for `widgetId` |
289
- | `/` | **POST** | Create `tile` |
290
- | `/:id` | **PUT** | Update `tile` |
291
- | `/:id` | **DELETE** | Delete tile whose `id` send in body |
344
+
345
+ | Route | Method | Description |
346
+ | ------- | ---------- | ----------------------------------- |
347
+ | `/list` | **POST** | List page data in pagination |
348
+ | `/` | **POST** | Create `page` |
349
+ | `/:id` | **PUT** | Update `page` |
350
+ | `/:id` | **DELETE** | Delete page whose `id` send in body |
351
+
352
+ #### Item
353
+
354
+ | Route | Method | Description |
355
+ | ------------ | ---------- | ----------------------------------- |
356
+ | `/:widgetId` | **GET** | Get Items data for `widgetId` |
357
+ | `/` | **POST** | Create `item` |
358
+ | `/:id` | **PUT** | Update `item` |
359
+ | `/:id` | **DELETE** | Delete item whose `id` send in body |
292
360
 
293
361
  #### User
294
- | Route | Method | Description |
295
- | --- | ----- | ----------- |
362
+
363
+ | Route | Method | Description |
364
+ | -------------- | -------- | -------------------------------------------------------- |
296
365
  | `/widget-data` | **POST** | Get widget-data data for specified widget `code` in body |
297
- | `/page-data` | **POST** | Get page-data data for specified page `code` in body |
366
+ | `/page-data` | **POST** | Get page-data data for specified page `code` in body |
298
367
 
299
368
  ### `descriptor` codes & `i18n` code for messages
300
369
 
301
370
  Nextjs [i18n](https://www.npmjs.com/package/i18next) package adds facility for internationalization in nodejs application, and it's used in following manner
371
+
302
372
  ```js
303
373
  // usage
304
- req?.i18n?.(CODE)
374
+ req?.i18n?.(CODE);
305
375
  ```
306
- | CODE | Description |
307
- | --- | ----------- |
308
- | `widget.getWidgetTypes` | While fetching widget types |
309
- | `widget.getSelectionTypes` | While fetching selection types |
310
- | `widget.getAll` | While fetching widgets |
311
- | `widget.create` | While creating widget |
312
- | `widget.update` | While updating widget |
313
- | `widget.partialUpdate` | While doing partialUpdate for widget, like toggle `IsActive` |
314
- | `widget.delete` | While deleting widget |
315
- | `widget.getCollectionData` | While getting widget `collection-data` |
316
- | `page.getAll` | While getting pages in pagination |
317
- | `page.create` | While creating page |
318
- | `page.update` | While updating page |
319
- | `page.delete` | While deleting page |
320
- | `tile.getAll` | While getting tiles for widget |
321
- | `tile.create` | While creating tile |
322
- | `tile.update` | While updating tile |
323
- | `user.getWidgetData` | While getting widget data |
324
- | `user.getPageData` | While getting page data |
325
-
326
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
327
-
328
376
 
377
+ | CODE | Description |
378
+ | -------------------------- | ------------------------------------------------------------ |
379
+ | `widget.getItemsTypes` | While fetching widget types |
380
+ | `widget.getWidgetTypes` | While fetching selection types |
381
+ | `widget.getAll` | While fetching widgets |
382
+ | `widget.create` | While creating widget |
383
+ | `widget.update` | While updating widget |
384
+ | `widget.partialUpdate` | While doing partialUpdate for widget, like toggle `IsActive` |
385
+ | `widget.delete` | While deleting widget |
386
+ | `widget.getCollectionData` | While getting widget `collection-data` |
387
+ | `page.getAll` | While getting pages in pagination |
388
+ | `page.create` | While creating page |
389
+ | `page.update` | While updating page |
390
+ | `page.delete` | While deleting page |
391
+ | `item.getAll` | While getting items for widget |
392
+ | `item.create` | While creating item |
393
+ | `item.update` | While updating item |
394
+ | `user.getWidgetData` | While getting widget data |
395
+ | `user.getPageData` | While getting page data |
329
396
 
397
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
330
398
 
331
399
  <!-- CONTRIBUTING -->
400
+
332
401
  ## Contributing
333
402
 
334
403
  Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
@@ -344,20 +413,20 @@ Don't forget to give the project a star! Thanks again!
344
413
 
345
414
  <p align="right">(<a href="#top">back to top</a>)</p>
346
415
 
347
-
348
-
349
416
  <!-- LICENSE -->
417
+
350
418
  ## License
351
419
 
352
420
  Distributed under the MIT License. See `LICENSE.txt` for more information.
353
421
 
354
422
  <p align="right">(<a href="#top">back to top</a>)</p>
355
423
 
356
-
357
424
  <!-- CONTACT -->
425
+
358
426
  ## Contact
359
427
 
360
428
  Knovator Technologies
429
+
361
430
  - Twitter [@knovator](https://twitter.com/knovator)
362
431
  - Web [https://knovator.com/](https://knovator.com/)
363
432
 
@@ -365,9 +434,9 @@ Project Link: [https://github.com/knovator/pagecreator](https://github.com/knova
365
434
 
366
435
  <p align="right">(<a href="#top">back to top</a>)</p>
367
436
 
368
-
369
437
  <!-- MARKDOWN LINKS & IMAGES -->
370
438
  <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
439
+
371
440
  [contributors-shield]: https://img.shields.io/github/contributors/knovator/pagecreator.svg?style=for-the-badge
372
441
  [contributors-url]: https://github.com/knovator/pagecreator/graphs/contributors
373
442
  [forks-shield]: https://img.shields.io/github/forks/knovator/pagecreator.svg?style=for-the-badge
@@ -377,4 +446,4 @@ Project Link: [https://github.com/knovator/pagecreator](https://github.com/knova
377
446
  [issues-shield]: https://img.shields.io/github/issues/knovator/pagecreator.svg?style=for-the-badge
378
447
  [issues-url]: https://github.com/knovator/pagecreator/issues
379
448
  [license-shield]: https://img.shields.io/github/license/knovator/pagecreator.svg?style=for-the-badge
380
- [license-url]: https://github.com/knovator/pagecreator/blob/master/LICENSE.txt
449
+ [license-url]: https://github.com/knovator/pagecreator/blob/master/LICENSE.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knovator/pagecreator-node",
3
- "version": "0.0.6",
3
+ "version": "0.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "knovator (https://knovator.com/)",
6
6
  "description": "PageCreator Node.js module",
@@ -27,14 +27,11 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "mongoose": "*",
30
- "express": "*",
31
- "tslib": "^2.3.0"
30
+ "express": "*"
32
31
  },
33
32
  "files": [
34
33
  "src",
35
34
  "package.json",
36
35
  "README.md"
37
- ],
38
- "main": "./src/index.js",
39
- "typings": "./src/index.d.ts"
36
+ ]
40
37
  }
@@ -0,0 +1,26 @@
1
+ export const VALIDATION = {
2
+ WIDGET_EXISTS: 'Widget with same code is available',
3
+ };
4
+ export const RESPONSE_CODES = {
5
+ DEFAULT: 'SUCCESS',
6
+ ERROR: 'ERROR',
7
+ };
8
+ export const REGEXS = {
9
+ OBJECTID_CAST_FAILED: /Cast to ObjectId failed/gm,
10
+ };
11
+ export const MONGOOSE_FIND_QUERIES = [
12
+ 'count',
13
+ 'find',
14
+ 'findOne',
15
+ 'findOneAndDelete',
16
+ 'findOneAndRemove',
17
+ 'findOneAndUpdate',
18
+ 'update',
19
+ 'updateOne',
20
+ 'updateMany',
21
+ ];
22
+ export const success = 200;
23
+ export const create = 201;
24
+ export const internalServerError = 500;
25
+ export const validationError = 422;
26
+ export const messageRoutePrefix = 'msg';