-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1204 lines (1146 loc) · 43.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2022-06-16 Thu 16:23 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Simple server for static content</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="John" />
<meta name="description" content="Self hosted netlify clone"
/>
<link rel="stylesheet" type="text/css" href="worg.css" />
<script type="text/javascript">
// @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.add("code-highlighted");
target.classList.add("code-highlighted");
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.remove("code-highlighted");
target.classList.remove("code-highlighted");
}
}
/*]]>*///-->
// @license-end
</script>
</head>
<body>
<div id="content">
<h1 class="title">Simple server for static content</h1>
<p>
Serve your site and sell courses with self hosted server.
</p>
<p>
<b>sserver</b> is simple headless server for hosting courses and associated blog/static content with minimal overhead.
</p>
<p>
It provides https out of the box so you don't have to deal with installing/managing certificates.
It syncs the content automatically from github so you don't have to upload your content to server. It also supports premium content with simple configuration file without affecting your content workflow for e.g. if you are using static site generator like hugo you can hide the premium content from public by specifying it in config file. It has stripe integration so you can sell your premium content. It has user management built in for adding/authenticating users.
It also has admin api so you can monitor orders/users of your site.
</p>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgff10ec5">1. Features</a></li>
<li><a href="#orgb48e275">2. Usage</a>
<ul>
<li><a href="#org91e01fe">2.1. github repository</a></li>
<li><a href="#org81fcc9d">2.2. Folder in github repository with config file</a></li>
<li><a href="#org49c3a09">2.3. Branch of github repository repository with config file (like gh-pages)</a></li>
<li><a href="#orgc9069a9">2.4. github repository with domain name</a></li>
<li><a href="#org706fa77">2.5. local files</a></li>
</ul>
</li>
<li><a href="#org211f02f">3. Operational details</a>
<ul>
<li><a href="#org2500148">3.1. Description of files created by <b>sserver</b></a></li>
<li><a href="#org1a51632">3.2. Configuration</a></li>
<li><a href="#orga46c60a">3.3. Default Values</a></li>
</ul>
</li>
<li><a href="#org3832274">4. API</a>
<ul>
<li><a href="#orga654ae9">4.1. API Endpoints</a></li>
</ul>
</li>
<li><a href="#org3f506ca">5. FAQ</a>
<ul>
<li><a href="#org731c923">5.1. Is this opensource?</a></li>
<li><a href="#orgbb39229">5.2. What is the current status?</a></li>
<li><a href="#orgb5daa82">5.3. Why was this created?</a></li>
<li><a href="#orga957c61">5.4. Can i use it for saas it already has user mangement and billing?</a></li>
<li><a href="#org98465fc">5.5. What are the use cases?</a></li>
<li><a href="#org2c8df24">5.6. What are the supported OS?</a></li>
<li><a href="#orgb2600b1">5.7. Where can i request feature? suggestions for improvement?</a></li>
<li><a href="#orgf1cedbf">5.8. What does it costs?</a></li>
</ul>
</li>
<li><a href="#org9d7f69c">6. TODO</a></li>
</ul>
</div>
</div>
<div id="outline-container-orgff10ec5" class="outline-2">
<h2 id="orgff10ec5"><span class="section-number-2">1</span> Features</h2>
<div class="outline-text-2" id="text-1">
<ul class="org-ul">
<li class="on"><code>[X]</code> Serve static content from github/local directory</li>
<li class="on"><code>[X]</code> Auto https support via letsencrypt</li>
<li class="on"><code>[X]</code> Auto sync content from github repository</li>
<li class="on"><code>[X]</code> Support for gated content/course</li>
<li class="on"><code>[X]</code> Stripe integration for selling course</li>
<li class="on"><code>[X]</code> User registration and authentication</li>
<li class="on"><code>[X]</code> Admin apis to get overall view of the store</li>
</ul>
</div>
</div>
<div id="outline-container-orgb48e275" class="outline-2">
<h2 id="orgb48e275"><span class="section-number-2">2</span> Usage</h2>
<div class="outline-text-2" id="text-2">
<p>
Here are some examples of how it can be used, please make sure to set SS_<> environment variables before trying them out e.g.
</p>
<pre class="example">
export SS_GITHUB_TOKEN=<github_token>
export SS_STRIPE_TOKEN=<stripe_token>
export SS_SMTP_FROM=<email_id>
export SS_SMTP_USER=<smtp_username>
export SS_SMTP_PWD=<smtp_password>
export SS_SMTP_HOST=<smtp_host_address>
export SS_SMTP_PORT=<smtp_port>
export SS_ADMIN_EMAIL=<admin_email>
export SS_ADMIN_PWD=<admin_password_for_sserver>
</pre>
</div>
<div id="outline-container-org91e01fe" class="outline-3">
<h3 id="org91e01fe"><span class="section-number-3">2.1</span> github repository</h3>
<div class="outline-text-3" id="text-2-1">
<pre class="example">
./sserver -repo "https://github.com/newbeelearn/sserver.git"
</pre>
<p>
Repository should have index.html and ssconfig.toml in its root directory. If hugo/jekyll etc. like static site generator is used, repository should contain generated site.(It would have index.html in root by default)
</p>
</div>
</div>
<div id="outline-container-org81fcc9d" class="outline-3">
<h3 id="org81fcc9d"><span class="section-number-3">2.2</span> Folder in github repository with config file</h3>
<div class="outline-text-3" id="text-2-2">
<pre class="example">
./sserver -repo "https://github.com/newbeelearn/sserver.git?folder=public"
</pre>
<p>
Repository should have index.html in folder from where you want to serve the content, typically it is public if hugo/jekyll etc. static site generators are used. It should have ssconfig.toml in the root directory
</p>
</div>
</div>
<div id="outline-container-org49c3a09" class="outline-3">
<h3 id="org49c3a09"><span class="section-number-3">2.3</span> Branch of github repository repository with config file (like gh-pages)</h3>
<div class="outline-text-3" id="text-2-3">
<pre class="example">
./sserver -repo "https://github.com/newbeelearn/sserver.git?ref=test-config"
</pre>
<p>
Branch should have index.html and ssconfig.toml in its root directory. If hugo/jekyll etc. like static site generator is used, branch should contain generated site.(It would have index.html in root by default)
</p>
</div>
</div>
<div id="outline-container-orgc9069a9" class="outline-3">
<h3 id="orgc9069a9"><span class="section-number-3">2.4</span> github repository with domain name</h3>
<div class="outline-text-3" id="text-2-4">
<div class="org-src-container">
<pre class="src src-shell">./sserver -repo <span style="color: #8b2252;">"https://github.com/newbeelearn/sserver.git?domain=example.com"</span>
</pre>
</div>
<p>
Repository should have index.html and ssconfig.toml in its root directory
Access to the domain from which site is served
<b>sserver</b> should have permissions to bind to 443 port, this can be done with following command
</p>
<pre class="example">
sudo setcap 'cap_net_bind_service=+ep' sserver
</pre>
</div>
</div>
<div id="outline-container-org706fa77" class="outline-3">
<h3 id="org706fa77"><span class="section-number-3">2.5</span> local files</h3>
<div class="outline-text-3" id="text-2-5">
<pre class="example">
./sserver -repo "file:///workspace/projects/newbeelearn.com/sserver"
</pre>
<p>
Repository should have index.html and ssconfig.toml in its root directory.
All the options i.e. folder/domain etc. can be specified in case of local files as well
</p>
<p>
Sample ssconfig.toml can be found below
</p>
<pre class="example" id="orgf8a01c4">
# specify the site
[site]
# period to check for new content
syncinterval = "@every 12h"
# product/course details
[[site.prod]]
name = "course1"
# path from root, this will be accessible to users who have bought the course
path = "courses/course1"
# can be draft/active, buying functionality will be enabled when status is active
status = "active"
# unique identifier for the course
sku = "prod-course-1"
# price in cents
price = 10000
# currency
currency = "USD"
</pre>
</div>
</div>
</div>
<div id="outline-container-org211f02f" class="outline-2">
<h2 id="org211f02f"><span class="section-number-2">3</span> Operational details</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-org2500148" class="outline-3">
<h3 id="org2500148"><span class="section-number-3">3.1</span> Description of files created by <b>sserver</b></h3>
<div class="outline-text-3" id="text-3-1">
<p>
<b>sserver</b> creates "wwwss" directory from where it is run
</p>
<div class="org-src-container">
<pre class="src src-shell">drwxrwxr-x 2 test test 4096 Nov 30 17:04 a
drwxrwxr-x 8 test test 4096 Nov 30 17:04 b
drwxrwxr-x 2 test test 4096 Nov 30 17:04 certs
drwxrwxr-x 2 test test 4096 Nov 30 17:04 logs
-rw-rw-r-- 1 test test 527483 Nov 30 17:04 tmp.zip
-rw-rw-r-- 1 test test 49152 Nov 30 17:05 ssapp.db
</pre>
</div>
<ul class="org-ul">
<li>If https is used key and certificates can be found in certs</li>
<li>Server access logs are inside logs folder</li>
<li>Database of users/permissions and course details are in sqlite file ssapp.db</li>
<li>tmp.zip is temporary site downloaded from github in zip format and is overwritten on every sync</li>
<li>a/b folders is from where site is served. Actual folder keeps on alternating between the two.</li>
</ul>
</div>
</div>
<div id="outline-container-org1a51632" class="outline-3">
<h3 id="org1a51632"><span class="section-number-3">3.2</span> Configuration</h3>
<div class="outline-text-3" id="text-3-2">
<p>
Configuration file is used to specify the products/courses that you want to sell
as well as some server parameters like how often the site should be synced etc.
</p>
</div>
<div id="outline-container-orga88c5d0" class="outline-4">
<h4 id="orga88c5d0"><span class="section-number-4">3.2.1</span> Server parameters are</h4>
<div class="outline-text-4" id="text-3-2-1">
<ul class="org-ul">
<li><b>syncinterval</b> specifies auto syncing period for content default is 12 hours</li>
<li><b>login</b> specifies login/sign-in page to be redirected to if user tries to access protected content if not specified it redirects
to home page of the site</li>
<li><b>postlogin</b> specifies page user should be redirected to in case of successful login if not specified it returns json response
which needs to be processed from client side</li>
<li><b>postsignup</b> specifies page user should be redirected to after completing the signup if not specified it returns json response
which needs to be interpreted on client side</li>
</ul>
</div>
</div>
<div id="outline-container-org6a49094" class="outline-4">
<h4 id="org6a49094"><span class="section-number-4">3.2.2</span> Product/Course parameters are</h4>
<div class="outline-text-4" id="text-3-2-2">
<ul class="org-ul">
<li><b>name</b> is the name of the product course</li>
<li><b>path</b> is the path of course content relative to the root directory. This will not be accessible without
registering and buying the course.</li>
<li><b>status</b> can be either draft or active. Buying functionality becomes available only when product status is active</li>
<li><b>sku</b> this should be unique identifier for the course/product. It creates stripe product with the identifier specified in
sku. If you already have a product in stripe use its id as sku otherwise duplicate products will be created.</li>
<li><b>price</b> is in cents for USD, i.e. 10.58USD course should set the price as 1058. For other currencies please check stripe documentation
as the software currently assumes stripe convention for currency and price is followed.</li>
<li><b>currency</b> should follow stripe convention</li>
</ul>
</div>
</div>
<div id="outline-container-org59f4d52" class="outline-4">
<h4 id="org59f4d52"><span class="section-number-4">3.2.3</span> Sample config file</h4>
<div class="outline-text-4" id="text-3-2-3">
<p>
Sample ssconfig.toml file is shown below
</p>
<pre class="example" id="org68ebec7">
#specify the site
[site]
#period to check for new content default is 12 hours
syncinterval = "@every 12h"
[[site.prod]]
name = "course1"
path = "courses/course1"
status = "active"
sku = "prod-course-1"
price = 10000
currency = "USD"
</pre>
</div>
</div>
</div>
<div id="outline-container-orga46c60a" class="outline-3">
<h3 id="orga46c60a"><span class="section-number-3">3.3</span> Default Values</h3>
<div class="outline-text-3" id="text-3-3">
<ul class="org-ul">
<li>If domain is not specified content will be served from port 54545 else port 443</li>
<li>If local file is specified content will be served from that directory else
it would be served from wwwss folder which will autosync content from github repository</li>
<li>If syncinterval is specified it will sync content from github/check content from local file
with syncinterval duration else it will sync/check for new content every 12 hours</li>
<li>Syncing between stripe events i.e. refund done through stripe site etc. are synced every
6 hours</li>
<li>If SMTP details are not specified, mail sending functionality on registration/reset etc. will be disabled</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org3832274" class="outline-2">
<h2 id="org3832274"><span class="section-number-2">4</span> API</h2>
<div class="outline-text-2" id="text-4">
<p>
All api endpoints are relative to the domain used for serving the content
i.e. if domain is example.com and api is <code>/api/v1/product/list</code> request would be <a href="https://example.com/api/v1/product/list">https://example.com/api/v1/product/list</a>
</p>
<p>
Role hierarchy is like this admin > user > guest
Any api accessible to guest is also accessible to user and any api accessible to user is also accessible to admin
For accessing user/admin api's session cookie obtained after logging in must be supplied with each request
in practice this will be taken care by the browser
</p>
</div>
<div id="outline-container-orga654ae9" class="outline-3">
<h3 id="orga654ae9"><span class="section-number-3">4.1</span> API Endpoints</h3>
<div class="outline-text-3" id="text-4-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Description</th>
<th scope="col" class="org-left">Request</th>
<th scope="col" class="org-left">Role</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><a href="#org5435a0a">Register User</a></td>
<td class="org-left">POST <code>/api/v1/user/register</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#org652be6d">Login User</a></td>
<td class="org-left">POST <code>/api/v1/user/login</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#org9aa383a">Logout user</a></td>
<td class="org-left">GET <code>/api/v1/user/logout</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#org962094f">Verify user</a></td>
<td class="org-left">GET <code>/api/v1/user/verify/:id</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#orgd53698d">Reset user password</a></td>
<td class="org-left">POST <code>/api/v1/user/reset</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#orgfb81347">Get product list</a></td>
<td class="org-left">GET <code>/api/v1/product/list</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#org54a75a0">Create order</a></td>
<td class="org-left">POST <code>/api/v1/order/id</code></td>
<td class="org-left">guest</td>
</tr>
<tr>
<td class="org-left"><a href="#org0ab0524">Modify order</a></td>
<td class="org-left">PUT <code>/api/v1/order/id</code></td>
<td class="org-left">user</td>
</tr>
<tr>
<td class="org-left"><a href="#org0d62395">Checkout order</a></td>
<td class="org-left">POST <code>/api/v1/order/checkout</code></td>
<td class="org-left">user</td>
</tr>
<tr>
<td class="org-left"><a href="#org256f534">Get order by order id</a></td>
<td class="org-left">GET <code>/api/v1/order/id/:id</code></td>
<td class="org-left">user</td>
</tr>
<tr>
<td class="org-left"><a href="#org426e0d1">Get all orders by user</a></td>
<td class="org-left">GET <code>/api/v1/order/id/list</code></td>
<td class="org-left">user</td>
</tr>
<tr>
<td class="org-left"><a href="#org0e8d849">Change user password</a></td>
<td class="org-left">POST <code>/api/v1/user/changepwd</code></td>
<td class="org-left">user</td>
</tr>
<tr>
<td class="org-left"><a href="#org76738fe">Get all orders</a></td>
<td class="org-left">GET <code>/api/v1/order/list</code></td>
<td class="org-left">admin</td>
</tr>
<tr>
<td class="org-left"><a href="#org606a5f3">Get all users</a></td>
<td class="org-left">GET <code>/api/v1/user/list</code></td>
<td class="org-left">admin</td>
</tr>
</tbody>
</table>
</div>
<div id="outline-container-org5435a0a" class="outline-4">
<h4 id="org5435a0a"><span class="section-number-4">4.1.1</span> Register user</h4>
<div class="outline-text-4" id="text-4-1-1">
<p>
Register new user with email and password. Sends mail to the email used to register with verification
code if SMTP server configuration is set.
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/register'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/x-www-form-urlencoded'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">'email=stripe%40newbeelearn.com&password=test&confirm-password=test&remember=on'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="orgde499d4">
{"status":"success"}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org652be6d" class="outline-4">
<h4 id="org652be6d"><span class="section-number-4">4.1.2</span> Login user</h4>
<div class="outline-text-4" id="text-4-1-2">
<p>
Login user with email and password. Returns json if "postlogin" field is not set in config file
otherwise redirects to the page specified in "postlogin"
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/login'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/x-www-form-urlencoded'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">'email=admin%40example.com&password=admin'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org8764973">
{
"data": {
"user_id": "1",
"username": ""
},
"msg": "user found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org9aa383a" class="outline-4">
<h4 id="org9aa383a"><span class="section-number-4">4.1.3</span> Logout user</h4>
<div class="outline-text-4" id="text-4-1-3">
<p>
Logs out logged in user and redirects to homepage
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/logout'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=9e8b22a3-15ac-442f-bf65-15c37dbfc889; max-age=300; path=/; secure; SameSite=Lax'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="orgd6dcc8d">
<!doctype html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org962094f" class="outline-4">
<h4 id="org962094f"><span class="section-number-4">4.1.4</span> Verify user</h4>
<div class="outline-text-4" id="text-4-1-4">
<p>
Verifies the email of registered user by sending url if domain is set or code that should be appended after the verify api
if domain is not set
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/verify/cafj5grn0gpog1j3a0m0'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org2de0481">
{"status":"success"}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-orgd53698d" class="outline-4">
<h4 id="orgd53698d"><span class="section-number-4">4.1.5</span> Reset user password</h4>
<div class="outline-text-4" id="text-4-1-5">
<p>
Resets the user password and sends the new temporary code for login. User needs to use this code
on next login and change the password
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/reset'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/x-www-form-urlencoded'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">'email=stripe%40newbeelearn.com'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org14d2b89">
{
"data": null,
"msg": "password reset successful",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-orgfb81347" class="outline-4">
<h4 id="orgfb81347"><span class="section-number-4">4.1.6</span> Get product list</h4>
<div class="outline-text-4" id="text-4-1-6">
<p>
Get all the products listed for sale on website. Takes "limit" and "offset" as queries.
If query is not set default values of limit is set to 10 and offset to 0
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/product/list?limit=1&offset=0'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="orgc409674">
{
"data": [
{
"prd_id": 1,
"prd_name": "course1",
"sku": "prod-course-1",
"permalink": "users/list/",
"price": 10000,
"currency": "USD",
"period": 365,
"status": "active"
}
],
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org54a75a0" class="outline-4">
<h4 id="org54a75a0"><span class="section-number-4">4.1.7</span> Create order</h4>
<div class="outline-text-4" id="text-4-1-7">
<p>
Creates new order with products listed in <code>"line_item"</code> field. Request should be valid json.
Actual <code>order_id/user_id</code> etc. fields are populated by the server any dummy value can be passed.
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/id'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=cad8439e-dcc4-475e-94fc-12b75f85bb20; max-age=300; path=/; secure; SameSite=Lax'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">' {</span>
<span style="color: #8b2252;"> "order_id": 1,</span>
<span style="color: #8b2252;"> "user_id": 3,</span>
<span style="color: #8b2252;"> "currency": "USD",</span>
<span style="color: #8b2252;"> "line_items": [</span>
<span style="color: #8b2252;"> {</span>
<span style="color: #8b2252;"> "sku": "prod-course-1"</span>
<span style="color: #8b2252;"> },</span>
<span style="color: #8b2252;"> {</span>
<span style="color: #8b2252;"> "sku": "prod-course-3"</span>
<span style="color: #8b2252;"> }</span>
<span style="color: #8b2252;"> ]</span>
<span style="color: #8b2252;">}'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org5b2760a">
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 11000,
"line_items": [
{
"line_id": 1,
"order_id": 1,
"prd_id": 1,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 10000,
"enabled": true,
"sku": "prod-course-1"
},
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
},
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org0ab0524" class="outline-4">
<h4 id="org0ab0524"><span class="section-number-4">4.1.8</span> Modify order</h4>
<div class="outline-text-4" id="text-4-1-8">
<p>
Modifies existing order by adding/deleting products in <code>line_item</code> field. User must be logged in to
modify the order and order should be in active state. Use the previous response of create order or get order
to add/delete products
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/id'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=cad8439e-dcc4-475e-94fc-12b75f85bb20; max-age=300; path=/; secure; SameSite=Lax'</span> <span style="color: #8b2252;">\</span>
-X PUT <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">' {</span>
<span style="color: #8b2252;"> "order_id": 1,</span>
<span style="color: #8b2252;"> "user_id": 3,</span>
<span style="color: #8b2252;"> "created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "status": "active",</span>
<span style="color: #8b2252;"> "currency": "USD",</span>
<span style="color: #8b2252;"> "order_number": "cafjktbn0gpp5hq3dt4g",</span>
<span style="color: #8b2252;"> "grand_total": 11000,</span>
<span style="color: #8b2252;"> "line_items": [</span>
<span style="color: #8b2252;"> {</span>
<span style="color: #8b2252;"> "line_id": 2,</span>
<span style="color: #8b2252;"> "order_id": 1,</span>
<span style="color: #8b2252;"> "prd_id": 2,</span>
<span style="color: #8b2252;"> "created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "grand": 1000,</span>
<span style="color: #8b2252;"> "enabled": true,</span>
<span style="color: #8b2252;"> "sku": "prod-course-3"</span>
<span style="color: #8b2252;"> }</span>
<span style="color: #8b2252;"> ]</span>
<span style="color: #8b2252;"> }'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org3ece6f2">
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
},
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org0d62395" class="outline-4">
<h4 id="org0d62395"><span class="section-number-4">4.1.9</span> Checkout order</h4>
<div class="outline-text-4" id="text-4-1-9">
<p>
Gets stripe url for payment of order created by create order api.
Use the response from create order/modify order/get order api to send the request.
Do not modify the response in this request it will result in failure.
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/checkout'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=2f1be070-7256-4e84-a4ef-c14754cabcdb; max-age=300; path=/; secure; SameSite=Lax'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">' {</span>
<span style="color: #8b2252;"> "order_id": 1,</span>
<span style="color: #8b2252;"> "user_id": 3,</span>
<span style="color: #8b2252;"> "created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "status": "active",</span>
<span style="color: #8b2252;"> "currency": "USD",</span>
<span style="color: #8b2252;"> "order_number": "cafjktbn0gpp5hq3dt4g",</span>
<span style="color: #8b2252;"> "grand_total": 11000,</span>
<span style="color: #8b2252;"> "line_items": [</span>
<span style="color: #8b2252;"> {</span>
<span style="color: #8b2252;"> "line_id": 2,</span>
<span style="color: #8b2252;"> "order_id": 1,</span>
<span style="color: #8b2252;"> "prd_id": 2,</span>
<span style="color: #8b2252;"> "created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",</span>
<span style="color: #8b2252;"> "grand": 1000,</span>
<span style="color: #8b2252;"> "enabled": true,</span>
<span style="color: #8b2252;"> "sku": "prod-course-3"</span>
<span style="color: #8b2252;"> }</span>
<span style="color: #8b2252;"> ]</span>
<span style="color: #8b2252;"> }'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org603aece">
{
"data": {
"url": "https://checkout.stripe.com/pay/cs_test_a17D2l74NsKMv29YJ1c5rSBPx7BGSsNAsObGAsOanEJqyFNXKEYDLji4BZ#fidkdWxOYHwnPyd1blpxYHZxWjA0TlVKPHNMaW9vYEd1YmhdUWQ3UUJqSEpMYTMza11ObGAyXDFPcXA8bz1yY1VicVZVdDN8c1NkaUZEazxIQWdjM04wdz1DTmF3PXxHaVE9bTVuZz1pUWw3NTUybHZLZldgaicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl"
},
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org256f534" class="outline-4">
<h4 id="org256f534"><span class="section-number-4">4.1.10</span> Get order by order number</h4>
<div class="outline-text-4" id="text-4-1-10">
<p>
Get order details by order number
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/id/cafjktbn0gpp5hq3dt4g'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="orgf0ff62f">
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"grand": 1000,
"enabled": true
}
]
},
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org426e0d1" class="outline-4">
<h4 id="org426e0d1"><span class="section-number-4">4.1.11</span> Get all orders by user</h4>
<div class="outline-text-4" id="text-4-1-11">
<p>
Get all orders by user. Takes limit and offset as query parameters default values are 10 and 0 respectively
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/id/list?limit=1&offset=0'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org6da069b">
{
"data": [
{
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000
}
],
"msg": "Order found",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org0e8d849" class="outline-4">
<h4 id="org0e8d849"><span class="section-number-4">4.1.12</span> Change user password</h4>
<div class="outline-text-4" id="text-4-1-12">
<p>
Change user password. User must be logged in to make this request
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/user/changepwd'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/x-www-form-urlencoded'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'</span> <span style="color: #8b2252;">\</span>
-X POST <span style="color: #8b2252;">\</span>
--data-raw <span style="color: #8b2252;">'oldpassword=cafjjjbn0gpp5hq3dt40&password=test123'</span>
</pre>
</div></li>
<li><p>
Example Response
</p>
<pre class="example" id="org0905a63">
{
"data": null,
"msg": "password change successful",
"status": "success"
}
</pre></li>
</ul>
</div>
</div>
<div id="outline-container-org76738fe" class="outline-4">
<h4 id="org76738fe"><span class="section-number-4">4.1.13</span> Get all orders</h4>
<div class="outline-text-4" id="text-4-1-13">
<p>
Get all orders created in the store. Takes limit and offset as query parameters default values are 10 and 0 respectively
Available to admin users only.
Get all orders
</p>
<ul class="org-ul">
<li><p>
Example Request
</p>
<div class="org-src-container">
<pre class="src src-shell">curl <span style="color: #8b2252;">'http://localhost:54545/api/v1/order/list?limit=1&offset=0'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Content-Type: application/json; charset=utf-8'</span> <span style="color: #8b2252;">\</span>
-H <span style="color: #8b2252;">'Cookie: session_id=e4ecd3a4-b8be-493e-a33d-518ab11c65e8; max-age=300; path=/; secure; SameSite=Lax'</span>