isite 2024.12.2 → 2024.12.4
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/apps/client-side/site_files/css/effect.css +2 -1
- package/apps/client-side/site_files/css/form.css +4 -0
- package/apps/client-side/site_files/css/layout.css +6 -1
- package/apps/client-side/site_files/js/ref.js +0 -2
- package/apps/client-side/site_files/js/ref.min.js +0 -1
- package/lib/routing.js +662 -623
- package/lib/security.js +8 -4
- package/lib/session.js +21 -3
- package/lib/sessions.js +12 -11
- package/lib/wsClient.js +1 -1
- package/package.json +1 -1
package/lib/routing.js
CHANGED
|
@@ -291,7 +291,7 @@ module.exports = function init(____0) {
|
|
|
291
291
|
callback =
|
|
292
292
|
callback ||
|
|
293
293
|
function (req, res) {
|
|
294
|
-
|
|
294
|
+
____0.log('No CallBack set For : ', r);
|
|
295
295
|
res.end();
|
|
296
296
|
};
|
|
297
297
|
if (typeof r === 'string') {
|
|
@@ -595,9 +595,14 @@ module.exports = function init(____0) {
|
|
|
595
595
|
};
|
|
596
596
|
|
|
597
597
|
_0xrrxo.handleRoute = async function (req, res, route) {
|
|
598
|
+
if (route.language) {
|
|
599
|
+
req.session.language = { ...route.language };
|
|
600
|
+
}
|
|
601
|
+
|
|
598
602
|
if (route.lang) {
|
|
599
|
-
req.session.language =
|
|
603
|
+
req.session.language.id = route.lang;
|
|
600
604
|
}
|
|
605
|
+
|
|
601
606
|
if (!route.public) {
|
|
602
607
|
if (!route.name.like(____0.strings[15]) && route.require.features.length > 0) {
|
|
603
608
|
let ok = !0;
|
|
@@ -663,716 +668,748 @@ module.exports = function init(____0) {
|
|
|
663
668
|
}
|
|
664
669
|
}
|
|
665
670
|
}
|
|
671
|
+
|
|
666
672
|
route.callback(req, res);
|
|
667
673
|
};
|
|
668
674
|
|
|
669
|
-
|
|
670
|
-
req
|
|
671
|
-
|
|
672
|
-
req.referer = req.headers['referer'] || '';
|
|
673
|
-
req.domain = '';
|
|
674
|
-
req.subDomain = '';
|
|
675
|
-
req.obj = {};
|
|
676
|
-
req.query = {};
|
|
677
|
-
req.queryRaw = {};
|
|
678
|
-
req.data = req.body = {};
|
|
679
|
-
req.bodyRaw = '';
|
|
680
|
-
req.params = {};
|
|
681
|
-
req.paramsRaw = {};
|
|
682
|
-
req.features = [];
|
|
683
|
-
|
|
684
|
-
res.setTimeout(1000 * ____0.options.responseTimeout, () => {
|
|
685
|
-
if (req.url.like('*api*')) {
|
|
686
|
-
return res.json({
|
|
687
|
-
done: false,
|
|
688
|
-
error: ____0.strings[19],
|
|
689
|
-
});
|
|
690
|
-
} else {
|
|
691
|
-
res.end(503);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
675
|
+
____0.validateServerRequest = async function (req, res, next) {
|
|
676
|
+
next(req, res);
|
|
677
|
+
};
|
|
694
678
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
679
|
+
____0.validateRequest = async function (req, res, next) {
|
|
680
|
+
next(req, res);
|
|
681
|
+
};
|
|
682
|
+
____0.validateRoute = async function (req, res, next) {
|
|
683
|
+
next(req, res);
|
|
684
|
+
};
|
|
698
685
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
686
|
+
____0.validateSession = async function (req, res, next) {
|
|
687
|
+
next(req, res);
|
|
688
|
+
};
|
|
702
689
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
690
|
+
_0xrrxo.handleServer = async function (req, res) {
|
|
691
|
+
____0.validateServerRequest(req, res, (req, res) => {
|
|
692
|
+
req.host = req.headers['host'] || '';
|
|
693
|
+
req.origin = req.headers['origin'] || req.host;
|
|
694
|
+
req.referer = req.headers['referer'] || '';
|
|
695
|
+
req.domain = '';
|
|
696
|
+
req.subDomain = '';
|
|
697
|
+
req.obj = {};
|
|
698
|
+
req.query = {};
|
|
699
|
+
req.queryRaw = {};
|
|
700
|
+
req.data = req.body = {};
|
|
701
|
+
req.bodyRaw = '';
|
|
702
|
+
req.params = {};
|
|
703
|
+
req.paramsRaw = {};
|
|
704
|
+
req.features = [];
|
|
705
|
+
|
|
706
|
+
res.setTimeout(1000 * ____0.options.responseTimeout, () => {
|
|
707
|
+
if (req.url.like('*api*')) {
|
|
708
|
+
return res.json({
|
|
709
|
+
done: false,
|
|
710
|
+
error: ____0.strings[19],
|
|
711
|
+
});
|
|
712
|
+
} else {
|
|
713
|
+
res.end(503);
|
|
707
714
|
}
|
|
708
715
|
});
|
|
709
|
-
};
|
|
710
716
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
id: null,
|
|
714
|
-
email: null,
|
|
715
|
-
date: new Date(),
|
|
716
|
-
ip: null,
|
|
717
|
+
req.addFeature = function (name) {
|
|
718
|
+
req.features.push(name);
|
|
717
719
|
};
|
|
718
720
|
|
|
719
|
-
|
|
720
|
-
req.
|
|
721
|
-
|
|
722
|
-
userFinger.email = req.session.user.email;
|
|
723
|
-
userFinger.name = req.session.user.profile.name || userFinger.email;
|
|
724
|
-
userFinger.name_ar = req.session.user.profile.name_ar || userFinger.email;
|
|
725
|
-
userFinger.name_en = req.session.user.profile.name_en || userFinger.email;
|
|
726
|
-
userFinger.ip = req.ip;
|
|
727
|
-
} else {
|
|
728
|
-
}
|
|
721
|
+
req.hasFeature = function (name) {
|
|
722
|
+
return req.features.some((f) => f.like(name));
|
|
723
|
+
};
|
|
729
724
|
|
|
730
|
-
|
|
731
|
-
|
|
725
|
+
req.removeFeature = function (name) {
|
|
726
|
+
req.features.forEach((f, i) => {
|
|
727
|
+
if (f.like(name)) {
|
|
728
|
+
req.features.splice(i, 1);
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
732
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
733
|
+
req.getUserFinger = function () {
|
|
734
|
+
let userFinger = {
|
|
735
|
+
id: null,
|
|
736
|
+
email: null,
|
|
737
|
+
date: new Date(),
|
|
738
|
+
ip: null,
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
if (req && req.session && req.session.user) {
|
|
742
|
+
req.session.user.profile = req.session.user.profile || {};
|
|
743
|
+
userFinger.id = req.session.user.id;
|
|
744
|
+
userFinger.email = req.session.user.email;
|
|
745
|
+
userFinger.name = req.session.user.profile.name || userFinger.email;
|
|
746
|
+
userFinger.name_ar = req.session.user.profile.name_ar || userFinger.email;
|
|
747
|
+
userFinger.name_en = req.session.user.profile.name_en || userFinger.email;
|
|
748
|
+
userFinger.ip = req.ip;
|
|
749
|
+
} else {
|
|
740
750
|
}
|
|
741
|
-
}
|
|
742
|
-
return w[req.session.language.id] || name;
|
|
743
|
-
};
|
|
744
751
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
req.acceptEncoding = req.headers[____0.strings[5]] ? req.headers[____0.strings[5]] : '';
|
|
748
|
-
res.ip = req.ip = req.headers[____0.strings[6]] ? req.headers[____0.strings[6]] : req.socket.remoteAddress?.replace('::ffff:', '');
|
|
749
|
-
if (req.ip == '::1') {
|
|
750
|
-
req.ip = '127.0.0.1';
|
|
751
|
-
}
|
|
752
|
-
res.ip2 = req.ip2 = req.socket.localAddress.replace('::ffff:', '');
|
|
753
|
-
res.port = req.port = req.socket.remotePort;
|
|
754
|
-
res.port2 = req.port2 = req.socket.localPort;
|
|
755
|
-
res.cookies = res.cookie = req.cookies = req.cookie = ____0.cookie(req, res, ____0);
|
|
752
|
+
return userFinger;
|
|
753
|
+
};
|
|
756
754
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
755
|
+
req.word = function (name) {
|
|
756
|
+
let w = ____0.word(name);
|
|
757
|
+
if (!w.hostList) {
|
|
758
|
+
return w[req.session.language.id] || name;
|
|
759
|
+
} else {
|
|
760
|
+
if ((w2 = w.hostList.find((h) => req.host.like(h.name)))) {
|
|
761
|
+
return w2[req.session.language.id] || name;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return w[req.session.language.id] || name;
|
|
765
|
+
};
|
|
760
766
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
767
|
+
res.code = null;
|
|
768
|
+
req.socket.remoteAddress = req.socket.remoteAddress || '';
|
|
769
|
+
req.acceptEncoding = req.headers[____0.strings[5]] ? req.headers[____0.strings[5]] : '';
|
|
770
|
+
res.ip = req.ip = req.headers[____0.strings[6]] ? req.headers[____0.strings[6]] : req.socket.remoteAddress?.replace('::ffff:', '');
|
|
771
|
+
if (req.ip == '::1') {
|
|
772
|
+
req.ip = '127.0.0.1';
|
|
764
773
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
774
|
+
res.ip2 = req.ip2 = req.socket.localAddress.replace('::ffff:', '');
|
|
775
|
+
res.port = req.port = req.socket.remotePort;
|
|
776
|
+
res.port2 = req.port2 = req.socket.localPort;
|
|
777
|
+
res.cookies = res.cookie = req.cookies = req.cookie = ____0.cookie(req, res, ____0);
|
|
778
|
+
|
|
779
|
+
req.urlRaw = req.url;
|
|
780
|
+
req.urlParserRaw = ____0.url.parse(req.urlRaw, !0);
|
|
781
|
+
req.urlParser = ____0.url.parse(req.urlRaw.toLowerCase(), !0);
|
|
782
|
+
|
|
783
|
+
res.set = (a, b, c) => {
|
|
784
|
+
if (res.writeHeadEnabled === !1 || res.finished === !0 || res.headersSent) {
|
|
785
|
+
return res;
|
|
786
|
+
}
|
|
787
|
+
if (typeof b == 'string') {
|
|
788
|
+
res.headers = res.headers || [];
|
|
789
|
+
res.headers[a] = b.toLowerCase();
|
|
790
|
+
}
|
|
777
791
|
|
|
778
|
-
|
|
779
|
-
if (res.writeHeadEnabled === !1 || res.finished === !0) {
|
|
792
|
+
res.setHeader(a, b, c);
|
|
780
793
|
return res;
|
|
781
|
-
}
|
|
782
|
-
res.cookie.write();
|
|
783
|
-
res.writeHeadEnabled = !1;
|
|
784
|
-
res.writeHead0(code, obj);
|
|
785
|
-
return res;
|
|
786
|
-
};
|
|
794
|
+
};
|
|
787
795
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
setTimeout(function () {
|
|
793
|
-
res.end(...data);
|
|
794
|
-
}, time);
|
|
795
|
-
};
|
|
796
|
+
res.delete = res.remove = res.removeHeader;
|
|
797
|
+
res.writeHead0 = res.writeHead;
|
|
798
|
+
res.writeHeadEnabled = !0;
|
|
796
799
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
800
|
+
res.writeHead = (code, obj) => {
|
|
801
|
+
if (res.writeHeadEnabled === !1 || res.finished === !0) {
|
|
802
|
+
return res;
|
|
803
|
+
}
|
|
804
|
+
res.cookie.write();
|
|
805
|
+
res.writeHeadEnabled = !1;
|
|
806
|
+
res.writeHead0(code, obj);
|
|
807
|
+
return res;
|
|
808
|
+
};
|
|
802
809
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
} else {
|
|
807
|
-
if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
|
|
808
|
-
res.set(____0.strings[7], 'text/html');
|
|
810
|
+
res.ending = (time, ...data) => {
|
|
811
|
+
if (!time) {
|
|
812
|
+
time = 0;
|
|
809
813
|
}
|
|
814
|
+
setTimeout(function () {
|
|
815
|
+
res.end(...data);
|
|
816
|
+
}, time);
|
|
817
|
+
};
|
|
810
818
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
(res.headers[____0.strings[7]].like('*text/css*') ||
|
|
816
|
-
res.headers[____0.strings[7]].like('*application/javascript*') ||
|
|
817
|
-
res.headers[____0.strings[7]].like('*text/html*') ||
|
|
818
|
-
res.headers[____0.strings[7]].like('*text/plain*') ||
|
|
819
|
-
res.headers[____0.strings[7]].like('*application/json*'))
|
|
820
|
-
) {
|
|
821
|
-
if (req.acceptEncoding.like('*gzip*') && typeof arg1 === 'string') {
|
|
822
|
-
res.set(____0.strings[8], 'gzip');
|
|
823
|
-
res.set('Vary', ____0.strings[5]);
|
|
824
|
-
arg1 = ____0.zlib.gzipSync(Buffer.from(arg1));
|
|
825
|
-
} else if (req.acceptEncoding.like('*deflate*') && typeof arg1 === 'string') {
|
|
826
|
-
res.set(____0.strings[8], 'deflate');
|
|
827
|
-
res.set('Vary', ____0.strings[5]);
|
|
828
|
-
arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
|
|
829
|
-
} else {
|
|
830
|
-
// ____0.log(typeof arg1)
|
|
831
|
-
}
|
|
819
|
+
res.end0 = res.end;
|
|
820
|
+
res.end = function (arg1, arg2, arg3, arg4) {
|
|
821
|
+
if (res.ended) {
|
|
822
|
+
return;
|
|
832
823
|
}
|
|
833
824
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
825
|
+
if (typeof arg1 === 'number') {
|
|
826
|
+
res.writeHead(arg1);
|
|
827
|
+
return res.end(arg2, arg3, arg4);
|
|
828
|
+
} else {
|
|
829
|
+
if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
|
|
830
|
+
res.set(____0.strings[7], 'text/html');
|
|
831
|
+
}
|
|
840
832
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
833
|
+
if (
|
|
834
|
+
arg1 &&
|
|
835
|
+
res.headers &&
|
|
836
|
+
res.headers[____0.strings[7]] &&
|
|
837
|
+
(res.headers[____0.strings[7]].like('*text/css*') ||
|
|
838
|
+
res.headers[____0.strings[7]].like('*application/javascript*') ||
|
|
839
|
+
res.headers[____0.strings[7]].like('*text/html*') ||
|
|
840
|
+
res.headers[____0.strings[7]].like('*text/plain*') ||
|
|
841
|
+
res.headers[____0.strings[7]].like('*application/json*'))
|
|
842
|
+
) {
|
|
843
|
+
if (req.acceptEncoding.like('*gzip*') && typeof arg1 === 'string') {
|
|
844
|
+
res.set(____0.strings[8], 'gzip');
|
|
845
|
+
res.set('Vary', ____0.strings[5]);
|
|
846
|
+
arg1 = ____0.zlib.gzipSync(Buffer.from(arg1));
|
|
847
|
+
} else if (req.acceptEncoding.like('*deflate*') && typeof arg1 === 'string') {
|
|
848
|
+
res.set(____0.strings[8], 'deflate');
|
|
849
|
+
res.set('Vary', ____0.strings[5]);
|
|
850
|
+
arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
|
|
851
|
+
} else {
|
|
852
|
+
// ____0.log(typeof arg1)
|
|
853
|
+
}
|
|
854
|
+
}
|
|
847
855
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
856
|
+
res.writeHead(res.code || res.statusCode || 200);
|
|
857
|
+
arg1 = arg1 || ' ';
|
|
858
|
+
res.ended = true;
|
|
859
|
+
return res.end0(arg1, arg2, arg3, arg4);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
851
862
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (stat && stat.isFile()) {
|
|
856
|
-
res.writeHead(200, {
|
|
857
|
-
'Content-Type': ____0.getContentType(path),
|
|
858
|
-
'Content-Length': stat.size,
|
|
859
|
-
'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
|
|
860
|
-
});
|
|
861
|
-
var readStream = ____0.fs.createReadStream(path);
|
|
862
|
-
readStream.on('end', function () {
|
|
863
|
-
readStream.close();
|
|
864
|
-
});
|
|
865
|
-
res.on(____0.strings[10], function () {
|
|
866
|
-
readStream.close();
|
|
867
|
-
});
|
|
868
|
-
readStream.pipe(res);
|
|
869
|
-
} else {
|
|
870
|
-
res.error();
|
|
863
|
+
res.status = (code) => {
|
|
864
|
+
if (!res.code) {
|
|
865
|
+
res.code = code || 200;
|
|
871
866
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
};
|
|
867
|
+
return res;
|
|
868
|
+
};
|
|
876
869
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
const readStream = ____0.fs.createReadStream(path, {
|
|
890
|
-
start,
|
|
891
|
-
end,
|
|
870
|
+
res.error = (code) => {
|
|
871
|
+
res.status(code || 404).end();
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
res.download2 = (path, name) => {
|
|
875
|
+
if (____0.isFileExistsSync(path)) {
|
|
876
|
+
var stat = ____0.fileStatSync(path);
|
|
877
|
+
if (stat && stat.isFile()) {
|
|
878
|
+
res.writeHead(200, {
|
|
879
|
+
'Content-Type': ____0.getContentType(path),
|
|
880
|
+
'Content-Length': stat.size,
|
|
881
|
+
'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
|
|
892
882
|
});
|
|
883
|
+
var readStream = ____0.fs.createReadStream(path);
|
|
893
884
|
readStream.on('end', function () {
|
|
894
885
|
readStream.close();
|
|
895
886
|
});
|
|
896
887
|
res.on(____0.strings[10], function () {
|
|
897
888
|
readStream.close();
|
|
898
889
|
});
|
|
899
|
-
res.writeHead(206, {
|
|
900
|
-
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
|
|
901
|
-
'Accept-Ranges': 'bytes',
|
|
902
|
-
'Content-Length': chunksize,
|
|
903
|
-
'Content-Type': ____0.getContentType(path),
|
|
904
|
-
});
|
|
905
890
|
readStream.pipe(res);
|
|
906
891
|
} else {
|
|
907
|
-
|
|
908
|
-
readStream.on('end', function () {
|
|
909
|
-
readStream.close();
|
|
910
|
-
});
|
|
911
|
-
res.on(____0.strings[10], function () {
|
|
912
|
-
readStream.close();
|
|
913
|
-
});
|
|
914
|
-
|
|
915
|
-
res.writeHead(200, {
|
|
916
|
-
'Content-Length': fileSize,
|
|
917
|
-
'Content-Type': ____0.getContentType(path),
|
|
918
|
-
'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
|
|
919
|
-
});
|
|
920
|
-
____0.fs.createReadStream(path).pipe(res);
|
|
892
|
+
res.error();
|
|
921
893
|
}
|
|
922
894
|
} else {
|
|
923
895
|
res.error();
|
|
924
896
|
}
|
|
925
|
-
}
|
|
926
|
-
res.error();
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
res.html = res.render = function (file, _data = null, options = {}) {
|
|
931
|
-
let filePath = '';
|
|
932
|
-
if (typeof file === 'object') {
|
|
933
|
-
filePath = file.path;
|
|
934
|
-
options = { ...options, ...file };
|
|
935
|
-
} else {
|
|
936
|
-
filePath = file;
|
|
937
|
-
}
|
|
897
|
+
};
|
|
938
898
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
899
|
+
res.download = function (path, name) {
|
|
900
|
+
if (____0.isFileExistsSync(path)) {
|
|
901
|
+
const stat = ____0.fileStatSync(path);
|
|
902
|
+
if (stat && stat.isFile()) {
|
|
903
|
+
const fileSize = stat.size;
|
|
904
|
+
const range = req.headers.range;
|
|
905
|
+
if (range) {
|
|
906
|
+
const parts = range.replace(/bytes=/, '').split('-');
|
|
907
|
+
const start = parseInt(parts[0], 10);
|
|
908
|
+
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
|
|
909
|
+
|
|
910
|
+
const chunksize = end - start + 1;
|
|
911
|
+
const readStream = ____0.fs.createReadStream(path, {
|
|
912
|
+
start,
|
|
913
|
+
end,
|
|
914
|
+
});
|
|
915
|
+
readStream.on('end', function () {
|
|
916
|
+
readStream.close();
|
|
917
|
+
});
|
|
918
|
+
res.on(____0.strings[10], function () {
|
|
919
|
+
readStream.close();
|
|
920
|
+
});
|
|
921
|
+
res.writeHead(206, {
|
|
922
|
+
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
|
|
923
|
+
'Accept-Ranges': 'bytes',
|
|
924
|
+
'Content-Length': chunksize,
|
|
925
|
+
'Content-Type': ____0.getContentType(path),
|
|
926
|
+
});
|
|
927
|
+
readStream.pipe(res);
|
|
928
|
+
} else {
|
|
929
|
+
const readStream = ____0.fs.createReadStream(path);
|
|
930
|
+
readStream.on('end', function () {
|
|
931
|
+
readStream.close();
|
|
932
|
+
});
|
|
933
|
+
res.on(____0.strings[10], function () {
|
|
934
|
+
readStream.close();
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
res.writeHead(200, {
|
|
938
|
+
'Content-Length': fileSize,
|
|
939
|
+
'Content-Type': ____0.getContentType(path),
|
|
940
|
+
'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
|
|
941
|
+
});
|
|
942
|
+
____0.fs.createReadStream(path).pipe(res);
|
|
943
|
+
}
|
|
949
944
|
} else {
|
|
950
|
-
|
|
945
|
+
res.error();
|
|
951
946
|
}
|
|
947
|
+
} else {
|
|
948
|
+
res.error();
|
|
952
949
|
}
|
|
950
|
+
};
|
|
953
951
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
952
|
+
res.html = res.render = function (file, _data = null, options = {}) {
|
|
953
|
+
let filePath = '';
|
|
954
|
+
if (typeof file === 'object') {
|
|
955
|
+
filePath = file.path;
|
|
956
|
+
options = { ...options, ...file };
|
|
957
|
+
} else {
|
|
958
|
+
filePath = file;
|
|
960
959
|
}
|
|
961
960
|
|
|
962
|
-
if (
|
|
963
|
-
|
|
961
|
+
if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == filePath && s.url == req.url))) {
|
|
962
|
+
res.headers = response.headers;
|
|
963
|
+
res.code = response.code;
|
|
964
|
+
res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
|
|
965
|
+
return res.end(response.content, response.encode);
|
|
964
966
|
}
|
|
967
|
+
____0.fsm.getContent(filePath, (content) => {
|
|
968
|
+
if (!content) {
|
|
969
|
+
if (_data && _data.html) {
|
|
970
|
+
return res.status(404).htmlContent(_data.html);
|
|
971
|
+
} else {
|
|
972
|
+
return res.status(404).end();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
965
975
|
|
|
966
|
-
|
|
967
|
-
req.
|
|
968
|
-
|
|
976
|
+
req.content = content;
|
|
977
|
+
req.data = { ...req.data, ..._data };
|
|
978
|
+
let route = { ...req.route, ...options };
|
|
969
979
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
res.set(____0.strings[7], 'text/css');
|
|
973
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
974
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
|
|
975
|
-
}
|
|
976
|
-
} else if (filePath.endsWith('.js')) {
|
|
977
|
-
res.set(____0.strings[7], 'application/javascript');
|
|
978
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
979
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
|
|
980
|
-
}
|
|
981
|
-
} else if (filePath.endsWith('.html')) {
|
|
982
|
-
res.set(____0.strings[7], 'text/html');
|
|
983
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
984
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
|
|
985
|
-
}
|
|
986
|
-
} else if (filePath.endsWith('.txt')) {
|
|
987
|
-
res.set(____0.strings[7], 'text/plain');
|
|
988
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
989
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
|
|
980
|
+
if (route.encript == '123') {
|
|
981
|
+
req.content = ____0.f1(req.content);
|
|
990
982
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
|
|
995
|
-
}
|
|
996
|
-
} else if (filePath.endsWith('.xml')) {
|
|
997
|
-
res.set(____0.strings[7], 'text/xml');
|
|
998
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
999
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
|
|
1000
|
-
}
|
|
1001
|
-
} else if (filePath.endsWith('.woff2')) {
|
|
1002
|
-
res.set(____0.strings[7], 'application/font-woff2');
|
|
1003
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
1004
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1005
|
-
}
|
|
1006
|
-
} else if (filePath.endsWith('.woff')) {
|
|
1007
|
-
res.set(____0.strings[7], 'application/font-woff');
|
|
1008
|
-
if (____0.options.cache.enabled && route.cache) {
|
|
1009
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
983
|
+
|
|
984
|
+
if (route.parser) {
|
|
985
|
+
req.content = ____0.parser(req, res, ____0, route).html(req.content);
|
|
1010
986
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
987
|
+
|
|
988
|
+
if (route.compress) {
|
|
989
|
+
req.content = req.content.replace(/\r?\n|\r/g, ' ').replace(/\s+/g, ' ');
|
|
1015
990
|
}
|
|
1016
|
-
|
|
1017
|
-
res.
|
|
1018
|
-
if (
|
|
1019
|
-
res.set(
|
|
991
|
+
|
|
992
|
+
res.status(options.code || 200);
|
|
993
|
+
if (filePath.endsWith('.css')) {
|
|
994
|
+
res.set(____0.strings[7], 'text/css');
|
|
995
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
996
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
|
|
997
|
+
}
|
|
998
|
+
} else if (filePath.endsWith('.js')) {
|
|
999
|
+
res.set(____0.strings[7], 'application/javascript');
|
|
1000
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1001
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
|
|
1002
|
+
}
|
|
1003
|
+
} else if (filePath.endsWith('.html')) {
|
|
1004
|
+
res.set(____0.strings[7], 'text/html');
|
|
1005
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1006
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
|
|
1007
|
+
}
|
|
1008
|
+
} else if (filePath.endsWith('.txt')) {
|
|
1009
|
+
res.set(____0.strings[7], 'text/plain');
|
|
1010
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1011
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
|
|
1012
|
+
}
|
|
1013
|
+
} else if (filePath.endsWith('.json')) {
|
|
1014
|
+
res.set(____0.strings[7], 'application/json');
|
|
1015
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1016
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
|
|
1017
|
+
}
|
|
1018
|
+
} else if (filePath.endsWith('.xml')) {
|
|
1019
|
+
res.set(____0.strings[7], 'text/xml');
|
|
1020
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1021
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
|
|
1022
|
+
}
|
|
1023
|
+
} else if (filePath.endsWith('.woff2')) {
|
|
1024
|
+
res.set(____0.strings[7], 'application/font-woff2');
|
|
1025
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1026
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1027
|
+
}
|
|
1028
|
+
} else if (filePath.endsWith('.woff')) {
|
|
1029
|
+
res.set(____0.strings[7], 'application/font-woff');
|
|
1030
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1031
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1032
|
+
}
|
|
1033
|
+
} else if (filePath.endsWith('.ttf')) {
|
|
1034
|
+
res.set(____0.strings[7], 'application/font-ttf');
|
|
1035
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1036
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1037
|
+
}
|
|
1038
|
+
} else if (filePath.endsWith('.svg')) {
|
|
1039
|
+
res.set(____0.strings[7], 'application/font-svg');
|
|
1040
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1041
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1042
|
+
}
|
|
1043
|
+
} else if (filePath.endsWith('.otf')) {
|
|
1044
|
+
res.set(____0.strings[7], 'application/font-otf');
|
|
1045
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1046
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1047
|
+
}
|
|
1048
|
+
} else if (filePath.endsWith('.eot')) {
|
|
1049
|
+
res.set(____0.strings[7], 'application/font-eot');
|
|
1050
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1051
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
|
|
1052
|
+
}
|
|
1053
|
+
} else if (filePath.endsWith('.gif')) {
|
|
1054
|
+
res.set(____0.strings[7], 'image/gif');
|
|
1055
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1056
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1057
|
+
}
|
|
1058
|
+
} else if (filePath.endsWith('.png')) {
|
|
1059
|
+
res.set(____0.strings[7], 'image/png');
|
|
1060
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1061
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1062
|
+
}
|
|
1063
|
+
} else if (filePath.endsWith('.jpg')) {
|
|
1064
|
+
res.set(____0.strings[7], 'image/jpg');
|
|
1065
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1066
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1067
|
+
}
|
|
1068
|
+
} else if (filePath.endsWith('.jpeg')) {
|
|
1069
|
+
res.set(____0.strings[7], 'image/jpeg');
|
|
1070
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1071
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1072
|
+
}
|
|
1073
|
+
} else if (filePath.endsWith('.ico')) {
|
|
1074
|
+
res.set(____0.strings[7], 'image/ico');
|
|
1075
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1076
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1077
|
+
}
|
|
1078
|
+
} else if (filePath.endsWith('.bmp')) {
|
|
1079
|
+
res.set(____0.strings[7], 'image/bmp');
|
|
1080
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1081
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1082
|
+
}
|
|
1083
|
+
} else if (filePath.endsWith('.webp')) {
|
|
1084
|
+
res.set(____0.strings[7], 'image/webp');
|
|
1085
|
+
if (____0.options.cache.enabled && route.cache) {
|
|
1086
|
+
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1087
|
+
}
|
|
1020
1088
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1089
|
+
|
|
1090
|
+
let response = {
|
|
1091
|
+
host: req.host,
|
|
1092
|
+
url: req.url,
|
|
1093
|
+
filePath: filePath,
|
|
1094
|
+
content: req.content,
|
|
1095
|
+
encode: ____0.getFileEncode(filePath),
|
|
1096
|
+
headers: res.headers,
|
|
1097
|
+
code: res.code,
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
if (options.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
|
|
1101
|
+
____0.sharedList.push(response);
|
|
1025
1102
|
}
|
|
1026
|
-
|
|
1027
|
-
res.
|
|
1028
|
-
|
|
1029
|
-
|
|
1103
|
+
|
|
1104
|
+
res.end(response.content, response.encode);
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
res.txt = (name, _data) => {
|
|
1109
|
+
____0.fsm.getContent(name, (content) => {
|
|
1110
|
+
if (!content) {
|
|
1111
|
+
return res.status(404).end();
|
|
1030
1112
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1113
|
+
req.route.content = content;
|
|
1114
|
+
if (req.route.encript === '123') {
|
|
1115
|
+
req.route.content = ____0.f1(req.route.content);
|
|
1035
1116
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1117
|
+
req.data = { ...req.data, ..._data };
|
|
1118
|
+
req.route.parser = 'txt';
|
|
1119
|
+
let out = ____0.parser(req, res, ____0, req.route).txt(req.route.content);
|
|
1120
|
+
res.set(____0.strings[7], 'text/plain');
|
|
1121
|
+
res.status(200).end(out);
|
|
1122
|
+
});
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
res.css = (name, _data) => {
|
|
1126
|
+
____0.fsm.getContent(name, (content) => {
|
|
1127
|
+
if (!content) {
|
|
1128
|
+
return res.status(404).end();
|
|
1040
1129
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1130
|
+
req.route.content = content;
|
|
1131
|
+
if (req.route.encript === '123') {
|
|
1132
|
+
req.route.content = ____0.f1(req.route.content);
|
|
1045
1133
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1134
|
+
req.data = { ...req.data, ..._data };
|
|
1135
|
+
req.route.parser = 'css';
|
|
1136
|
+
let out = ____0.parser(req, res, ____0, req.route).css(req.route.content);
|
|
1137
|
+
res.set(____0.strings[7], 'text/css');
|
|
1138
|
+
res.status(200).end(out);
|
|
1139
|
+
});
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
res.js = (name, _data) => {
|
|
1143
|
+
____0.fsm.getContent(name, (content) => {
|
|
1144
|
+
if (!content) {
|
|
1145
|
+
return res.status(404).end();
|
|
1050
1146
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1147
|
+
req.route.content = content;
|
|
1148
|
+
if (req.route.encript === '123') {
|
|
1149
|
+
req.route.content = ____0.f1(req.route.content);
|
|
1055
1150
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1151
|
+
req.data = { ...req.data, ..._data };
|
|
1152
|
+
req.route.parser = 'js';
|
|
1153
|
+
let out = ____0.parser(req, res, ____0, req.route).js(req.route.content);
|
|
1154
|
+
res.set(____0.strings[7], 'text/javascript');
|
|
1155
|
+
res.status(200).end(out);
|
|
1156
|
+
});
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
res.jsonFile = (name, _data) => {
|
|
1160
|
+
____0.fsm.getContent(name, (content) => {
|
|
1161
|
+
if (!content) {
|
|
1162
|
+
return res.status(404).end();
|
|
1060
1163
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
|
|
1164
|
+
req.route.content = content;
|
|
1165
|
+
if (req.route.encript === '123') {
|
|
1166
|
+
req.route.content = ____0.f1(req.route.content);
|
|
1065
1167
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
encode: ____0.getFileEncode(filePath),
|
|
1074
|
-
headers: res.headers,
|
|
1075
|
-
code: res.code,
|
|
1076
|
-
};
|
|
1077
|
-
|
|
1078
|
-
if (options.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
|
|
1079
|
-
____0.sharedList.push(response);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
res.end(response.content, response.encode);
|
|
1083
|
-
});
|
|
1084
|
-
};
|
|
1168
|
+
req.data = { ...req.data, ..._data };
|
|
1169
|
+
req.route.parser = 'json';
|
|
1170
|
+
let out = ____0.parser(req, res, ____0, req.route).html(req.route.content);
|
|
1171
|
+
res.set(____0.strings[7], 'application/json');
|
|
1172
|
+
res.status(200).end(out);
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1085
1175
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1176
|
+
res.htmlContent =
|
|
1177
|
+
res.send =
|
|
1178
|
+
res.sendHTML =
|
|
1179
|
+
(text) => {
|
|
1180
|
+
if (typeof text === 'string') {
|
|
1181
|
+
res.set(____0.strings[7], 'text/html');
|
|
1182
|
+
res.status(200).end(text);
|
|
1183
|
+
} else {
|
|
1184
|
+
res.json(text);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
res.textContent = res.sendTEXT = (text) => {
|
|
1188
|
+
if (typeof text === 'string') {
|
|
1189
|
+
res.set(____0.strings[7], 'text/plain');
|
|
1190
|
+
res.status(200).end(text);
|
|
1191
|
+
} else {
|
|
1192
|
+
res.json(text);
|
|
1090
1193
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1194
|
+
};
|
|
1195
|
+
res.json = (obj, time) => {
|
|
1196
|
+
if (typeof obj === 'string') {
|
|
1197
|
+
return res.jsonFile(obj);
|
|
1198
|
+
} else {
|
|
1199
|
+
res.set(____0.strings[7], 'application/json');
|
|
1200
|
+
obj = ____0.toJson(obj);
|
|
1201
|
+
res.status(200).ending(time || 0, obj);
|
|
1202
|
+
obj = null;
|
|
1203
|
+
return res;
|
|
1094
1204
|
}
|
|
1095
|
-
|
|
1096
|
-
req.route.parser = 'txt';
|
|
1097
|
-
let out = ____0.parser(req, res, ____0, req.route).txt(req.route.content);
|
|
1098
|
-
res.set(____0.strings[7], 'text/plain');
|
|
1099
|
-
res.status(200).end(out);
|
|
1100
|
-
});
|
|
1101
|
-
};
|
|
1205
|
+
};
|
|
1102
1206
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
}
|
|
1108
|
-
req.route.content = content;
|
|
1109
|
-
if (req.route.encript === '123') {
|
|
1110
|
-
req.route.content = ____0.f1(req.route.content);
|
|
1111
|
-
}
|
|
1112
|
-
req.data = { ...req.data, ..._data };
|
|
1113
|
-
req.route.parser = 'css';
|
|
1114
|
-
let out = ____0.parser(req, res, ____0, req.route).css(req.route.content);
|
|
1115
|
-
res.set(____0.strings[7], 'text/css');
|
|
1116
|
-
res.status(200).end(out);
|
|
1117
|
-
});
|
|
1118
|
-
};
|
|
1207
|
+
res.redirect = (url, code = 302) => {
|
|
1208
|
+
res.set('Location', url);
|
|
1209
|
+
res.status(code).end();
|
|
1210
|
+
};
|
|
1119
1211
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
req.data = { ...req.data, ..._data };
|
|
1130
|
-
req.route.parser = 'js';
|
|
1131
|
-
let out = ____0.parser(req, res, ____0, req.route).js(req.route.content);
|
|
1132
|
-
res.set(____0.strings[7], 'text/javascript');
|
|
1133
|
-
res.status(200).end(out);
|
|
1134
|
-
});
|
|
1135
|
-
};
|
|
1212
|
+
res.set('CharSet', 'UTF-8');
|
|
1213
|
+
res.set('Access-Control-Allow-Credentials', 'true');
|
|
1214
|
+
res.set('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || 'Origin, X-Requested-With, Content-Type, Accept , Access-Token , Authorization');
|
|
1215
|
+
res.set('Access-Control-Allow-Methods', req.headers['access-control-request-method'] || 'POST,GET,DELETE,PUT,OPTIONS,VIEW,HEAD,CONNECT,TRACE');
|
|
1216
|
+
res.set('Access-Control-Allow-Origin', req.referer || '*');
|
|
1217
|
+
if (req.origin) {
|
|
1218
|
+
res.set('Access-Control-Allow-Origin', req.origin);
|
|
1219
|
+
}
|
|
1136
1220
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
return
|
|
1141
|
-
}
|
|
1142
|
-
req.route.content = content;
|
|
1143
|
-
if (req.route.encript === '123') {
|
|
1144
|
-
req.route.content = ____0.f1(req.route.content);
|
|
1221
|
+
____0.validateRequest(req, res, (req, res) => {
|
|
1222
|
+
if (____0.options.www === false && req.host.contains('www')) {
|
|
1223
|
+
res.redirect('//' + req.host.replace('www.', '') + req.url, 301);
|
|
1224
|
+
return;
|
|
1145
1225
|
}
|
|
1146
|
-
req.data = { ...req.data, ..._data };
|
|
1147
|
-
req.route.parser = 'json';
|
|
1148
|
-
let out = ____0.parser(req, res, ____0, req.route).html(req.route.content);
|
|
1149
|
-
res.set(____0.strings[7], 'application/json');
|
|
1150
|
-
res.status(200).end(out);
|
|
1151
|
-
});
|
|
1152
|
-
};
|
|
1153
1226
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
res.set(____0.strings[7], 'text/html');
|
|
1160
|
-
res.status(200).end(text);
|
|
1161
|
-
} else {
|
|
1162
|
-
res.json(text);
|
|
1227
|
+
if (!req.urlParser.pathname.like(____0.strings[0])) {
|
|
1228
|
+
if (!____0._0_a405) {
|
|
1229
|
+
res.status(405);
|
|
1230
|
+
res.end();
|
|
1231
|
+
return;
|
|
1163
1232
|
}
|
|
1164
|
-
};
|
|
1165
|
-
res.textContent = res.sendTEXT = (text) => {
|
|
1166
|
-
if (typeof text === 'string') {
|
|
1167
|
-
res.set(____0.strings[7], 'text/plain');
|
|
1168
|
-
res.status(200).end(text);
|
|
1169
|
-
} else {
|
|
1170
|
-
res.json(text);
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
res.json = (obj, time) => {
|
|
1174
|
-
if (typeof obj === 'string') {
|
|
1175
|
-
return res.jsonFile(obj);
|
|
1176
|
-
} else {
|
|
1177
|
-
res.set(____0.strings[7], 'application/json');
|
|
1178
|
-
obj = ____0.toJson(obj);
|
|
1179
|
-
res.status(200).ending(time || 0, obj);
|
|
1180
|
-
obj = null;
|
|
1181
|
-
return res;
|
|
1182
|
-
}
|
|
1183
|
-
};
|
|
1184
|
-
|
|
1185
|
-
res.redirect = (url, code = 302) => {
|
|
1186
|
-
res.set('Location', url);
|
|
1187
|
-
res.status(code).end();
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
res.set('CharSet', 'UTF-8');
|
|
1191
|
-
res.set('Access-Control-Allow-Credentials', 'true');
|
|
1192
|
-
res.set('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || 'Origin, X-Requested-With, Content-Type, Accept , Access-Token , Authorization');
|
|
1193
|
-
res.set('Access-Control-Allow-Methods', req.headers['access-control-request-method'] || 'POST,GET,DELETE,PUT,OPTIONS,VIEW,HEAD,CONNECT,TRACE');
|
|
1194
|
-
res.set('Access-Control-Allow-Origin', req.referer || '*');
|
|
1195
|
-
if (req.origin) {
|
|
1196
|
-
res.set('Access-Control-Allow-Origin', req.origin);
|
|
1197
|
-
}
|
|
1198
1233
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
error: ____0.strings[3],
|
|
1218
|
-
});
|
|
1219
|
-
} else {
|
|
1220
|
-
return res.render(
|
|
1221
|
-
____0.strings[2],
|
|
1222
|
-
{
|
|
1223
|
-
html: ____0.strings[3],
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
parser: ____0.strings[17],
|
|
1234
|
+
if (!____0._0_ar2_0_) {
|
|
1235
|
+
res.set(____0.strings[1], 'true');
|
|
1236
|
+
res.status(402);
|
|
1237
|
+
if (req.url.like('*api*')) {
|
|
1238
|
+
return res.json({
|
|
1239
|
+
done: false,
|
|
1240
|
+
error: ____0.strings[3],
|
|
1241
|
+
});
|
|
1242
|
+
} else {
|
|
1243
|
+
return res.render(
|
|
1244
|
+
____0.strings[2],
|
|
1245
|
+
{
|
|
1246
|
+
html: ____0.strings[3],
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
parser: ____0.strings[17],
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
1227
1252
|
}
|
|
1228
|
-
|
|
1253
|
+
}
|
|
1229
1254
|
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
1255
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1256
|
+
let findRouteIndex = _0xrrxo.list.findIndex((r) => req.method.toLowerCase().like(r.method.toLowerCase()) && req.urlParser.pathname.like(r.name));
|
|
1257
|
+
if (findRouteIndex !== -1) {
|
|
1258
|
+
if (!_0xrrxo.list[findRouteIndex].count) {
|
|
1259
|
+
_0xrrxo.list[findRouteIndex].count = 0;
|
|
1260
|
+
}
|
|
1261
|
+
_0xrrxo.list[findRouteIndex].count++;
|
|
1262
|
+
if (____0.options.help) {
|
|
1263
|
+
res.set('help-request-count', _0xrrxo.list[findRouteIndex].count);
|
|
1264
|
+
}
|
|
1242
1265
|
|
|
1243
|
-
|
|
1266
|
+
req.route = _0xrrxo.list[findRouteIndex];
|
|
1244
1267
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1268
|
+
req.urlParser.arr = req.urlParser.pathname.split('/');
|
|
1269
|
+
req.urlParserRaw.arr = req.urlParserRaw.pathname.split('/');
|
|
1247
1270
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1271
|
+
for (let i = 0; i < req.route.map.length; i++) {
|
|
1272
|
+
let map = req.route.map[i];
|
|
1273
|
+
if (typeof req.urlParser.arr[map.index] === 'string') {
|
|
1274
|
+
try {
|
|
1275
|
+
req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index].replace(/\+/g, ' '));
|
|
1276
|
+
} catch (error) {
|
|
1277
|
+
req.params[map.name] = req.urlParser.arr[map.index].replace(/\+/g, ' ');
|
|
1278
|
+
}
|
|
1279
|
+
req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index];
|
|
1280
|
+
}
|
|
1255
1281
|
}
|
|
1256
|
-
req.
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1282
|
+
req.session = {
|
|
1283
|
+
$save: () => {},
|
|
1284
|
+
accessToken: 'SHARED',
|
|
1285
|
+
language: ____0.options.language || { id: 'En', dir: 'ltr', text: 'left' },
|
|
1286
|
+
lang: ____0.options.language?.id || ____0.options.lang || 'En',
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
req.query = req.urlParser.query;
|
|
1290
|
+
req.queryRaw = req.urlParserRaw.query;
|
|
1291
|
+
|
|
1292
|
+
____0.validateRoute(req, res, (req, res) => {
|
|
1293
|
+
if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/urlencoded/i)) {
|
|
1294
|
+
req.on('data', function (data) {
|
|
1295
|
+
req.bodyRaw += data;
|
|
1296
|
+
});
|
|
1297
|
+
req.on('end', function () {
|
|
1298
|
+
req.dataRaw = req.bodyRaw;
|
|
1299
|
+
req.data = req.body = ____0.querystring.parse(req.bodyRaw);
|
|
1300
|
+
if (____0.options.session.enabled) {
|
|
1301
|
+
____0.session(req, res, ____0, function (session) {
|
|
1302
|
+
req.session = session;
|
|
1303
|
+
____0.validateSession(req, res, (req, res) => {
|
|
1304
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1305
|
+
});
|
|
1306
|
+
});
|
|
1307
|
+
} else {
|
|
1308
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
} else if (req.method.contains('post') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].contains('multipart')) {
|
|
1312
|
+
let form = ____0.formidable({
|
|
1313
|
+
multiples: !0,
|
|
1314
|
+
uploadDir: ____0.options.upload_dir,
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
form.parse(req, (err, fields, files) => {
|
|
1318
|
+
if (err) {
|
|
1319
|
+
____0.log(err);
|
|
1320
|
+
}
|
|
1321
|
+
req.form = { err, fields, files };
|
|
1322
|
+
req.data = req.body = fields || {};
|
|
1323
|
+
req.files = files;
|
|
1324
|
+
if (____0.options.session.enabled) {
|
|
1325
|
+
____0.session(req, res, ____0, function (session) {
|
|
1326
|
+
req.session = session;
|
|
1327
|
+
____0.validateSession(req, res, (req, res) => {
|
|
1328
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1329
|
+
});
|
|
1330
|
+
});
|
|
1331
|
+
} else {
|
|
1332
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1265
1335
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1336
|
+
return;
|
|
1337
|
+
} else if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/json/i)) {
|
|
1338
|
+
req.on('data', function (data) {
|
|
1339
|
+
req.bodyRaw += data;
|
|
1340
|
+
});
|
|
1341
|
+
req.on('end', function () {
|
|
1342
|
+
req.dataRaw = req.bodyRaw;
|
|
1343
|
+
req.data = req.body = ____0.fromJson(req.bodyRaw);
|
|
1344
|
+
if (____0.options.session.enabled) {
|
|
1345
|
+
____0.session(req, res, ____0, function (session) {
|
|
1346
|
+
req.session = session;
|
|
1347
|
+
____0.validateSession(req, res, (req, res) => {
|
|
1348
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1349
|
+
});
|
|
1350
|
+
});
|
|
1351
|
+
} else {
|
|
1352
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
} else if (!req.method.toLowerCase().like('get')) {
|
|
1356
|
+
req.on('data', function (data) {
|
|
1357
|
+
req.bodyRaw += data;
|
|
1358
|
+
});
|
|
1359
|
+
req.on('end', function () {
|
|
1360
|
+
req.dataRaw = req.bodyRaw;
|
|
1361
|
+
req.data = req.body = ____0.fromJson(req.bodyRaw);
|
|
1362
|
+
if (____0.options.session.enabled) {
|
|
1363
|
+
____0.session(req, res, ____0, function (session) {
|
|
1364
|
+
req.session = session;
|
|
1365
|
+
____0.validateSession(req, res, (req, res) => {
|
|
1366
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
} else {
|
|
1370
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1371
|
+
}
|
|
1372
|
+
});
|
|
1373
|
+
} else {
|
|
1374
|
+
req.body = req.data = req.query;
|
|
1375
|
+
req.bodyRaw = req.dataRaw = req.queryRaw;
|
|
1376
|
+
|
|
1377
|
+
if (____0.options.session.enabled) {
|
|
1378
|
+
____0.session(req, res, ____0, function (session) {
|
|
1379
|
+
req.session = session;
|
|
1380
|
+
____0.validateSession(req, res, (req, res) => {
|
|
1381
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1382
|
+
});
|
|
1383
|
+
});
|
|
1384
|
+
} else {
|
|
1385
|
+
_0xrrxo.handleRoute(req, res, req.route);
|
|
1386
|
+
}
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1268
1390
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
req.
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
____0.session(req, res, ____0, function (session) {
|
|
1278
|
-
req.session = session;
|
|
1279
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1280
|
-
});
|
|
1281
|
-
} else {
|
|
1282
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1391
|
+
return;
|
|
1392
|
+
} else {
|
|
1393
|
+
if (req.urlParser.pathname == '/') {
|
|
1394
|
+
if (____0.options.help) {
|
|
1395
|
+
res.set('help-eror-message', 'unhandled route root : ' + req.urlParser.pathname);
|
|
1396
|
+
}
|
|
1397
|
+
res.htmlContent("<h1 align='center'>Base Route / Not Set</h1>");
|
|
1398
|
+
return;
|
|
1283
1399
|
}
|
|
1284
|
-
});
|
|
1285
|
-
} else if (req.method.contains('post') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].contains('multipart')) {
|
|
1286
|
-
let form = ____0.formidable({
|
|
1287
|
-
multiples: !0,
|
|
1288
|
-
uploadDir: ____0.options.upload_dir,
|
|
1289
|
-
});
|
|
1290
1400
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
____0.log(err);
|
|
1294
|
-
}
|
|
1295
|
-
req.form = { err, fields, files };
|
|
1296
|
-
req.data = req.body = fields || {};
|
|
1297
|
-
req.files = files;
|
|
1298
|
-
if (____0.options.session.enabled) {
|
|
1299
|
-
____0.session(req, res, ____0, function (session) {
|
|
1300
|
-
req.session = session;
|
|
1301
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1302
|
-
});
|
|
1303
|
-
} else {
|
|
1304
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1401
|
+
if (____0.options.help) {
|
|
1402
|
+
res.set('help-eror-message', 'unhandled route help : ' + req.urlParser.pathname);
|
|
1305
1403
|
}
|
|
1306
|
-
});
|
|
1307
1404
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
req.bodyRaw += data;
|
|
1312
|
-
});
|
|
1313
|
-
req.on('end', function () {
|
|
1314
|
-
req.dataRaw = req.bodyRaw;
|
|
1315
|
-
req.data = req.body = ____0.fromJson(req.bodyRaw);
|
|
1316
|
-
if (____0.options.session.enabled) {
|
|
1317
|
-
____0.session(req, res, ____0, function (session) {
|
|
1318
|
-
req.session = session;
|
|
1319
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1320
|
-
});
|
|
1321
|
-
} else {
|
|
1322
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
1325
|
-
} else if (!req.method.toLowerCase().like('get')) {
|
|
1326
|
-
req.on('data', function (data) {
|
|
1327
|
-
req.bodyRaw += data;
|
|
1328
|
-
});
|
|
1329
|
-
req.on('end', function () {
|
|
1330
|
-
req.dataRaw = req.bodyRaw;
|
|
1331
|
-
req.data = req.body = ____0.fromJson(req.bodyRaw);
|
|
1332
|
-
if (____0.options.session.enabled) {
|
|
1333
|
-
____0.session(req, res, ____0, function (session) {
|
|
1334
|
-
req.session = session;
|
|
1335
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1336
|
-
});
|
|
1337
|
-
} else {
|
|
1338
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1405
|
+
if (req.method.toLowerCase().like('options') || req.method.toLowerCase().like('head')) {
|
|
1406
|
+
res.status(200).end();
|
|
1407
|
+
return;
|
|
1339
1408
|
}
|
|
1340
|
-
|
|
1341
|
-
} else {
|
|
1342
|
-
req.body = req.data = req.query;
|
|
1343
|
-
req.bodyRaw = req.dataRaw = req.queryRaw;
|
|
1344
|
-
|
|
1345
|
-
if (____0.options.session.enabled) {
|
|
1346
|
-
____0.session(req, res, ____0, function (session) {
|
|
1347
|
-
req.session = session;
|
|
1348
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1349
|
-
});
|
|
1350
|
-
} else {
|
|
1351
|
-
_0xrrxo.handleRoute(req, res, req.route);
|
|
1352
|
-
}
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
return;
|
|
1357
|
-
} else {
|
|
1358
|
-
if (req.urlParser.pathname == '/') {
|
|
1359
|
-
if (____0.options.help) {
|
|
1360
|
-
res.set('help-eror-message', 'unhandled route root : ' + req.urlParser.pathname);
|
|
1409
|
+
____0.handleNotRoute(req, res);
|
|
1361
1410
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
if (____0.options.help) {
|
|
1367
|
-
res.set('help-eror-message', 'unhandled route help : ' + req.urlParser.pathname);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
if (req.method.toLowerCase().like('options') || req.method.toLowerCase().like('head')) {
|
|
1371
|
-
res.status(200).end();
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
____0.handleNotRoute(req, res);
|
|
1375
|
-
}
|
|
1411
|
+
});
|
|
1412
|
+
});
|
|
1376
1413
|
};
|
|
1377
1414
|
|
|
1378
1415
|
____0.handleNotRoute = function (req, res) {
|
|
@@ -1385,6 +1422,8 @@ module.exports = function init(____0) {
|
|
|
1385
1422
|
_0xrrxo.start = function (_ports, callback) {
|
|
1386
1423
|
____0.startTime = Date.now();
|
|
1387
1424
|
|
|
1425
|
+
____0.ws.wsSupport();
|
|
1426
|
+
|
|
1388
1427
|
____0.https.globalAgent.options = {
|
|
1389
1428
|
key: ____0.fs.readFileSync(____0.options.https.key || __dirname + '/../ssl/key.pem'),
|
|
1390
1429
|
cert: ____0.fs.readFileSync(____0.options.https.cert || __dirname + '/../ssl/cert.pem'),
|
|
@@ -1416,7 +1455,7 @@ module.exports = function init(____0) {
|
|
|
1416
1455
|
try {
|
|
1417
1456
|
if (____0.options.http2) {
|
|
1418
1457
|
let server = ____0.http2.createServer();
|
|
1419
|
-
server.on('error', (err) =>
|
|
1458
|
+
server.on('error', (err) => ____0.log(err));
|
|
1420
1459
|
server.on('stream', (stream, headers) => {
|
|
1421
1460
|
// _0xrrxo.handleStream(stream , headers , server);
|
|
1422
1461
|
let path = headers[':path'];
|
|
@@ -1437,7 +1476,7 @@ module.exports = function init(____0) {
|
|
|
1437
1476
|
server.timeout = 1000 * ____0.options.responseTimeout;
|
|
1438
1477
|
server.on('error', (e) => {
|
|
1439
1478
|
if (e.code === 'EADDRINUSE') {
|
|
1440
|
-
|
|
1479
|
+
____0.log('Address in use, Closing Server : ' + p);
|
|
1441
1480
|
server.close();
|
|
1442
1481
|
}
|
|
1443
1482
|
});
|
|
@@ -1458,7 +1497,7 @@ module.exports = function init(____0) {
|
|
|
1458
1497
|
});
|
|
1459
1498
|
}
|
|
1460
1499
|
} catch (error) {
|
|
1461
|
-
|
|
1500
|
+
____0.log(error);
|
|
1462
1501
|
}
|
|
1463
1502
|
});
|
|
1464
1503
|
|
|
@@ -1475,7 +1514,7 @@ module.exports = function init(____0) {
|
|
|
1475
1514
|
server.timeout = 1000 * ____0.options.responseTimeout;
|
|
1476
1515
|
server.on('error', (e) => {
|
|
1477
1516
|
if (e.code === 'EADDRINUSE') {
|
|
1478
|
-
|
|
1517
|
+
____0.log('Address in use, Closing Server : ' + p);
|
|
1479
1518
|
server.close();
|
|
1480
1519
|
}
|
|
1481
1520
|
});
|