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

snec-mvc-framework

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snec-mvc-framework - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

34

app.js
const Koa = require('koa');
const session = require('koa-session');
const debug = require('debug')('snec-mvc-framework:app');
const path = require('path');

@@ -37,3 +38,34 @@ const middlewares = require('./middlewares');

// or if you prefer all default config, just use => app.use(session(app));
// this.use(async (ctx, next) => {
// console.log('ctx.request.url', ctx.request.url);
// await next();
// });
this.use(async (ctx, next) => {
if (ctx.request.url.indexOf('injection') >= 0 && ctx.request.url.indexOf('globalInjection') == -1 && ctx.request.header.referer !== undefined) {
debug('原ctx.request.url', ctx.request.url);
let str = ctx.request.header.referer;
let url = '';
let params = '';
let idx = -1;
let count = 0;
for (let i = 0; i < str.length; i++) {
if (str[i] == '/') {
if (count === 2) {
idx = i;
break;
} else {
count++
}
}
}
str = str.slice(idx);
url = str;
ctx.request.url = '/injection' + url;
debug('现ctx.request.url', ctx.request.url);
}
await next();
});
this.initController();

@@ -40,0 +72,0 @@ this.initService();

38

loader/service.js

@@ -46,41 +46,3 @@ const path = require('path');

// constructor(servicePath) {
// this.loadFiles(servicePath).forEach(filepath => {
// const basename = path.basename(filepath);
// const extname = path.extname(filepath);
// const fileName = basename.substring(0, basename.indexOf(extname));
// if (serviceMap.get(fileName)) {
// throw new Error(`servies文件夹下有${fileName}文件同名!`)
// } else {
// serviceMap.set(fileName, filepath);
// }
// const _this = this;
// Object.defineProperty(services, fileName, {
// get() {
// if (serviceMap.get(fileName)) {
// if (!serviceClass.get(fileName)) {
// // 只有用到某个service才require这个文件
// const S = require(serviceMap.get(fileName));
// serviceClass.set(fileName, S);
// }
// const S = serviceClass.get(fileName);
// // 每次new一个新的Service实例
// // 传入context
// let newS = new S(_this.context);
// Object.defineProperty(newS, 'service', {
// get() {
// return services;
// }
// });
// return newS;
// }
// }
// })
// });
// }
function loadFiles(target) {

@@ -87,0 +49,0 @@ const files = glob.sync(`${target}/**/*.js`)

const Router = require('koa-router');
const debug = require('debug')('snec-mvc-framework:router');
const koaCompose = require('koa-compose')

@@ -45,2 +46,3 @@

// router.get('/tc', fn1, fn2, fn3);
debug('router.'+method+'(\t'+args[0]+' ,\t '+controller+')');
router[method].apply(router, args)

@@ -47,0 +49,0 @@ }

{
"name": "snec-mvc-framework",
"version": "1.0.12",
"version": "1.0.13",
"description": "mvc framework for koa",

@@ -5,0 +5,0 @@ "main": "index.js",

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