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

@campkit/core

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@campkit/core - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

7

dist/campkit-core.cjs.development.js

@@ -227,2 +227,7 @@ 'use strict';

} = _this2;
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS'
};
return _catch(function () {

@@ -239,2 +244,3 @@ const httpRequest = mapApiGatewayEventToHttpRequest({

const res = _this2.handleLambdaResponse({
headers: corsHeaders,
statusCode: 200,

@@ -250,2 +256,3 @@ body: JSON.stringify(responseToHttpRequest)

const res = _this2.handleLambdaResponse({
headers: corsHeaders,
statusCode: 502,

@@ -252,0 +259,0 @@ body: JSON.stringify({

2

dist/campkit-core.cjs.production.min.js

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

"use strict";require("reflect-metadata");var e=require("url"),t=require("@campkit/common"),r=require("@campkit/rest"),n=require("@campkit/event");function o(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function s(e){return Reflect.getMetadata("app",e)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));class a{constructor(e){this.appInstance=e.module}runRestApplication(e){try{const t=this,{appInstance:n}=t,o=s(n);if(!o.restController)throw new Error("need a rest controller to handle http requests");const a=r.getRestControllerMetadata(o.restController);return Promise.resolve(a.run(e)).then((function(e){if(!e)throw Error("Controller did not respond");return e}))}catch(e){return Promise.reject(e)}}handleRestApplicationResponse(e,t=!1){const{appInstance:n}=this,o=s(n).restController,a=r.getRestControllerMetadata(o);return t?o.onError?o.onError(e):a.onError(e):o.onSuccess?o.onSuccess(e):a.onSuccess(e)}runEventApplication(e){try{const t=this,{appInstance:r}=t,o=s(r);if(!o.eventController)throw new Error("need a event controller to handle event requests");const a=n.getEventControllerMetadata(o.eventController);return Promise.resolve(a.run(e)).then((function(e){if(!e)throw Error("Event controller did not respond");return e}))}catch(e){return Promise.reject(e)}}}const c=new t.Logger("AWSLambdaApplication");class i extends a{constructor(e){super({module:e.module}),this.event=e.httpAdapter.event,this.context=e.httpAdapter.context}handleRequest(){try{const e=this,{event:t}=e;try{switch(e.determineLambdaInvocationType(t)){case"http":return e.handleHttpRequest();case"authorizer":return e.handleAuthorizerRequest();case"event":return e.handleEventRequest();default:throw new Error("Lambda event unknown")}}catch(e){c.log(e)}}catch(e){return Promise.reject(e)}}handleLambdaResponse(e){const{statusCode:t=200,headers:r={},body:n}=e;return{statusCode:t,headers:r,body:n}}determineLambdaInvocationType(e){return e.hasOwnProperty("authorizationToken")?"authorizer":e.hasOwnProperty("triggerSource")?"event":"http"}handleHttpRequest(){try{const e=this,{event:t,context:r}=e;return o((function(){const n=function({event:e,context:t}){const r=Object.assign({"Content-Length":0},e.headers);if(e.body&&!r["Content-Length"]){const t=l(e);Object.keys(t).length&&(r["Content-Length"]=Buffer.byteLength(JSON.stringify(t)))}const n=JSON.parse(JSON.stringify(e));return delete n.body,r["x-apigateway-event"]=encodeURIComponent(JSON.stringify(n)),r["x-apigateway-context"]=encodeURIComponent(JSON.stringify(t)),{method:e.httpMethod,path:u(e),headers:r,body:l(e)}}({event:t,context:r});return Promise.resolve(e.runRestApplication(n)).then((function(t){if(!t)throw new Error("no response from the http request");const r=e.handleLambdaResponse({statusCode:200,body:JSON.stringify(t)});return e.handleRestApplicationResponse(r)}))}),(function(t){c.log(t,"handleHttpRequest");const r=e.handleLambdaResponse({statusCode:502,body:JSON.stringify({error:t.message,type:t.name})});return e.handleRestApplicationResponse(r,!0)}))}catch(e){return Promise.reject(e)}}handleAuthorizerRequest(){}handleEventRequest(){try{const e=this,{event:t}=e;return o((function(){return Promise.resolve(e.runEventApplication(t)).then((function(e){if(!e)throw new Error("no response from the event request");return e}))}),(function(e){return c.log(e,"handleEventRequest"),e}))}catch(e){return Promise.reject(e)}}}function u(t){return e.format({pathname:t.path,query:t.queryStringParameters})}function l(e){return e.body?e.body:{}}class d{create(e,t,r={provider:"aws"}){try{const{provider:n}=r;if("aws"===n)return new i({module:e,httpAdapter:t}).handleRequest();throw Error("currently only aws lambda events are supported")}catch(e){return Promise.reject(e)}}}const p=new d;exports.App=function(e){return t=>{Reflect.defineMetadata("app",e,t)}},exports.CampkitFactory=p,exports.getAppMetadata=s;
"use strict";require("reflect-metadata");var e=require("url"),t=require("@campkit/common"),r=require("@campkit/rest"),n=require("@campkit/event");function o(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function s(e){return Reflect.getMetadata("app",e)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));class a{constructor(e){this.appInstance=e.module}runRestApplication(e){try{const t=this,{appInstance:n}=t,o=s(n);if(!o.restController)throw new Error("need a rest controller to handle http requests");const a=r.getRestControllerMetadata(o.restController);return Promise.resolve(a.run(e)).then((function(e){if(!e)throw Error("Controller did not respond");return e}))}catch(e){return Promise.reject(e)}}handleRestApplicationResponse(e,t=!1){const{appInstance:n}=this,o=s(n).restController,a=r.getRestControllerMetadata(o);return t?o.onError?o.onError(e):a.onError(e):o.onSuccess?o.onSuccess(e):a.onSuccess(e)}runEventApplication(e){try{const t=this,{appInstance:r}=t,o=s(r);if(!o.eventController)throw new Error("need a event controller to handle event requests");const a=n.getEventControllerMetadata(o.eventController);return Promise.resolve(a.run(e)).then((function(e){if(!e)throw Error("Event controller did not respond");return e}))}catch(e){return Promise.reject(e)}}}const c=new t.Logger("AWSLambdaApplication");class i extends a{constructor(e){super({module:e.module}),this.event=e.httpAdapter.event,this.context=e.httpAdapter.context}handleRequest(){try{const e=this,{event:t}=e;try{switch(e.determineLambdaInvocationType(t)){case"http":return e.handleHttpRequest();case"authorizer":return e.handleAuthorizerRequest();case"event":return e.handleEventRequest();default:throw new Error("Lambda event unknown")}}catch(e){c.log(e)}}catch(e){return Promise.reject(e)}}handleLambdaResponse(e){const{statusCode:t=200,headers:r={},body:n}=e;return{statusCode:t,headers:r,body:n}}determineLambdaInvocationType(e){return e.hasOwnProperty("authorizationToken")?"authorizer":e.hasOwnProperty("triggerSource")?"event":"http"}handleHttpRequest(){try{const e=this,{event:t,context:r}=e,n={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":!0,"Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS"};return o((function(){const o=function({event:e,context:t}){const r=Object.assign({"Content-Length":0},e.headers);if(e.body&&!r["Content-Length"]){const t=l(e);Object.keys(t).length&&(r["Content-Length"]=Buffer.byteLength(JSON.stringify(t)))}const n=JSON.parse(JSON.stringify(e));return delete n.body,r["x-apigateway-event"]=encodeURIComponent(JSON.stringify(n)),r["x-apigateway-context"]=encodeURIComponent(JSON.stringify(t)),{method:e.httpMethod,path:u(e),headers:r,body:l(e)}}({event:t,context:r});return Promise.resolve(e.runRestApplication(o)).then((function(t){if(!t)throw new Error("no response from the http request");const r=e.handleLambdaResponse({headers:n,statusCode:200,body:JSON.stringify(t)});return e.handleRestApplicationResponse(r)}))}),(function(t){c.log(t,"handleHttpRequest");const r=e.handleLambdaResponse({headers:n,statusCode:502,body:JSON.stringify({error:t.message,type:t.name})});return e.handleRestApplicationResponse(r,!0)}))}catch(e){return Promise.reject(e)}}handleAuthorizerRequest(){}handleEventRequest(){try{const e=this,{event:t}=e;return o((function(){return Promise.resolve(e.runEventApplication(t)).then((function(e){if(!e)throw new Error("no response from the event request");return e}))}),(function(e){return c.log(e,"handleEventRequest"),e}))}catch(e){return Promise.reject(e)}}}function u(t){return e.format({pathname:t.path,query:t.queryStringParameters})}function l(e){return e.body?e.body:{}}class d{create(e,t,r={provider:"aws"}){try{const{provider:n}=r;if("aws"===n)return new i({module:e,httpAdapter:t}).handleRequest();throw Error("currently only aws lambda events are supported")}catch(e){return Promise.reject(e)}}}const h=new d;exports.App=function(e){return t=>{Reflect.defineMetadata("app",e,t)}},exports.CampkitFactory=h,exports.getAppMetadata=s;
//# sourceMappingURL=campkit-core.cjs.production.min.js.map

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

import"reflect-metadata";import{format as e}from"url";import{Logger as t}from"@campkit/common";import{getRestControllerMetadata as r}from"@campkit/rest";import{getEventControllerMetadata as n}from"@campkit/event";function o(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function s(e){return t=>{Reflect.defineMetadata("app",e,t)}}function a(e){return Reflect.getMetadata("app",e)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));class c{constructor(e){this.appInstance=e.module}runRestApplication(e){try{const t=this,{appInstance:n}=t,o=a(n);if(!o.restController)throw new Error("need a rest controller to handle http requests");const s=r(o.restController);return Promise.resolve(s.run(e)).then((function(e){if(!e)throw Error("Controller did not respond");return e}))}catch(e){return Promise.reject(e)}}handleRestApplicationResponse(e,t=!1){const{appInstance:n}=this,o=a(n).restController,s=r(o);return t?o.onError?o.onError(e):s.onError(e):o.onSuccess?o.onSuccess(e):s.onSuccess(e)}runEventApplication(e){try{const t=this,{appInstance:r}=t,o=a(r);if(!o.eventController)throw new Error("need a event controller to handle event requests");const s=n(o.eventController);return Promise.resolve(s.run(e)).then((function(e){if(!e)throw Error("Event controller did not respond");return e}))}catch(e){return Promise.reject(e)}}}const i=new t("AWSLambdaApplication");class u extends c{constructor(e){super({module:e.module}),this.event=e.httpAdapter.event,this.context=e.httpAdapter.context}handleRequest(){try{const e=this,{event:t}=e;try{switch(e.determineLambdaInvocationType(t)){case"http":return e.handleHttpRequest();case"authorizer":return e.handleAuthorizerRequest();case"event":return e.handleEventRequest();default:throw new Error("Lambda event unknown")}}catch(e){i.log(e)}}catch(e){return Promise.reject(e)}}handleLambdaResponse(e){const{statusCode:t=200,headers:r={},body:n}=e;return{statusCode:t,headers:r,body:n}}determineLambdaInvocationType(e){return e.hasOwnProperty("authorizationToken")?"authorizer":e.hasOwnProperty("triggerSource")?"event":"http"}handleHttpRequest(){try{const e=this,{event:t,context:r}=e;return o((function(){const n=function({event:e,context:t}){const r=Object.assign({"Content-Length":0},e.headers);if(e.body&&!r["Content-Length"]){const t=p(e);Object.keys(t).length&&(r["Content-Length"]=Buffer.byteLength(JSON.stringify(t)))}const n=JSON.parse(JSON.stringify(e));return delete n.body,r["x-apigateway-event"]=encodeURIComponent(JSON.stringify(n)),r["x-apigateway-context"]=encodeURIComponent(JSON.stringify(t)),{method:e.httpMethod,path:h(e),headers:r,body:p(e)}}({event:t,context:r});return Promise.resolve(e.runRestApplication(n)).then((function(t){if(!t)throw new Error("no response from the http request");const r=e.handleLambdaResponse({statusCode:200,body:JSON.stringify(t)});return e.handleRestApplicationResponse(r)}))}),(function(t){i.log(t,"handleHttpRequest");const r=e.handleLambdaResponse({statusCode:502,body:JSON.stringify({error:t.message,type:t.name})});return e.handleRestApplicationResponse(r,!0)}))}catch(e){return Promise.reject(e)}}handleAuthorizerRequest(){}handleEventRequest(){try{const e=this,{event:t}=e;return o((function(){return Promise.resolve(e.runEventApplication(t)).then((function(e){if(!e)throw new Error("no response from the event request");return e}))}),(function(e){return i.log(e,"handleEventRequest"),e}))}catch(e){return Promise.reject(e)}}}function h(t){return e({pathname:t.path,query:t.queryStringParameters})}function p(e){return e.body?e.body:{}}class d{create(e,t,r={provider:"aws"}){try{const{provider:n}=r;if("aws"===n)return new u({module:e,httpAdapter:t}).handleRequest();throw Error("currently only aws lambda events are supported")}catch(e){return Promise.reject(e)}}}const l=new d;export{s as App,l as CampkitFactory,a as getAppMetadata};
import"reflect-metadata";import{format as e}from"url";import{Logger as t}from"@campkit/common";import{getRestControllerMetadata as r}from"@campkit/rest";import{getEventControllerMetadata as n}from"@campkit/event";function o(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function s(e){return t=>{Reflect.defineMetadata("app",e,t)}}function a(e){return Reflect.getMetadata("app",e)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));class c{constructor(e){this.appInstance=e.module}runRestApplication(e){try{const t=this,{appInstance:n}=t,o=a(n);if(!o.restController)throw new Error("need a rest controller to handle http requests");const s=r(o.restController);return Promise.resolve(s.run(e)).then((function(e){if(!e)throw Error("Controller did not respond");return e}))}catch(e){return Promise.reject(e)}}handleRestApplicationResponse(e,t=!1){const{appInstance:n}=this,o=a(n).restController,s=r(o);return t?o.onError?o.onError(e):s.onError(e):o.onSuccess?o.onSuccess(e):s.onSuccess(e)}runEventApplication(e){try{const t=this,{appInstance:r}=t,o=a(r);if(!o.eventController)throw new Error("need a event controller to handle event requests");const s=n(o.eventController);return Promise.resolve(s.run(e)).then((function(e){if(!e)throw Error("Event controller did not respond");return e}))}catch(e){return Promise.reject(e)}}}const i=new t("AWSLambdaApplication");class u extends c{constructor(e){super({module:e.module}),this.event=e.httpAdapter.event,this.context=e.httpAdapter.context}handleRequest(){try{const e=this,{event:t}=e;try{switch(e.determineLambdaInvocationType(t)){case"http":return e.handleHttpRequest();case"authorizer":return e.handleAuthorizerRequest();case"event":return e.handleEventRequest();default:throw new Error("Lambda event unknown")}}catch(e){i.log(e)}}catch(e){return Promise.reject(e)}}handleLambdaResponse(e){const{statusCode:t=200,headers:r={},body:n}=e;return{statusCode:t,headers:r,body:n}}determineLambdaInvocationType(e){return e.hasOwnProperty("authorizationToken")?"authorizer":e.hasOwnProperty("triggerSource")?"event":"http"}handleHttpRequest(){try{const e=this,{event:t,context:r}=e,n={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":!0,"Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS"};return o((function(){const o=function({event:e,context:t}){const r=Object.assign({"Content-Length":0},e.headers);if(e.body&&!r["Content-Length"]){const t=h(e);Object.keys(t).length&&(r["Content-Length"]=Buffer.byteLength(JSON.stringify(t)))}const n=JSON.parse(JSON.stringify(e));return delete n.body,r["x-apigateway-event"]=encodeURIComponent(JSON.stringify(n)),r["x-apigateway-context"]=encodeURIComponent(JSON.stringify(t)),{method:e.httpMethod,path:l(e),headers:r,body:h(e)}}({event:t,context:r});return Promise.resolve(e.runRestApplication(o)).then((function(t){if(!t)throw new Error("no response from the http request");const r=e.handleLambdaResponse({headers:n,statusCode:200,body:JSON.stringify(t)});return e.handleRestApplicationResponse(r)}))}),(function(t){i.log(t,"handleHttpRequest");const r=e.handleLambdaResponse({headers:n,statusCode:502,body:JSON.stringify({error:t.message,type:t.name})});return e.handleRestApplicationResponse(r,!0)}))}catch(e){return Promise.reject(e)}}handleAuthorizerRequest(){}handleEventRequest(){try{const e=this,{event:t}=e;return o((function(){return Promise.resolve(e.runEventApplication(t)).then((function(e){if(!e)throw new Error("no response from the event request");return e}))}),(function(e){return i.log(e,"handleEventRequest"),e}))}catch(e){return Promise.reject(e)}}}function l(t){return e({pathname:t.path,query:t.queryStringParameters})}function h(e){return e.body?e.body:{}}class d{create(e,t,r={provider:"aws"}){try{const{provider:n}=r;if("aws"===n)return new u({module:e,httpAdapter:t}).handleRequest();throw Error("currently only aws lambda events are supported")}catch(e){return Promise.reject(e)}}}const p=new d;export{s as App,p as CampkitFactory,a as getAppMetadata};
//# sourceMappingURL=campkit-core.esm.production.min.js.map
{
"name": "@campkit/core",
"version": "0.0.9",
"version": "0.0.10",
"publishConfig": {

@@ -60,3 +60,3 @@ "access": "public"

},
"gitHead": "49bb812bc18acd00115be00583048d1c195a7f0e"
"gitHead": "e0787dce04288144dbf10bea03f2069ae24eec5b"
}

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