blend-kit 1.0.1

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 (210) hide show
  1. package/dist/helper/ApiHelper.js +0 -0
  2. package/dist/helper/BasicHelper.js +28 -0
  3. package/dist/helper/CommonHelper.js +10 -0
  4. package/dist/helper/DataHelper.js +241 -0
  5. package/dist/helper/ExpressHelper.js +728 -0
  6. package/dist/helper/FrontEndApiHelper.js +485 -0
  7. package/dist/helper/FrontEndReactApiHelper.js +483 -0
  8. package/dist/helper/MongoHelper.js +143 -0
  9. package/dist/helper/RNHelper.js +560 -0
  10. package/dist/helper/ReactHelper.js +524 -0
  11. package/dist/helper/SectionHelper.js +152 -0
  12. package/dist/helper/fileHelper.js +127 -0
  13. package/dist/helper/grammarHelper/BlendApiGrammarHelper.js +48 -0
  14. package/dist/helper/grammarHelper/BlendBasicGrammarHelper.js +98 -0
  15. package/dist/helper/grammarHelper/BlendDataGrammarHelper.js +47 -0
  16. package/dist/helper/grammarHelper/BlendMDPGrammarHelper.js +29 -0
  17. package/dist/helper/grammarHelper/BlendMongoGrammarHelper.js +51 -0
  18. package/dist/helper/grammarHelper/BlendRNGrammarHelper.js +56 -0
  19. package/dist/helper/grammarHelper/BlendReactGrammarHelper.js +55 -0
  20. package/dist/helper/grammarHelper/GrammarErrorHelper.js +16 -0
  21. package/dist/index.js +159 -0
  22. package/dist/parser/blendApi/src/grammar/BlendApiLexer.js +201 -0
  23. package/dist/parser/blendApi/src/grammar/BlendApiListener.js +3 -0
  24. package/dist/parser/blendApi/src/grammar/BlendApiParser.js +961 -0
  25. package/dist/parser/blendData/src/grammar/BlendDataLexer.js +154 -0
  26. package/dist/parser/blendData/src/grammar/BlendDataListener.js +3 -0
  27. package/dist/parser/blendData/src/grammar/BlendDataParser.js +641 -0
  28. package/dist/parser/blendMDP/src/grammar/BlendMDPLexer.js +151 -0
  29. package/dist/parser/blendMDP/src/grammar/BlendMDPListener.js +3 -0
  30. package/dist/parser/blendMDP/src/grammar/BlendMDPParser.js +490 -0
  31. package/dist/parser/blendMongo/src/grammar/BlendMongoLexer.js +187 -0
  32. package/dist/parser/blendMongo/src/grammar/BlendMongoListener.js +3 -0
  33. package/dist/parser/blendMongo/src/grammar/BlendMongoParser.js +848 -0
  34. package/dist/parser/blendRN/src/grammar/BlendRNLexer.js +172 -0
  35. package/dist/parser/blendRN/src/grammar/BlendRNListener.js +3 -0
  36. package/dist/parser/blendRN/src/grammar/BlendRNParser.js +657 -0
  37. package/dist/parser/blendReact/src/grammar/BlendReactLexer.js +159 -0
  38. package/dist/parser/blendReact/src/grammar/BlendReactListener.js +3 -0
  39. package/dist/parser/blendReact/src/grammar/BlendReactParser.js +644 -0
  40. package/dist/parser/blendbasic/src/grammar/BlendBasicLexer.js +147 -0
  41. package/dist/parser/blendbasic/src/grammar/BlendBasicListener.js +3 -0
  42. package/dist/parser/blendbasic/src/grammar/BlendBasicParser.js +747 -0
  43. package/dist/src/app.js +76 -0
  44. package/dist/src/app.ts +54 -0
  45. package/dist/types/apiOperationTypes.js +13 -0
  46. package/dist/types/basicOperationTypes.js +2 -0
  47. package/dist/types/dataOperationTypes.js +2 -0
  48. package/dist/types/frontendOperationTypes.js +4 -0
  49. package/dist/types/generalTypes.js +0 -0
  50. package/dist/types/mongoOperationTypes.js +12 -0
  51. package/package.json +29 -0
  52. package/src/grammar/.antlr/ApiModuleLexer.interp +71 -0
  53. package/src/grammar/.antlr/ApiModuleLexer.java +194 -0
  54. package/src/grammar/.antlr/ApiModuleLexer.tokens +32 -0
  55. package/src/grammar/.antlr/BlendApi.interp +70 -0
  56. package/src/grammar/.antlr/BlendApi.tokens +44 -0
  57. package/src/grammar/.antlr/BlendApiLexer.interp +89 -0
  58. package/src/grammar/.antlr/BlendApiLexer.java +237 -0
  59. package/src/grammar/.antlr/BlendApiLexer.tokens +44 -0
  60. package/src/grammar/.antlr/BlendApiParser.java +767 -0
  61. package/src/grammar/.antlr/BlendBasic.interp +41 -0
  62. package/src/grammar/.antlr/BlendBasic.tokens +20 -0
  63. package/src/grammar/.antlr/BlendBasicLexer.interp +50 -0
  64. package/src/grammar/.antlr/BlendBasicLexer.java +179 -0
  65. package/src/grammar/.antlr/BlendBasicLexer.tokens +20 -0
  66. package/src/grammar/.antlr/BlendBasicParser.java +599 -0
  67. package/src/grammar/.antlr/BlendData.interp +50 -0
  68. package/src/grammar/.antlr/BlendData.tokens +29 -0
  69. package/src/grammar/.antlr/BlendDataLexer.interp +65 -0
  70. package/src/grammar/.antlr/BlendDataLexer.java +181 -0
  71. package/src/grammar/.antlr/BlendDataLexer.tokens +29 -0
  72. package/src/grammar/.antlr/BlendDataParser.java +520 -0
  73. package/src/grammar/.antlr/BlendMDP.interp +45 -0
  74. package/src/grammar/.antlr/BlendMDP.tokens +25 -0
  75. package/src/grammar/.antlr/BlendMDPLexer.interp +59 -0
  76. package/src/grammar/.antlr/BlendMDPLexer.java +178 -0
  77. package/src/grammar/.antlr/BlendMDPLexer.tokens +25 -0
  78. package/src/grammar/.antlr/BlendMDPParser.java +386 -0
  79. package/src/grammar/.antlr/BlendMongo.interp +65 -0
  80. package/src/grammar/.antlr/BlendMongo.tokens +41 -0
  81. package/src/grammar/.antlr/BlendMongoLexer.interp +83 -0
  82. package/src/grammar/.antlr/BlendMongoLexer.java +219 -0
  83. package/src/grammar/.antlr/BlendMongoLexer.tokens +41 -0
  84. package/src/grammar/.antlr/BlendMongoParser.java +669 -0
  85. package/src/grammar/.antlr/BlendRN.interp +53 -0
  86. package/src/grammar/.antlr/BlendRN.tokens +31 -0
  87. package/src/grammar/.antlr/BlendRNLexer.interp +71 -0
  88. package/src/grammar/.antlr/BlendRNLexer.java +202 -0
  89. package/src/grammar/.antlr/BlendRNLexer.tokens +31 -0
  90. package/src/grammar/.antlr/BlendRNParser.java +542 -0
  91. package/src/grammar/.antlr/BlendReact.interp +49 -0
  92. package/src/grammar/.antlr/BlendReact.tokens +28 -0
  93. package/src/grammar/.antlr/BlendReactLexer.interp +65 -0
  94. package/src/grammar/.antlr/BlendReactLexer.java +188 -0
  95. package/src/grammar/.antlr/BlendReactLexer.tokens +28 -0
  96. package/src/grammar/.antlr/BlendReactParser.java +530 -0
  97. package/src/grammar/BlendApi.g4 +26 -0
  98. package/src/grammar/BlendBasic.g4 +16 -0
  99. package/src/grammar/BlendData.g4 +24 -0
  100. package/src/grammar/BlendMDP.g4 +12 -0
  101. package/src/grammar/BlendMongo.g4 +24 -0
  102. package/src/grammar/BlendRN.g4 +18 -0
  103. package/src/grammar/BlendReact.g4 +16 -0
  104. package/src/helper/BasicHelper.ts +35 -0
  105. package/src/helper/CommonHelper.ts +5 -0
  106. package/src/helper/DataHelper.ts +268 -0
  107. package/src/helper/ExpressHelper.ts +807 -0
  108. package/src/helper/FrontEndApiHelper.ts +526 -0
  109. package/src/helper/FrontEndReactApiHelper.ts +532 -0
  110. package/src/helper/MongoHelper.ts +165 -0
  111. package/src/helper/RNHelper.ts +651 -0
  112. package/src/helper/ReactHelper.ts +597 -0
  113. package/src/helper/SectionHelper.ts +154 -0
  114. package/src/helper/fileHelper.ts +111 -0
  115. package/src/helper/grammarHelper/BlendApiGrammarHelper.ts +45 -0
  116. package/src/helper/grammarHelper/BlendBasicGrammarHelper.ts +101 -0
  117. package/src/helper/grammarHelper/BlendDataGrammarHelper.ts +49 -0
  118. package/src/helper/grammarHelper/BlendMDPGrammarHelper.ts +33 -0
  119. package/src/helper/grammarHelper/BlendMongoGrammarHelper.ts +50 -0
  120. package/src/helper/grammarHelper/BlendRNGrammarHelper.ts +65 -0
  121. package/src/helper/grammarHelper/BlendReactGrammarHelper.ts +65 -0
  122. package/src/helper/grammarHelper/GrammarErrorHelper.ts +13 -0
  123. package/src/index.ts +168 -0
  124. package/src/parser/blendApi/src/grammar/BlendApi.interp +70 -0
  125. package/src/parser/blendApi/src/grammar/BlendApi.tokens +44 -0
  126. package/src/parser/blendApi/src/grammar/BlendApiLexer.interp +89 -0
  127. package/src/parser/blendApi/src/grammar/BlendApiLexer.tokens +44 -0
  128. package/src/parser/blendApi/src/grammar/BlendApiLexer.ts +193 -0
  129. package/src/parser/blendApi/src/grammar/BlendApiListener.ts +145 -0
  130. package/src/parser/blendApi/src/grammar/BlendApiParser.ts +968 -0
  131. package/src/parser/blendData/src/grammar/BlendData.interp +50 -0
  132. package/src/parser/blendData/src/grammar/BlendData.tokens +29 -0
  133. package/src/parser/blendData/src/grammar/BlendDataLexer.interp +65 -0
  134. package/src/parser/blendData/src/grammar/BlendDataLexer.tokens +29 -0
  135. package/src/parser/blendData/src/grammar/BlendDataLexer.ts +146 -0
  136. package/src/parser/blendData/src/grammar/BlendDataListener.ts +97 -0
  137. package/src/parser/blendData/src/grammar/BlendDataParser.ts +641 -0
  138. package/src/parser/blendMDP/src/grammar/BlendMDP.interp +45 -0
  139. package/src/parser/blendMDP/src/grammar/BlendMDP.tokens +25 -0
  140. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.interp +59 -0
  141. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.tokens +25 -0
  142. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.ts +143 -0
  143. package/src/parser/blendMDP/src/grammar/BlendMDPListener.ts +85 -0
  144. package/src/parser/blendMDP/src/grammar/BlendMDPParser.ts +483 -0
  145. package/src/parser/blendMongo/src/grammar/BlendMongo.interp +65 -0
  146. package/src/parser/blendMongo/src/grammar/BlendMongo.tokens +41 -0
  147. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.interp +83 -0
  148. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.tokens +41 -0
  149. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.ts +179 -0
  150. package/src/parser/blendMongo/src/grammar/BlendMongoListener.ts +133 -0
  151. package/src/parser/blendMongo/src/grammar/BlendMongoParser.ts +849 -0
  152. package/src/parser/blendRN/src/grammar/BlendRN.interp +53 -0
  153. package/src/parser/blendRN/src/grammar/BlendRN.tokens +31 -0
  154. package/src/parser/blendRN/src/grammar/BlendRNLexer.interp +71 -0
  155. package/src/parser/blendRN/src/grammar/BlendRNLexer.tokens +31 -0
  156. package/src/parser/blendRN/src/grammar/BlendRNLexer.ts +164 -0
  157. package/src/parser/blendRN/src/grammar/BlendRNListener.ts +85 -0
  158. package/src/parser/blendRN/src/grammar/BlendRNParser.ts +659 -0
  159. package/src/parser/blendReact/src/grammar/BlendReact.interp +49 -0
  160. package/src/parser/blendReact/src/grammar/BlendReact.tokens +28 -0
  161. package/src/parser/blendReact/src/grammar/BlendReactLexer.interp +65 -0
  162. package/src/parser/blendReact/src/grammar/BlendReactLexer.tokens +28 -0
  163. package/src/parser/blendReact/src/grammar/BlendReactLexer.ts +151 -0
  164. package/src/parser/blendReact/src/grammar/BlendReactListener.ts +85 -0
  165. package/src/parser/blendReact/src/grammar/BlendReactParser.ts +646 -0
  166. package/src/parser/blendbasic/src/grammar/BlendBasic.interp +41 -0
  167. package/src/parser/blendbasic/src/grammar/BlendBasic.tokens +20 -0
  168. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.interp +50 -0
  169. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.tokens +20 -0
  170. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.ts +139 -0
  171. package/src/parser/blendbasic/src/grammar/BlendBasicListener.ts +109 -0
  172. package/src/parser/blendbasic/src/grammar/BlendBasicParser.ts +747 -0
  173. package/src/types/apiOperationTypes.ts +43 -0
  174. package/src/types/basicOperationTypes.ts +15 -0
  175. package/src/types/dataOperationTypes.ts +20 -0
  176. package/src/types/frontendOperationTypes.ts +92 -0
  177. package/src/types/generalTypes.ts +0 -0
  178. package/src/types/mongoOperationTypes.ts +36 -0
  179. package/template/.env.dev +1 -0
  180. package/template/package.json +36 -0
  181. package/template/src/app.js +76 -0
  182. package/template/src/app.ts +54 -0
  183. package/template/src/config/app.config.js +0 -0
  184. package/template/src/config/app.config.ts +0 -0
  185. package/template/src/config/database.config.js +6 -0
  186. package/template/src/config/database.config.ts +4 -0
  187. package/template/src/data/interfaces.js +2 -0
  188. package/template/src/data/interfaces.ts +23 -0
  189. package/template/src/middlewares/auth.js +22 -0
  190. package/template/src/middlewares/auth.ts +21 -0
  191. package/template/src/models/Database.js +10 -0
  192. package/template/src/models/Database.ts +8 -0
  193. package/template/src/models/User/Permission.model.js +13 -0
  194. package/template/src/models/User/Permission.model.ts +14 -0
  195. package/template/src/models/User/Role.model.js +13 -0
  196. package/template/src/models/User/Role.model.ts +14 -0
  197. package/template/src/models/User/User.model.js +17 -0
  198. package/template/src/models/User/User.model.ts +18 -0
  199. package/template/src/routes/User.routes.js +47 -0
  200. package/template/src/routes/User.routes.ts +41 -0
  201. package/template/src/routes/common/common.routes.config.js +14 -0
  202. package/template/src/routes/common/common.routes.config.ts +15 -0
  203. package/template/src/services/User/User.service.js +75 -0
  204. package/template/src/services/User/User.service.ts +68 -0
  205. package/template/src/services/User/api.data.js +72 -0
  206. package/template/src/services/User/api.data.ts +79 -0
  207. package/template/src/services/User/api.interface.js +3 -0
  208. package/template/src/services/User/api.interface.ts +10 -0
  209. package/template/tsconfig.json +10 -0
  210. package/tsconfig.json +13 -0
@@ -0,0 +1,43 @@
1
+ export type IApiSpec = {
2
+ name: string;
3
+ type: string;
4
+ input: any;
5
+ output: any;
6
+ authenticated?: boolean;
7
+ directOutput?: IApiDataField;
8
+ };
9
+
10
+ export type IApiMainSection = {
11
+ name: string;
12
+ expressSectionList: IExpressSection[];
13
+ };
14
+
15
+ export type IExpressSection = {
16
+ name: string;
17
+ apiSectionList: IApiSection[];
18
+ includedDataModuleList: string[];
19
+ };
20
+
21
+ export type IApiSection = {
22
+ name: string,
23
+ apiList: IApiSpec[]
24
+ }
25
+
26
+ export interface IApiDataField {
27
+ name?: string,
28
+ type?: string,
29
+ required?: boolean
30
+ }
31
+
32
+
33
+
34
+ // export type IApiModule = {
35
+ // name: string;
36
+ // apiList: IApiSpec[];
37
+ // }
38
+
39
+ export enum ApiType {
40
+ Get="GET",
41
+ Post="POST",
42
+ Put="PUT"
43
+ }
@@ -0,0 +1,15 @@
1
+ export type IBasicSection = {
2
+ name: string;
3
+ dataModuleList: string[];
4
+ expressModuleList: { name: string; includedDataModuleList: string[] }[];
5
+ rnModuleList?: {name: string}[];
6
+ reactModuleList?: {name: string}[];
7
+ mongoModuleList?: {name: string}[];
8
+ };
9
+
10
+ export type IBasicProject = {
11
+ name: string;
12
+ description: string;
13
+ createdAt: string;
14
+ sectionList: IBasicSection[];
15
+ };
@@ -0,0 +1,20 @@
1
+ export interface IDataSection {
2
+ name: string,
3
+ sectionDataList: IDataModule[]
4
+ }
5
+
6
+ export interface IDataModule {
7
+ name: string,
8
+ dataList: IData[]
9
+ }
10
+
11
+ export interface IData {
12
+ name: string,
13
+ fields: IDataField[]
14
+ }
15
+
16
+ export interface IDataField {
17
+ name: string,
18
+ type: string,
19
+ required?: boolean
20
+ }
@@ -0,0 +1,92 @@
1
+ export interface IFrontEndScreen{
2
+ name: string;
3
+ path: string;
4
+ parentLayout?: string;
5
+ };
6
+
7
+ export interface IRNLayout {
8
+ name: string;
9
+ route: string;
10
+ type?: string;
11
+ element?: any;
12
+ children?: Array<{
13
+ element?: string;
14
+ name: string;
15
+ route: string;
16
+ type?: string;
17
+ children?: IRNLayout["children"];
18
+ parentLayout?:string;
19
+ }>;
20
+ };
21
+ export interface IRNScreen{
22
+ name: string,
23
+ path: string
24
+ }
25
+
26
+ export interface IRNComponent{
27
+ name: string,
28
+ path: string
29
+ }
30
+ export interface IRNModule {
31
+ componentList: IRNComponent[],
32
+ screenList: IRNScreen[],
33
+ layout: IRNLayout[],
34
+ name: string,
35
+ }
36
+
37
+
38
+ export interface IRNSection {
39
+ name: string,
40
+ rnModuleList: IRNModule[];
41
+ }
42
+ export interface SpecJSON {
43
+ screenList: IFrontEndScreen[];
44
+ layout: IRNLayout[];
45
+ }
46
+
47
+
48
+
49
+ //React
50
+
51
+
52
+ export interface IReactSection {
53
+ name: string,
54
+ reactModuleList: IReactModule[];
55
+ }
56
+
57
+ export interface IReactModule {
58
+
59
+ componentList: IReactComponent[],
60
+ screenList: IReactScreen[],
61
+ layout: IReactLayout[],
62
+ name: string,
63
+ }
64
+
65
+
66
+
67
+ export interface IReactScreen {
68
+ name:string,
69
+ path:string
70
+ }
71
+
72
+ export interface IReactComponent {
73
+ name:string,
74
+ path:string,
75
+ props?: any,
76
+ parent?: string
77
+ }
78
+
79
+
80
+ export interface IReactLayout {
81
+ name:string,
82
+ route:string,
83
+ children?: IReactLayout[],
84
+ element?: string;
85
+ // type?: string;
86
+ }
87
+
88
+ export interface IReactElement {
89
+ element: string;
90
+ route: string;
91
+ name: string;
92
+ }
File without changes
@@ -0,0 +1,36 @@
1
+
2
+
3
+ export interface IMongoSection {
4
+ name: string,
5
+ sectionDbList: IDataBase[]
6
+ }
7
+
8
+ export interface IDataBase {
9
+ dbName: string;
10
+ collectionList: ICollection[];
11
+ }
12
+
13
+ export interface ICollection {
14
+ name: string,
15
+ fields: Field[]
16
+ }
17
+
18
+
19
+ export interface Field {
20
+ name: string,
21
+ required?: boolean,
22
+ type: any,
23
+ index?: boolean,
24
+ unique?: boolean,
25
+ ref?: string
26
+ }
27
+
28
+ export enum FieldType {
29
+ String="String",
30
+ Number="Number",
31
+ Date="Date",
32
+ Object="Object",
33
+ StringArray="[String]",
34
+ Boolean="Boolean"
35
+ }
36
+
@@ -0,0 +1 @@
1
+ JWT_SECRET_KEY=vachavadhyan
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "vaishnavam",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "tsc && NODE_ENV=dev node ./dist/app.js",
8
+ "debug": "export DEBUG=* && npm run start",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "author": "Govind",
12
+ "license": "ISC",
13
+ "dependencies": {
14
+ "bcrypt": "^5.1.0",
15
+ "body-parser": "^1.20.1",
16
+ "cors": "^2.8.5",
17
+ "crypto": "^1.0.1",
18
+ "debug": "^4.3.4",
19
+ "express": "^4.18.2",
20
+ "express-jwt": "^8.4.1",
21
+ "express-winston": "^4.2.0",
22
+ "jsonwebtoken": "^9.0.0",
23
+ "mongoose": "^6.8.1",
24
+ "winston": "^3.8.2",
25
+ "dotenv": "^16.3.1"
26
+ },
27
+ "devDependencies": {
28
+ "@types/bcrypt": "^5.0.0",
29
+ "@types/cors": "^2.8.13",
30
+ "@types/debug": "^4.1.7",
31
+ "@types/express": "^4.17.15",
32
+ "source-map-support": "^0.5.21",
33
+ "tslint": "^6.1.3",
34
+ "typescript": "^4.9.4"
35
+ }
36
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const express_1 = __importDefault(require("express"));
40
+ const http = __importStar(require("http"));
41
+ const cors_1 = __importDefault(require("cors"));
42
+ const debug_1 = __importDefault(require("debug"));
43
+ const body_parser_1 = require("body-parser");
44
+ const mongoose_1 = __importDefault(require("mongoose"));
45
+ const dotenv_1 = __importDefault(require("dotenv"));
46
+ const app = (0, express_1.default)();
47
+ const port = 3000;
48
+ const routes = [];
49
+ const debugLog = (0, debug_1.default)('app');
50
+ app.use((err, req, res, next) => {
51
+ console.error(err.stack);
52
+ res.status(500).send('Something broke!');
53
+ });
54
+ app.use(express_1.default.json());
55
+ app.use((0, cors_1.default)());
56
+ app.use((0, body_parser_1.urlencoded)());
57
+ app.use((0, body_parser_1.json)());
58
+ dotenv_1.default.config({ path: `.env.${process.env.NODE_ENV}` });
59
+ mongoose_1.default.set('strictQuery', false);
60
+ const runningMessage = `Server running ats http://localhost:${port}`;
61
+ app.get('/', (req, res) => {
62
+ res.send("Hello World");
63
+ });
64
+ const server = http.createServer(app);
65
+ server.listen(port, () => {
66
+ if (process.env.MONGO_DB_URL) {
67
+ mongoose_1.default.connect(process.env.MONGO_DB_URL).then(mongoConnection => {
68
+ console.log("Succesfully connected to the data base", routes);
69
+ });
70
+ }
71
+ console.log(runningMessage);
72
+ routes.forEach((route) => {
73
+ });
74
+ // our only exception to avoiding console.log(), because we
75
+ // always want to know when the server is done starting up
76
+ });
@@ -0,0 +1,54 @@
1
+ import express from 'express';
2
+ import * as http from 'http';
3
+
4
+ import * as winston from 'winston';
5
+ import * as expressWinston from 'express-winston';
6
+ import cors from 'cors';
7
+ import debug from 'debug';
8
+
9
+ import bodyParser, {json, urlencoded} from 'body-parser';
10
+ import mongoose from 'mongoose';
11
+ import { CommonRoutesConfig } from './routes/common/common.routes.config';
12
+ import dotenv from "dotenv";
13
+
14
+ const app: express.Application = express();
15
+
16
+ const port = 3000;
17
+ const routes: Array<CommonRoutesConfig> = [];
18
+ const debugLog: debug.IDebugger = debug('app');
19
+ app.use((err: any, req:express.Request, res:express.Response, next:any) => {
20
+ console.error(err.stack)
21
+ res.status(500).send('Something broke!')
22
+ });
23
+ app.use(express.json());
24
+
25
+ app.use(cors());
26
+ app.use(urlencoded());
27
+ app.use(json());
28
+ dotenv.config({ path: `.env.${process.env.NODE_ENV}` });
29
+ mongoose.set('strictQuery', false);
30
+
31
+ const runningMessage = `Server running ats http://localhost:${port}`;
32
+ app.get('/', (req: express.Request, res: express.Response) => {
33
+
34
+ res.send("Hello World")
35
+ });
36
+
37
+
38
+ const server: http.Server = http.createServer(app);
39
+
40
+
41
+ server.listen(port, () => {
42
+ if(process.env.MONGO_DB_URL) {
43
+ mongoose.connect(process.env.MONGO_DB_URL).then(mongoConnection => {
44
+ console.log("Succesfully connected to the data base",routes)
45
+ })
46
+ }
47
+ console.log(runningMessage);
48
+ routes.forEach((route: CommonRoutesConfig) => {
49
+
50
+ });
51
+ // our only exception to avoiding console.log(), because we
52
+ // always want to know when the server is done starting up
53
+
54
+ });
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const databaseConfig = {
4
+ url: 'mongodb://127.0.0.1/vaishnavam'
5
+ };
6
+ exports.default = databaseConfig;
@@ -0,0 +1,4 @@
1
+ const databaseConfig = {
2
+ url: 'mongodb://127.0.0.1/vaishnavam'
3
+ }
4
+ export default databaseConfig;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+
2
+ export interface IUser_User {
3
+ userName: String,
4
+ emailId: String,
5
+ password: String,
6
+ mobile: String,
7
+ firstName: String,
8
+ lastName: String,
9
+
10
+ }
11
+
12
+ export interface IRole_User {
13
+ name: String,
14
+ description: String,
15
+
16
+ }
17
+
18
+ export interface IPermission_User {
19
+ name: String,
20
+ description: String,
21
+
22
+ }
23
+
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
7
+ const verifyToken = (req, res, next) => {
8
+ const token = req.body.token || req.query.token || req.headers["authorization"];
9
+ if (!token) {
10
+ return res.status(403).send("A token is required for authentication");
11
+ }
12
+ try {
13
+ const secretKey = process.env.JWT_SECRET_KEY || "";
14
+ const decoded = jsonwebtoken_1.default.verify(token, secretKey);
15
+ req.user = decoded;
16
+ }
17
+ catch (err) {
18
+ return res.status(401).send("Invalid Token");
19
+ }
20
+ return next();
21
+ };
22
+ exports.default = verifyToken;
@@ -0,0 +1,21 @@
1
+
2
+ import jwt from 'jsonwebtoken';
3
+
4
+ const verifyToken = (req: any, res: any, next: any) => {
5
+ const token =
6
+ req.body.token || req.query.token || req.headers["authorization"];
7
+
8
+ if (!token) {
9
+ return res.status(403).send("A token is required for authentication");
10
+ }
11
+ try {
12
+ const secretKey = process.env.JWT_SECRET_KEY || "";
13
+ const decoded = jwt.verify(token, secretKey);
14
+ req.user = decoded;
15
+ } catch (err) {
16
+ return res.status(401).send("Invalid Token");
17
+ }
18
+ return next();
19
+ };
20
+
21
+ export default verifyToken;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const mongoose_1 = __importDefault(require("mongoose"));
7
+ class Database {
8
+ }
9
+ Database.UserDb = mongoose_1.default.connection.useDb('user');
10
+ exports.default = Database;
@@ -0,0 +1,8 @@
1
+
2
+ import mongoose from "mongoose";
3
+
4
+ export default class Database {
5
+ static UserDb = mongoose.connection.useDb('user');
6
+
7
+ }
8
+
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Database_1 = __importDefault(require("../Database"));
7
+ const mongoose_1 = require("mongoose");
8
+ const PermissionSchema = new mongoose_1.Schema({
9
+ name: { type: String, },
10
+ description: { type: String, },
11
+ });
12
+ const Permission = Database_1.default.UserDb.model('Permission', PermissionSchema);
13
+ exports.default = Permission;
@@ -0,0 +1,14 @@
1
+
2
+ import Database from '../Database';
3
+ import { Schema, model, connect, ObjectId } from 'mongoose';
4
+
5
+ import {IPermission_User} from '../../data/interfaces';
6
+ const PermissionSchema = new Schema<IPermission_User>({
7
+ name: {type: String,},
8
+ description: {type: String,},
9
+
10
+ });
11
+
12
+ const Permission = Database.UserDb.model<IPermission_User>('Permission', PermissionSchema);
13
+
14
+ export default Permission;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Database_1 = __importDefault(require("../Database"));
7
+ const mongoose_1 = require("mongoose");
8
+ const RoleSchema = new mongoose_1.Schema({
9
+ name: { type: String, },
10
+ description: { type: String, },
11
+ });
12
+ const Role = Database_1.default.UserDb.model('Role', RoleSchema);
13
+ exports.default = Role;
@@ -0,0 +1,14 @@
1
+
2
+ import Database from '../Database';
3
+ import { Schema, model, connect, ObjectId } from 'mongoose';
4
+
5
+ import {IRole_User} from '../../data/interfaces';
6
+ const RoleSchema = new Schema<IRole_User>({
7
+ name: {type: String,},
8
+ description: {type: String,},
9
+
10
+ });
11
+
12
+ const Role = Database.UserDb.model<IRole_User>('Role', RoleSchema);
13
+
14
+ export default Role;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Database_1 = __importDefault(require("../Database"));
7
+ const mongoose_1 = require("mongoose");
8
+ const UserSchema = new mongoose_1.Schema({
9
+ userName: { type: String, },
10
+ emailId: { type: String, },
11
+ password: { type: String, },
12
+ mobile: { type: String, },
13
+ firstName: { type: String, },
14
+ lastName: { type: String, },
15
+ });
16
+ const User = Database_1.default.UserDb.model('User', UserSchema);
17
+ exports.default = User;
@@ -0,0 +1,18 @@
1
+
2
+ import Database from '../Database';
3
+ import { Schema, model, connect, ObjectId } from 'mongoose';
4
+
5
+ import {IUser_User} from '../../data/interfaces';
6
+ const UserSchema = new Schema<IUser_User>({
7
+ userName: {type: String,},
8
+ emailId: {type: String,},
9
+ password: {type: String,},
10
+ mobile: {type: String,},
11
+ firstName: {type: String,},
12
+ lastName: {type: String,},
13
+
14
+ });
15
+
16
+ const User = Database.UserDb.model<IUser_User>('User', UserSchema);
17
+
18
+ export default User;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const common_routes_config_1 = require("./common/common.routes.config");
16
+ const User_service_1 = __importDefault(require("../services/User/User.service"));
17
+ const api_data_1 = require("../services/User/api.data");
18
+ class UserRoutes extends common_routes_config_1.CommonRoutesConfig {
19
+ constructor(app) {
20
+ super(app, 'UserRoutes');
21
+ this.UserService = new User_service_1.default();
22
+ }
23
+ configureRoutes() {
24
+ this.app.route('/user/signup').post((req, res) => __awaiter(this, void 0, void 0, function* () {
25
+ const input = api_data_1.USER_SIGNUP_INPUT.fromJSON(req.body);
26
+ const defaultPreCondition = input.checkDefaultPreCondition();
27
+ if (defaultPreCondition.isValid) {
28
+ this.UserService.Signup(input, res);
29
+ }
30
+ else {
31
+ res.status(412).send(defaultPreCondition.errorBody);
32
+ }
33
+ }));
34
+ this.app.route('/user/login').post((req, res) => __awaiter(this, void 0, void 0, function* () {
35
+ const input = api_data_1.USER_LOGIN_INPUT.fromJSON(req.body);
36
+ const defaultPreCondition = input.checkDefaultPreCondition();
37
+ if (defaultPreCondition.isValid) {
38
+ this.UserService.Login(input, res);
39
+ }
40
+ else {
41
+ res.status(412).send(defaultPreCondition.errorBody);
42
+ }
43
+ }));
44
+ return this.app;
45
+ }
46
+ }
47
+ exports.default = UserRoutes;