Skip to content

Commit e967fb3

Browse files
committed
Update impress
1 parent ab0e01c commit e967fb3

File tree

224 files changed

+1914
-4500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+1914
-4500
lines changed

impress-simple/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

impress-simple/.eslintrc.json

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": 2020
10+
},
11+
"globals": {
12+
"BigInt": true,
13+
"Metacom": true
14+
},
15+
"rules": {
16+
"indent": [
17+
"error",
18+
2
19+
],
20+
"linebreak-style": [
21+
"error",
22+
"unix"
23+
],
24+
"quotes": [
25+
"error",
26+
"single"
27+
],
28+
"semi": [
29+
"error",
30+
"always"
31+
],
32+
"no-loop-func": [
33+
"error"
34+
],
35+
"block-spacing": [
36+
"error",
37+
"always"
38+
],
39+
"camelcase": [
40+
"error"
41+
],
42+
"eqeqeq": [
43+
"error",
44+
"always"
45+
],
46+
"strict": [
47+
"error",
48+
"global"
49+
],
50+
"brace-style": [
51+
"error",
52+
"1tbs",
53+
{
54+
"allowSingleLine": true
55+
}
56+
],
57+
"comma-style": [
58+
"error",
59+
"last"
60+
],
61+
"comma-spacing": [
62+
"error",
63+
{
64+
"before": false,
65+
"after": true
66+
}
67+
],
68+
"eol-last": [
69+
"error"
70+
],
71+
"func-call-spacing": [
72+
"error",
73+
"never"
74+
],
75+
"key-spacing": [
76+
"error",
77+
{
78+
"beforeColon": false,
79+
"afterColon": true,
80+
"mode": "minimum"
81+
}
82+
],
83+
"keyword-spacing": [
84+
"error",
85+
{
86+
"before": true,
87+
"after": true,
88+
"overrides": {
89+
"function": {
90+
"after": false
91+
}
92+
}
93+
}
94+
],
95+
"max-len": [
96+
"error",
97+
{
98+
"code": 80,
99+
"ignoreUrls": true
100+
}
101+
],
102+
"max-nested-callbacks": [
103+
"error",
104+
{
105+
"max": 7
106+
}
107+
],
108+
"new-cap": [
109+
"error",
110+
{
111+
"newIsCap": true,
112+
"capIsNew": false,
113+
"properties": true
114+
}
115+
],
116+
"new-parens": [
117+
"error"
118+
],
119+
"no-lonely-if": [
120+
"error"
121+
],
122+
"no-trailing-spaces": [
123+
"error"
124+
],
125+
"no-unneeded-ternary": [
126+
"error"
127+
],
128+
"no-whitespace-before-property": [
129+
"error"
130+
],
131+
"object-curly-spacing": [
132+
"error",
133+
"always"
134+
],
135+
"operator-assignment": [
136+
"error",
137+
"always"
138+
],
139+
"operator-linebreak": [
140+
"error",
141+
"after"
142+
],
143+
"semi-spacing": [
144+
"error",
145+
{
146+
"before": false,
147+
"after": true
148+
}
149+
],
150+
"space-before-blocks": [
151+
"error",
152+
"always"
153+
],
154+
"space-before-function-paren": [
155+
"error",
156+
{
157+
"anonymous": "never",
158+
"named": "never",
159+
"asyncArrow": "always"
160+
}
161+
],
162+
"space-in-parens": [
163+
"error",
164+
"never"
165+
],
166+
"space-infix-ops": [
167+
"error"
168+
],
169+
"space-unary-ops": [
170+
"error",
171+
{
172+
"words": true,
173+
"nonwords": false,
174+
"overrides": {
175+
"typeof": false
176+
}
177+
}
178+
],
179+
"no-unreachable": [
180+
"error"
181+
],
182+
"no-global-assign": [
183+
"error"
184+
],
185+
"no-self-compare": [
186+
"error"
187+
],
188+
"no-unmodified-loop-condition": [
189+
"error"
190+
],
191+
"no-constant-condition": [
192+
"error",
193+
{
194+
"checkLoops": false
195+
}
196+
],
197+
"no-console": [
198+
"off"
199+
],
200+
"no-useless-concat": [
201+
"error"
202+
],
203+
"no-useless-escape": [
204+
"error"
205+
],
206+
"no-shadow-restricted-names": [
207+
"error"
208+
],
209+
"no-use-before-define": [
210+
"error",
211+
{
212+
"functions": false
213+
}
214+
],
215+
"arrow-parens": [
216+
"error",
217+
"as-needed"
218+
],
219+
"arrow-body-style": [
220+
"error",
221+
"as-needed"
222+
],
223+
"arrow-spacing": [
224+
"error"
225+
],
226+
"no-confusing-arrow": [
227+
"error",
228+
{
229+
"allowParens": true
230+
}
231+
],
232+
"no-useless-computed-key": [
233+
"error"
234+
],
235+
"no-useless-rename": [
236+
"error"
237+
],
238+
"no-var": [
239+
"error"
240+
],
241+
"object-shorthand": [
242+
"error",
243+
"always"
244+
],
245+
"prefer-arrow-callback": [
246+
"error"
247+
],
248+
"prefer-const": [
249+
"error"
250+
],
251+
"prefer-numeric-literals": [
252+
"error"
253+
],
254+
"prefer-rest-params": [
255+
"error"
256+
],
257+
"prefer-spread": [
258+
"error"
259+
],
260+
"rest-spread-spacing": [
261+
"error",
262+
"never"
263+
],
264+
"template-curly-spacing": [
265+
"error",
266+
"never"
267+
]
268+
}
269+
}

impress-simple/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
/log/
3+
*.log
4+
*.pem
5+
*.done
6+
.DS_Store

impress-simple/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Metarhia Starter Kit for Node.js Server
2+
3+
## Concept
4+
5+
This is a logical continuation of
6+
[Node.js Starter Kit](https://github.com/HowProgrammingWorks/NodejsStarterKit)
7+
from [How Programming Works](https://github.com/HowProgrammingWorks) software
8+
development course moving all system code to dependencies, namely using
9+
[Metarhia technology stack](https://github.com/metarhia).
10+
11+
You can begin development from this starter kit but having in mind future
12+
production deployment and further moving application to
13+
[Metaserverless cloud](https://github.com/Metaserverless) based on Metarhia
14+
technology stack and Node.js.
15+
16+
The purpose of this starter kit is to show best practices for Metarhia and
17+
Metaserverless, to give structure and architecture example, to illustrate
18+
simplicity and efficiency of mentioned technologies.
19+
20+
All parts of this implementation are optimized for reliability, scalability,
21+
performance and security. So if you need readability and want to study code,
22+
let's start with
23+
[Node.js Starter Kit](https://github.com/HowProgrammingWorks/NodejsStarterKit).
24+
25+
## Feature list
26+
27+
- Serve API with routing, HTTP(S), WS(S)
28+
- Server code live reload with file system watch
29+
- Graceful shutdown and application reload
30+
- Minimum code size and dependencies
31+
- Code sandboxing for security and context isolation
32+
- Multi-threading for CPU utilization and isolation
33+
- Serve multiple ports in threads
34+
- Serve static files with memory cache
35+
- Application configuration
36+
- Simple logger and redirection from console
37+
- Database access layer (Postgresql)
38+
- Client persistent sessions
39+
- Unit-tests and API tests example
40+
- Request queue timeout and size
41+
- API parallel execution concurrency
42+
- API method execution timeout
43+
- Load balancing for scaling
44+
- Prototype polution prevention
45+
- Better code isolation
46+
47+
## Usage
48+
49+
- You need node.js v12.5.0 or later (v14 prefered)
50+
- Fork and clone this repository (optionally subscribe to repo changes)
51+
- Run `npm i` to install dependencies and generate RSA certificate
52+
- Remove unneeded dependencies if your project doesn't require them
53+
- Add your license to `LICENSE` file but don't remove starter kit license
54+
- Start your project modifying this starter kit
55+
- Ask questions in https://t.me/nodeua and post issues on
56+
[github](https://github.com/HowProgrammingWorks/NodejsStarterKit/issues)
57+
- Run project: `node server.js` and stop with Ctrl+C
58+
59+
## License
60+
61+
Copyright (c) 2020 Metarhia contributors.
62+
This starter kit is [MIT licensed](./LICENSE).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOptions": {
3+
"sourceType": "module"
4+
}
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"globals": {
3+
"application": "readonly",
4+
"context": "readonly",
5+
"api": "readonly"
6+
}
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
async ({ login, password, fullName }) => {
2+
const hash = await application.security.hashPassword(password);
3+
await application.auth.registerUser(login, hash, fullName);
4+
return { result: 'success' };
5+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
({
2+
access: 'public',
3+
method: async ({ login, password }) => {
4+
const user = await application.auth.getUser(login);
5+
const hash = user ? user.password : undefined;
6+
const valid = await application.security.validatePassword(password, hash);
7+
if (!user || !valid) throw new Error('Incorrect login or password');
8+
console.log(`Logged user: ${login}`);
9+
return { result: 'success', userId: user.id };
10+
}
11+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
async () => {
2+
const status = context.token ? 'logged' : 'not logged';
3+
return { result: status };
4+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"rules": {
3+
"strict": [
4+
"error",
5+
"never"
6+
]
7+
},
8+
"globals": {
9+
"application": "readonly",
10+
"context": "readonly",
11+
"api": "readonly"
12+
}
13+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy