elit 3.3.7 → 3.3.8

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/dist/server.mjs CHANGED
@@ -2872,9 +2872,31 @@ var ServerRouter = class {
2872
2872
  const query = this.parseQuery(url);
2873
2873
  req.query = query;
2874
2874
  req.params = params;
2875
+ let _statusCode = 200;
2876
+ const elitRes = res;
2877
+ elitRes.status = function(code) {
2878
+ _statusCode = code;
2879
+ return this;
2880
+ };
2881
+ elitRes.json = function(data, statusCode) {
2882
+ const code = statusCode !== void 0 ? statusCode : _statusCode;
2883
+ this.writeHead(code, { "Content-Type": "application/json" });
2884
+ this.end(JSON.stringify(data));
2885
+ return this;
2886
+ };
2887
+ elitRes.send = function(data) {
2888
+ if (typeof data === "string") {
2889
+ this.writeHead(_statusCode, { "Content-Type": "text/html" });
2890
+ this.end(data);
2891
+ } else {
2892
+ this.writeHead(_statusCode, { "Content-Type": "application/json" });
2893
+ this.end(JSON.stringify(data));
2894
+ }
2895
+ return this;
2896
+ };
2875
2897
  const ctx = {
2876
2898
  req,
2877
- res,
2899
+ res: elitRes,
2878
2900
  params,
2879
2901
  query,
2880
2902
  body,