You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,5 @@ For example: it has not written about `const obj = new Object();` because we jus
68
68
## Architecture guide
69
69
70
70
The software architecture (SA) is one of the most important parts of the developing. It helps developers easy to integrate into the ocean of the codes.
71
-
The architecture describes a set of aspects and decisions of the software.
72
-
This implies taking into consideration all kinds of requirements (performance, security, etc.), the organization of the system, how the system parts communicate with each other.\
73
-
You should think about the long term, building software that is both functional right now and can support any sort of growth and change. \
71
+
The architecture describes a set of aspects and decisions of the software. \
Copy file name to clipboardExpand all lines: guides/architecture-guide.md
+60-14Lines changed: 60 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,10 +36,31 @@ We'll speak about every small part of the code in detail even if it seems too pr
36
36
1.[yarn.lock](#yarnlock)
37
37
38
38
39
+
## Foreword
40
+
41
+
I'd like to start from naming of files or directories.
42
+
1. All files or directories are started with lowercase. E.g. `configs`, `index.js`
43
+
2. Complex words are written with dash. E.g. `admin-panel-ctrl`
44
+
3. All directories are written with plural form. Exception is `dal` (data access layer), but in that dir again all subdirectories are in plural form.
45
+
46
+
In our software structure we use barrel export. A barrel is a way to rollup exports from several modules into a single convenient module. The barrel itself is a module file that re-exports selected exports of other modules. \
47
+
Putting those words in action, is creating an index.js file to reexport everything the end user will need:
48
+
```
49
+
const objects = require('./objects');
50
+
const strings = require('./strings');
51
+
const general = require('./general');
52
+
53
+
module.exports = {
54
+
objects,
55
+
strings,
56
+
general,
57
+
};
58
+
```
59
+
Express framework v4.x doesn't use async/await functions, so we asyncified all we need (it is shown in `controllers` section).
39
60
40
61
## yarn.lock
41
62
42
-
If you use `npm` as your package manager, than equivalent to yarn.lock file is `package-lock.json` file.\
63
+
If you use `npm` as your package manager, then equivalent to yarn.lock file is `package-lock.json` file.\
43
64
Many developers think that yarn.lock file is unnecessary. ATTENTION ! :loudspeaker: Don't delete or add this file to `.gitignore`. It can bring really serious problems to your application.\
44
65
In order to get consistent installs across machines, Yarn needs more information than the dependencies you configure in your package.json. Yarn needs to store exactly which versions of each dependency has installed.
45
66
To do this Yarn uses a [yarn.lock](https://classic.yarnpkg.com/en/docs/yarn-lock/) file in the root of your project.
@@ -49,16 +70,16 @@ We'll speak about every small part of the code in detail even if it seems too pr
49
70
## README
50
71
51
72
README.md file is an optional file. Absence of it doesn't leave a negative influence on your code. Although I strongly recommended you to write and complete your application 'introduction' file. It helps developers and visitors easily to understand what your app/repo is about.
52
-
If you don't know how start to fill your README, or if you get lazy to do it, start from scratch and write only the most important things at first (say greetings to your visitors, how your app should be used, or how they can run it). When you already have some written some topics then you'll continue fill it again and again ).
73
+
If you don't know how start filling your README, start from a scratch and write only the most important things at first (say greetings to your visitors, how your app should be used, or how they can run it). When you already have some written some topics then you'll continue fill it again and again ).
53
74
54
75
**[⬆ back to top](#table-of-contents)**
55
76
56
77
## package.json
57
78
58
79
As we all know the `package.json` is node.js app's backbone. \
59
-
You should take care of it and keep clean. My advice is regularly check your all dependencies, dev-, peer- dependencies and so on. It's a good idea to keep updated your all modules, but you must be careful, your modules' version changes can entail many problems related with your system, node.js and their incompatibility. \
60
-
When you usually install or remove a module, your package manager (yarn or npm) shows you a brief info about your modules (packages) states and statuses. They can be deprecated or can have vulnerabilities, warnings. You can follow yarn/npm advices and fixed them don't forgetting about the incompatibility. \
61
-
You should regularly remove unused unnecessary modules from your app. There are many useful tools for it, e.g. [depcheck](https://github.com/depcheck/depcheck). You can install it globally and use for your all apps. \
80
+
You should take care of it and keep clean. My advice is regularly check all of your dependencies, dev-, peer- dependencies and so on. It's a good idea to keep updated your all modules, but you must be careful, your modules' version changes can result in many problems related with your system, node.js and their incompatibility. \
81
+
When you usually install or remove a module, your package manager (yarn or npm) shows you a brief info about your modules (packages) states and statuses. They can be deprecated or can have vulnerabilities, warnings. You can follow yarn/npm advices and fix them without forgetting about the incompatibilities. \
82
+
You should regularly remove unused, unnecessary modules from your app. There are many useful tools for it, e.g. [depcheck](https://github.com/depcheck/depcheck). You can install it globally and use for your all apps. \
62
83
In package.json you can add scripts for running, debugging, testing and so on.
63
84
64
85
**[⬆ back to top](#table-of-contents)**
@@ -77,14 +98,14 @@ We'll speak about every small part of the code in detail even if it seems too pr
77
98
78
99
## jenkinsfile
79
100
80
-
This file is use for auto deployment. It's an optional file. I'll add more info about this file after a while.
101
+
This file is used for auto deployment. It's an optional file. I'll add more info about this file later.
81
102
82
103
**[⬆ back to top](#table-of-contents)**
83
104
84
105
## index
85
106
86
-
This is the entry point of your app. This is a cell from which is originated your application civilization. For running it, Node.js runs `index.js` at first. It initializes all classes and methods\
87
-
Here you should write code few as possible. It should be a very simple and clean. Usually you create the server with a port and give connection to your database. You can also add here your routers and middlewares.
107
+
This is the entry point of your app. This is a cell from which your application's civilization is originated . For running it, Node.js runs `index.js` at first. It initializes all classes and methods\
108
+
Here you should write as less code as possible. It should be a very simple and clean. Usually you create the server with a port and give connection to your database. You can also add here your routers and middlewares.
88
109
89
110
**[⬆ back to top](#table-of-contents)**
90
111
@@ -101,7 +122,7 @@ We'll speak about every small part of the code in detail even if it seems too pr
101
122
102
123
## .eslintrc
103
124
104
-
ESLint is a ESLint is a static code analysis tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs.
125
+
ESLint is a static code analysis tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs.
105
126
This is its config file. Our `.eslintrc` and style guide are being written according best practices of JS, Node.js (e.g. the great software development school of Airbnb), and, of course, our best modest experience :innocent: It was tested line by line. For more info please take a look our style guide.
106
127
107
128
**[⬆ back to top](#table-of-contents)**
@@ -130,7 +151,7 @@ We'll speak about every small part of the code in detail even if it seems too pr
130
151
## views
131
152
132
153
This directory is used to save template engines. A template engine enables you to use static template files in your application. At runtime, the template engine replaces variables in a template file with actual values, and transforms the template into an HTML file sent to the client. This approach makes it easier to design an HTML page.\
133
-
You may not to have view engine. We decided to add it just for example. We use `EJS`. You can install another you wish. After it you need to set 2 things: the view engine and the directory for it (by default express use `views` dir). In our case we set them in entry `index.js` file.
154
+
You may not have view engine. We decided to add it just for example. We use `EJS`. You can use any engine you prefer. After it you need to set 2 things: the view engine and the directory for it (by default express use `views` dir). In our case we set them in entry `index.js` file.
134
155
135
156
**[⬆ back to top](#table-of-contents)**
136
157
@@ -143,14 +164,29 @@ We'll speak about every small part of the code in detail even if it seems too pr
143
164
**[⬆ back to top](#table-of-contents)**
144
165
145
166
## services
146
-
Services are conceptual parts of app architecture.
At first, we run indexRouter's use method (which is a middleware too) which accepts combined middlewares group, then the router accepts controllers group by file name order and at last it accepts ErrorHandler middleware. \
189
+
It should be noted that ErrorHandler accepts 4 arguments: `err, req, res, next`, but the last one is not used. If we don't put the 4th argument, Express will not understand the 1st argument as `err`, it will understand as `req`.
154
190
155
191
**[⬆ back to top](#table-of-contents)**
156
192
@@ -161,16 +197,22 @@ Services are conceptual parts of app architecture.
161
197
162
198
## helpers
163
199
200
+
This is the place, where you can save reusable methods for different and recurring situations. Why? It's easy to reach to different data, when you already know where is it. Then it's comfortable use from one place and when you change some values it will change everywhere which has the reference to it.
201
+
We separate helpers by data types' methods or for specific cases.
164
202
165
203
**[⬆ back to top](#table-of-contents)**
166
204
167
205
## guides
168
206
169
-
207
+
This directory is intended to store guidelines related the project. In our case we have 2 of them.
208
+
1. style guide (about syntax, semantics, manuscript of the code)
209
+
1. architecture guide (current file)
210
+
170
211
**[⬆ back to top](#table-of-contents)**
171
212
172
213
## files
173
214
215
+
The `files` directory stores files related your template engine (.css, .js) or your media files and documents.
174
216
175
217
**[⬆ back to top](#table-of-contents)**
176
218
@@ -181,12 +223,16 @@ Services are conceptual parts of app architecture.
0 commit comments