@je-es/server 0.1.0 → 0.1.2
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.
- package/README.md +88 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,41 +3,65 @@
|
|
|
3
3
|
<br>
|
|
4
4
|
<div align="center">
|
|
5
5
|
<p>
|
|
6
|
-
<img src="./assets/img/logo.png" alt="logo" style="" height="
|
|
6
|
+
<img src="./assets/img/logo.png" alt="logo" style="" height="80" />
|
|
7
7
|
</p>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div align="center">
|
|
11
|
-
<img src="https://img.shields.io/badge/v-0.1.
|
|
11
|
+
<img src="https://img.shields.io/badge/v-0.1.2-black"/>
|
|
12
12
|
<a href="https://github.com/maysara-elshewehy">
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/je-es
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<div align="center">
|
|
18
|
-
<img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/>
|
|
19
|
-
<br>
|
|
14
|
+
<a href="https://github.com/je-es"> <img src="https://img.shields.io/badge/@-je--es-black"/> </a>
|
|
20
15
|
</div>
|
|
16
|
+
<br>
|
|
21
17
|
|
|
22
18
|
<!-- ╚═════════════════════════════════════════════════════════════════╝ -->
|
|
23
19
|
|
|
24
20
|
|
|
25
21
|
|
|
22
|
+
|
|
26
23
|
<!-- ╔══════════════════════════════ DOC ══════════════════════════════╗ -->
|
|
27
24
|
|
|
28
25
|
- ## Quick Start 🔥
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
> _**The simplest, fastest, most organized and stable way to build servers.**_
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
# install
|
|
34
|
-
space i @je-es/server
|
|
29
|
+
> _We prefer to use [`space`](https://github.com//solution-lib/space) with [`@solution-dist/server`](https://github.com/solution-dist/server) for a better experience._
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
- #### Setup
|
|
32
|
+
|
|
33
|
+
> install [`space`](https://github.com/solution-lib/space) first.
|
|
34
|
+
|
|
35
|
+
- ##### Create
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
space init <name> -t server # This will clone a ready-to-use repo and make some changes to suit your server.
|
|
39
|
+
cd <name> # Go to the project directory
|
|
40
|
+
space install # Install the dependencies
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- ##### Manage
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
space build # To build your server
|
|
47
|
+
space test # To test your server
|
|
48
|
+
space start # To start your server
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# example
|
|
53
|
+
> space start
|
|
54
|
+
|
|
55
|
+
# output
|
|
56
|
+
16:16:31 ✓ Server started at http://localhost:3000
|
|
57
|
+
16:17:25 GET / 200 4ms
|
|
58
|
+
...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<br>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
- ## Examples
|
|
41
65
|
|
|
42
66
|
- ### Basic Server
|
|
43
67
|
|
|
@@ -92,6 +116,8 @@
|
|
|
92
116
|
...
|
|
93
117
|
```
|
|
94
118
|
|
|
119
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
120
|
+
|
|
95
121
|
- ### With Database
|
|
96
122
|
|
|
97
123
|
```typescript
|
|
@@ -134,6 +160,8 @@
|
|
|
134
160
|
// Data persists in ./my_app.db file!
|
|
135
161
|
```
|
|
136
162
|
|
|
163
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
164
|
+
|
|
137
165
|
- ### With Security
|
|
138
166
|
|
|
139
167
|
```typescript
|
|
@@ -168,7 +196,7 @@
|
|
|
168
196
|
await app.start();
|
|
169
197
|
```
|
|
170
198
|
|
|
171
|
-
<
|
|
199
|
+
<br>
|
|
172
200
|
|
|
173
201
|
- ## API Reference
|
|
174
202
|
|
|
@@ -219,6 +247,8 @@
|
|
|
219
247
|
await app.start();
|
|
220
248
|
```
|
|
221
249
|
|
|
250
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
251
|
+
|
|
222
252
|
- ### Route Definition
|
|
223
253
|
|
|
224
254
|
```typescript
|
|
@@ -258,6 +288,8 @@
|
|
|
258
288
|
};
|
|
259
289
|
```
|
|
260
290
|
|
|
291
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
292
|
+
|
|
261
293
|
- ### Context API
|
|
262
294
|
|
|
263
295
|
```typescript
|
|
@@ -315,7 +347,7 @@
|
|
|
315
347
|
}
|
|
316
348
|
```
|
|
317
349
|
|
|
318
|
-
<
|
|
350
|
+
<br>
|
|
319
351
|
|
|
320
352
|
- ## Security Features
|
|
321
353
|
|
|
@@ -337,6 +369,8 @@
|
|
|
337
369
|
});
|
|
338
370
|
```
|
|
339
371
|
|
|
372
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
373
|
+
|
|
340
374
|
- ### CORS Configuration
|
|
341
375
|
|
|
342
376
|
```typescript
|
|
@@ -363,6 +397,8 @@
|
|
|
363
397
|
});
|
|
364
398
|
```
|
|
365
399
|
|
|
400
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
401
|
+
|
|
366
402
|
- ### CSRF Protection
|
|
367
403
|
|
|
368
404
|
```typescript
|
|
@@ -377,6 +413,8 @@
|
|
|
377
413
|
const isValid = security.validateCsrfToken(token, 'session-id');
|
|
378
414
|
```
|
|
379
415
|
|
|
416
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
417
|
+
|
|
380
418
|
- ### Input Sanitization
|
|
381
419
|
|
|
382
420
|
```typescript
|
|
@@ -393,7 +431,7 @@
|
|
|
393
431
|
// Output: ''; DROP TABLE users--
|
|
394
432
|
```
|
|
395
433
|
|
|
396
|
-
<
|
|
434
|
+
<br>
|
|
397
435
|
|
|
398
436
|
- ## Database Support
|
|
399
437
|
|
|
@@ -412,6 +450,8 @@
|
|
|
412
450
|
// Access in routes via c.db
|
|
413
451
|
```
|
|
414
452
|
|
|
453
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
454
|
+
|
|
415
455
|
- ### Multiple Databases
|
|
416
456
|
|
|
417
457
|
```typescript
|
|
@@ -450,6 +490,8 @@
|
|
|
450
490
|
});
|
|
451
491
|
```
|
|
452
492
|
|
|
493
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
494
|
+
|
|
453
495
|
- ### Schema Definition
|
|
454
496
|
|
|
455
497
|
```typescript
|
|
@@ -494,6 +536,8 @@
|
|
|
494
536
|
});
|
|
495
537
|
```
|
|
496
538
|
|
|
539
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
540
|
+
|
|
497
541
|
- ### Database Operations
|
|
498
542
|
|
|
499
543
|
```typescript
|
|
@@ -583,6 +627,8 @@
|
|
|
583
627
|
});
|
|
584
628
|
```
|
|
585
629
|
|
|
630
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
631
|
+
|
|
586
632
|
- ### Query Builder
|
|
587
633
|
|
|
588
634
|
```typescript
|
|
@@ -671,6 +717,8 @@
|
|
|
671
717
|
});
|
|
672
718
|
```
|
|
673
719
|
|
|
720
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
721
|
+
|
|
674
722
|
- ### Transactions
|
|
675
723
|
|
|
676
724
|
```typescript
|
|
@@ -711,6 +759,8 @@
|
|
|
711
759
|
});
|
|
712
760
|
```
|
|
713
761
|
|
|
762
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
763
|
+
|
|
714
764
|
- ### Raw SQL
|
|
715
765
|
|
|
716
766
|
```typescript
|
|
@@ -762,7 +812,7 @@
|
|
|
762
812
|
});
|
|
763
813
|
```
|
|
764
814
|
|
|
765
|
-
<
|
|
815
|
+
<br>
|
|
766
816
|
|
|
767
817
|
- ## Advanced Features
|
|
768
818
|
|
|
@@ -792,6 +842,8 @@
|
|
|
792
842
|
};
|
|
793
843
|
```
|
|
794
844
|
|
|
845
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
846
|
+
|
|
795
847
|
- ### Cookie Management
|
|
796
848
|
|
|
797
849
|
```typescript
|
|
@@ -838,6 +890,8 @@
|
|
|
838
890
|
});
|
|
839
891
|
```
|
|
840
892
|
|
|
893
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
894
|
+
|
|
841
895
|
- ### Dynamic Routing
|
|
842
896
|
|
|
843
897
|
```typescript
|
|
@@ -873,6 +927,8 @@
|
|
|
873
927
|
});
|
|
874
928
|
```
|
|
875
929
|
|
|
930
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
931
|
+
|
|
876
932
|
- ### Health Checks
|
|
877
933
|
|
|
878
934
|
```typescript
|
|
@@ -899,6 +955,8 @@
|
|
|
899
955
|
}
|
|
900
956
|
```
|
|
901
957
|
|
|
958
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
959
|
+
|
|
902
960
|
- ### Graceful Shutdown
|
|
903
961
|
|
|
904
962
|
```typescript
|
|
@@ -924,6 +982,8 @@
|
|
|
924
982
|
});
|
|
925
983
|
```
|
|
926
984
|
|
|
985
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
986
|
+
|
|
927
987
|
- ### Dynamic Routes
|
|
928
988
|
|
|
929
989
|
```typescript
|
|
@@ -951,6 +1011,8 @@
|
|
|
951
1011
|
console.log(routes);
|
|
952
1012
|
```
|
|
953
1013
|
|
|
1014
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
1015
|
+
|
|
954
1016
|
- ### Request Timeout
|
|
955
1017
|
|
|
956
1018
|
```typescript
|
|
@@ -970,6 +1032,8 @@
|
|
|
970
1032
|
});
|
|
971
1033
|
```
|
|
972
1034
|
|
|
1035
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
1036
|
+
|
|
973
1037
|
- ### Custom Error Handling
|
|
974
1038
|
|
|
975
1039
|
```typescript
|
|
@@ -1010,11 +1074,9 @@
|
|
|
1010
1074
|
<!-- ╔══════════════════════════════ END ══════════════════════════════╗ -->
|
|
1011
1075
|
|
|
1012
1076
|
<br>
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
</div>
|
|
1017
|
-
<br>
|
|
1077
|
+
|
|
1078
|
+
---
|
|
1079
|
+
|
|
1018
1080
|
<div align="center">
|
|
1019
1081
|
<a href="https://github.com/solution-lib/space"><img src="https://img.shields.io/badge/by-Space-black"/></a>
|
|
1020
1082
|
</div>
|