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

@sumor/app

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumor/app - npm Package Compare versions

Comparing version 17.0.5 to 17.0.6

2

index.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Sumor_App",[],t):"object"==typeof exports?exports.Sumor_App=t():e.Sumor_App=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=require("@sumor/base")},function(e,t){e.exports=require("http")},function(e,t){e.exports=require("express")},function(e,t,r){"use strict";r.r(t),r.d(t,"App",(function(){return s})),r.d(t,"_meta",(function(){return p}));var n=r(0),o=r.n(n),a=r(1),u=r.n(a),c=r(2),i=r.n(c);class s{constructor(){this.program={}}handle(e){for(let t in e._meta.program){const r=t,n=e._meta.program[t],a=o.a.object.get(e,r);this.program[r]={meta:n,handler:a}}}async serve(e){await(async(e,t)=>{const r=i()(),n=u.a.createServer(r),a="http://localhost:"+e;for(let e in t){const n="/api/"+e.replace(/\./g,"/");console.log(`${a}${n}`),r.all(n,(async function(r,n,a){const u={};Object.assign(u,r.query,r.body);const c=o.a.caller(t[e].handler,t[e].meta,{});let i;try{i={code:"OK",data:await c(u)}}catch(e){i={code:e.code||"INTERNAL_ERROR",message:e.message}}n.send(i)}))}n.listen(e,e=>{console.log("应用已运行在:"+a)})})(e,this.program)}}var p={program:{App:{}}};t.default={App:s,_meta:p}}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Sumor_App",[],t):"object"==typeof exports?exports.Sumor_App=t():e.Sumor_App=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=require("@sumor/utils")},function(e,t){e.exports=require("@sumor/base")},function(e,t){e.exports=require("selfsigned")},function(e,t){e.exports=require("http")},function(e,t){e.exports=require("express")},function(e,t){e.exports=require("spdy")},function(e,t,r){"use strict";r.r(t),r.d(t,"App",(function(){return g})),r.d(t,"_meta",(function(){return h}));var o=r(1),n=r.n(o),a=r(0),i=r.n(a),s=r(2),c=r.n(s),l=async(e,t)=>{const r={key:e+"/domain.key",cert:e+"/domain.cer",ca:e+"/ca.cer"};let o=await i.a.file.exists(r.key)&&await i.a.file.exists(r.cert);if(o||(await(async(e,t)=>{t=t||"selfsigned";const r=await new Promise((e,r)=>{c.a.generate([{name:"commonName",value:t}],{days:3650},(function(t,o){t?r(t):e(o)}))});r.private&&await i.a.file.writeFile(e.key,r.private),r.cert&&await i.a.file.writeFile(e.cert,r.cert)})(r,t),o=!0),o){const e=await i.a.file.readFile(r.key),t=await i.a.file.readFile(r.cert);let o;return await i.a.file.exists(r.ca)&&(o=await i.a.file.readFile(r.ca)),{key:e,cert:t,ca:o}}},p=r(3),u=r.n(p),f=r(4),d=r.n(f),m=r(5),y=r.n(m);class g{constructor(e){this.root=e||process.cwd(),this.program={}}async init(){this.runtime||(this.runtime=await(async e=>{e=e||process.cwd();const t={};t.config=await i.a.file.readJson(e+"/config.json")||{},t.path={ssl:e+"/ssl"},t.ssl=await l(t.path.ssl),t.ssl?t.protocol=t.config.protocol||"https":t.protocol="http",t.domain=t.config.domain||"localhost",t.port=t.config.port||("https"===t.protocol?443:80);const r="http"===t.protocol&&80===t.port||"https"===t.protocol&&443===t.port?"":":"+t.port;return t.origin=`${t.protocol}://${t.domain}${r}`,t})(this.root))}handle(e){for(let t in e._meta.program){const r=t,o=e._meta.program[t],a=n.a.object.get(e,r);this.program[r]={meta:o,handler:a}}}async serve(){await this.init(),await(async(e,t)=>{const r=d()();for(let o in t){const a="/api/"+o.replace(/\./g,"/");console.log(`${e.origin}${a}`),r.all(a,(async function(e,r,a){const i={};Object.assign(i,e.query,e.body);const s=n.a.caller(t[o].handler,t[o].meta,{});let c;try{c={code:"OK",data:await s(i)}}catch(e){c={code:e.code||"INTERNAL_ERROR",message:e.message}}r.send(c)}))}const o=()=>{console.log("应用已运行在:"+e.origin)};if(e.ssl){y.a.createServer(e.ssl,r).listen(e.port,o)}else{u.a.createServer(r).listen(e.port,o)}})(this.runtime,this.program)}}var h={program:{App:{name:"轻呈云应用",desc:"构建轻呈云应用",arguments:"path",isClass:!0,parameters:{path:{name:"应用目录"}}}}};t.default={App:g,_meta:h}}])}));
{
"name": "@sumor/app",
"version": "17.0.5",
"version": "17.0.6",
"dependencies": {
"@sumor/base": "^17.0.8",
"@sumor/utils": "^17.0.3",
"@sumor/utils": "^17.0.4",
"express": "^4.17.1",
"spdy": "^4.0.2"
"spdy": "^4.0.2",
"selfsigned": "^1.10.7"
}
}

@@ -27,4 +27,65 @@ # @sumor/app

## 构建应用
```javascript
const {App} = require("@sumor/app");
const app = new App();
app.handle({
_meta:{
program:{
"say.hello.world":{
parameters:{
p1:{
name:"参数1",
type:"string",
length:3
}
}
}
}
},
say:{
hello:{
world:(parameters,context)=>{
return parameters.p1;
}
}
}
});
app.serve();
// 然后您就可以通过运行提示访问您的应用了
```
## SSL 临时证书设置
在开发阶段,如您无法提供有效证书,将会自动生成临时证书。
临时证书是不被浏览器信任的,需要按照以下步骤完成证书启用,以达到调试目的。
请注意,该方案仅使用于本地测试环境,请勿用于正式用途
### 1. 下载证书
####windows用户
可跳过该步骤
####macOS用户
* 打开浏览器访问测试站点
* 右键菜单中选中检查按钮```inspect```或点击键盘F12
* 选中安全页签```Security```
* 点击查看证书```View certificate```
* 拖拽证书图标到本地即可下载证书(大的证书图标)
* 双击本地文件打开该证书
* 在自动打开的证书列表中找到该证书并右键打开简介
* 选择信任页签```Trust```
* 下拉框中选中始终信任
* 刷新浏览器测试站点页面
### 2. 允许使用临时证书
* 打开测试站点
* 点击```高级```
* 点击```继续前往XXX(不安全)```
## 接口文档
### App(parameters)
### new App(path) 轻呈云应用
构建轻呈云应用
###### 类型
###### 参数
* `path` __应用目录__
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