Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onlinx/core

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onlinx/core - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

4

dist/context.d.ts
/// <reference types="node" />
import { IncomingHttpHeaders } from 'http';
import { IncomingHttpHeaders, IncomingMessage } from 'http';
import { MimeTypes, UnknownObject } from './utils/types';

@@ -13,2 +13,3 @@ declare type HeadersUnion = string | number | string[];

headers: IncomingHttpHeaders;
raw: IncomingMessage;
}

@@ -22,2 +23,3 @@ interface Headers {

private request;
readonly raw: IncomingMessage;
headers: Headers;

@@ -24,0 +26,0 @@ data: UnknownObject;

@@ -77,2 +77,3 @@ 'use strict';

this.raw = request.raw;
this.data = {}; // Makes sure that the defaultResponse is not mutated

@@ -302,3 +303,4 @@

return {
headers: request.headers
headers: request.headers,
raw: request
};

@@ -305,0 +307,0 @@ };

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("url"),n=require("http");function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function e(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}var o={type:"text/plain",status:404,headers:{}},i=function(){function t(t){var n=this;this.data={},this.response=r({},o),this.request=t,this.headers={get:function(t){return n.request.headers[t.toLowerCase()]},set:function(t,r){n.response.headers[t]=r}}}return t.prototype.status=function(t){return this.response.status=t,this},t}();const u=function(){function t(){}return t.prototype.then=function(n,r){const e=new t,o=this.s;if(o){const t=1&o?n:r;if(t){try{s(e,1,t(this.v))}catch(t){s(e,2,t)}return e}return this}return this.o=function(t){try{const o=t.v;1&t.s?s(e,1,n?n(o):o):r?s(e,1,r(o)):s(e,2,o)}catch(t){s(e,2,t)}},e},t}();function s(t,n,r){if(!t.s){if(r instanceof u){if(!r.s)return void(r.o=s.bind(null,t,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(s.bind(null,t,n),s.bind(null,t,2));t.s=n,t.v=r;const e=t.o;e&&e(t)}}function c(t){return t instanceof u&&1&t.s}const a="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function f(t,n,r){if("function"==typeof t[a]){var e,o,i,f=t[a]();if(function t(a){try{for(;!((e=f.next()).done||r&&r());)if((a=n(e.value))&&a.then){if(!c(a))return void a.then(t,i||(i=s.bind(null,o=new u,2)));a=a.v}o?s(o,1,a):o=a}catch(t){s(o||(o=new u),2,t)}}(),f.return){var h=function(t){try{e.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(h,(function(t){throw h(t)}));h()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],v=0;v<t.length;v++)l.push(t[v]);return function(t,n,r){var e,o,i=-1;return function a(f){try{for(;++i<t.length&&(!r||!r());)if((f=n(i))&&f.then){if(!c(f))return void f.then(a,o||(o=s.bind(null,e=new u,2)));f=f.v}e?s(e,1,f):e=f}catch(t){s(e||(e=new u),2,t)}}(),e}(l,(function(t){return n(l[t])}),r)}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var h=function(){function n(){this.routes=[]}var r=n.prototype;return r.route=function(t,n){this.routes.push({path:t,routes:n})},r.mount=function(){var n=this;return function(r,o){try{var i=(u=t.parse(r.url||"/").pathname||"",s={path:"*",routes:{all:function(t){try{return t.status(404),Promise.resolve("404 Not Found")}catch(t){return Promise.reject(t)}}}},function(t){for(var n,r=[],o=function(t,n){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return e(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,void 0):void 0}}(t))){r&&(t=r);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}(t);!(n=o()).done;){var i=n.value;"*"===i.path?r.unshift(i):i.path.startsWith("/")&&r.push(i)}return r}(n.routes).some((function(t){return("*"===t.path||t.path===u)&&(s=t,!0)})),s);return Promise.resolve(l(i,r,o)).then((function(){}))}catch(t){return Promise.reject(t)}var u,s}},n}(),l=function(t,n,r){try{var e=function(t){return{headers:t.headers}}(n),o=new i(e);return Promise.resolve(f(Object.entries(t.routes),(function(t){var e=t[0],i=t[1],u=function(){var t;if(e===(null===(t=n.method)||void 0===t?void 0:t.toLowerCase())){var u=function(){if(i instanceof Array)return Promise.resolve(p(i,o,r)).then((function(){}));var t=function(){if(null!=i)return Promise.resolve(i(o)).then((function(t){return Promise.resolve(v(t,r,o)).then((function(){}))}))}();return t&&t.then?t.then((function(){})):void 0}();if(u&&u.then)return u.then((function(){}))}}();if(u&&u.then)return u.then((function(){}))})))}catch(t){return Promise.reject(t)}},v=function(t,n,e){var o={};"object"==typeof t&&(o["Content-Type"]="application/json"),o=r({},o,e.response.headers),n.writeHead(e.response.status,o),n.write(t),n.end()},p=function(t,n,r){try{var e=!1,o=f(t,(function(t){return Promise.resolve(t(n)).then((function(t){var o=function(){if(void 0===t||!0===t);else{var o=function(){if(!1!==t)return Promise.resolve(v(t,r,n)).then((function(){e=!0}));e=!0}();if(o&&o.then)return o.then((function(){}))}}();if(o&&o.then)return o.then((function(){}))}))}),(function(){return e}));return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},y=function(){function t(t){this.controller=t,this.server=n.createServer(this.controller.router.mount())}return t.prototype.mount=function(t,n){this.server.listen(t,n)},t}();exports.Context=i,exports.Controller=function(t){this.router=t},exports.Router=h,exports.Server=y;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("url"),r=require("http");function n(){return(n=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var o={type:"text/plain",status:404,headers:{}},i=function(){function t(t){var r=this;this.raw=t.raw,this.data={},this.response=n({},o),this.request=t,this.headers={get:function(t){return r.request.headers[t.toLowerCase()]},set:function(t,n){r.response.headers[t]=n}}}return t.prototype.status=function(t){return this.response.status=t,this},t}();const u=function(){function t(){}return t.prototype.then=function(r,n){const e=new t,o=this.s;if(o){const t=1&o?r:n;if(t){try{s(e,1,t(this.v))}catch(t){s(e,2,t)}return e}return this}return this.o=function(t){try{const o=t.v;1&t.s?s(e,1,r?r(o):o):n?s(e,1,n(o)):s(e,2,o)}catch(t){s(e,2,t)}},e},t}();function s(t,r,n){if(!t.s){if(n instanceof u){if(!n.s)return void(n.o=s.bind(null,t,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(s.bind(null,t,r),s.bind(null,t,2));t.s=r,t.v=n;const e=t.o;e&&e(t)}}function a(t){return t instanceof u&&1&t.s}const c="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function f(t,r,n){if("function"==typeof t[c]){var e,o,i,f=t[c]();if(function t(c){try{for(;!((e=f.next()).done||n&&n());)if((c=r(e.value))&&c.then){if(!a(c))return void c.then(t,i||(i=s.bind(null,o=new u,2)));c=c.v}o?s(o,1,c):o=c}catch(t){s(o||(o=new u),2,t)}}(),f.return){var h=function(t){try{e.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(h,(function(t){throw h(t)}));h()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],v=0;v<t.length;v++)l.push(t[v]);return function(t,r,n){var e,o,i=-1;return function c(f){try{for(;++i<t.length&&(!n||!n());)if((f=r(i))&&f.then){if(!a(f))return void f.then(c,o||(o=s.bind(null,e=new u,2)));f=f.v}e?s(e,1,f):e=f}catch(t){s(e||(e=new u),2,t)}}(),e}(l,(function(t){return r(l[t])}),n)}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var h=function(){function r(){this.routes=[]}var n=r.prototype;return n.route=function(t,r){this.routes.push({path:t,routes:r})},n.mount=function(){var r=this;return function(n,o){try{var i=(u=t.parse(n.url||"/").pathname||"",s={path:"*",routes:{all:function(t){try{return t.status(404),Promise.resolve("404 Not Found")}catch(t){return Promise.reject(t)}}}},function(t){for(var r,n=[],o=function(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,void 0):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(t);!(r=o()).done;){var i=r.value;"*"===i.path?n.unshift(i):i.path.startsWith("/")&&n.push(i)}return n}(r.routes).some((function(t){return("*"===t.path||t.path===u)&&(s=t,!0)})),s);return Promise.resolve(l(i,n,o)).then((function(){}))}catch(t){return Promise.reject(t)}var u,s}},r}(),l=function(t,r,n){try{var e=function(t){return{headers:t.headers,raw:t}}(r),o=new i(e);return Promise.resolve(f(Object.entries(t.routes),(function(t){var e=t[0],i=t[1],u=function(){var t;if(e===(null===(t=r.method)||void 0===t?void 0:t.toLowerCase())){var u=function(){if(i instanceof Array)return Promise.resolve(p(i,o,n)).then((function(){}));var t=function(){if(null!=i)return Promise.resolve(i(o)).then((function(t){return Promise.resolve(v(t,n,o)).then((function(){}))}))}();return t&&t.then?t.then((function(){})):void 0}();if(u&&u.then)return u.then((function(){}))}}();if(u&&u.then)return u.then((function(){}))})))}catch(t){return Promise.reject(t)}},v=function(t,r,e){var o={};"object"==typeof t&&(o["Content-Type"]="application/json"),o=n({},o,e.response.headers),r.writeHead(e.response.status,o),r.write(t),r.end()},p=function(t,r,n){try{var e=!1,o=f(t,(function(t){return Promise.resolve(t(r)).then((function(t){var o=function(){if(void 0===t||!0===t);else{var o=function(){if(!1!==t)return Promise.resolve(v(t,n,r)).then((function(){e=!0}));e=!0}();if(o&&o.then)return o.then((function(){}))}}();if(o&&o.then)return o.then((function(){}))}))}),(function(){return e}));return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},y=function(){function t(t){this.controller=t,this.server=r.createServer(this.controller.router.mount())}return t.prototype.mount=function(t,r){this.server.listen(t,r)},t}();exports.Context=i,exports.Controller=function(t){this.router=t},exports.Router=h,exports.Server=y;
//# sourceMappingURL=core.cjs.production.min.js.map

@@ -73,2 +73,3 @@ import { parse } from 'url';

this.raw = request.raw;
this.data = {}; // Makes sure that the defaultResponse is not mutated

@@ -298,3 +299,4 @@

return {
headers: request.headers
headers: request.headers,
raw: request
};

@@ -301,0 +303,0 @@ };

{
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -1,6 +0,6 @@

import { IncomingHttpHeaders } from 'http';
import { IncomingHttpHeaders, IncomingMessage } from 'http';
import { MimeTypes, UnknownObject } from './utils/types';
type HeadersUnion = string | number | string[]
export type HeadersObject = UnknownObject<HeadersUnion>
export type HeadersObject = UnknownObject<HeadersUnion>

@@ -14,2 +14,3 @@ export interface ContextResponse {

headers: IncomingHttpHeaders
raw: IncomingMessage
}

@@ -31,5 +32,8 @@ const defaultResponse: ContextResponse = {

readonly raw: IncomingMessage;
headers: Headers
data: UnknownObject
constructor(request: ContextRequest) {
this.raw = request.raw;
this.data = {};

@@ -36,0 +40,0 @@ // Makes sure that the defaultResponse is not mutated

@@ -38,4 +38,5 @@ import type { Context, ContextRequest } from '../context';

return {
headers: request.headers
headers: request.headers,
raw: request
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc