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

maishu-chitu-scaffold

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maishu-chitu-scaffold - npm Package Compare versions

Comparing version 1.16.0 to 1.17.0

demo/static/preivew.html

50

controllers/home.js

@@ -11,6 +11,4 @@ "use strict";

};
var HomeController_1;
Object.defineProperty(exports, "__esModule", { value: true });
const maishu_node_mvc_1 = require("maishu-node-mvc");
const path = require("path");
const fs = require("fs");

@@ -22,7 +20,27 @@ const errors_1 = require("../errors");

const maishu_toolkit_1 = require("maishu-toolkit");
let htmlPath = path.join(__dirname, "../static/index.html");
let HomeController = HomeController_1 = class HomeController {
g(ctx) {
if (!fs.existsSync(htmlPath))
throw errors_1.errors.physicalPathNotExists(htmlPath);
// let htmlPath = path.join(__dirname, "../static/index.html");
let pgaeAction = maishu_node_mvc_1.action(function (virtualPath, ctx) {
let root = typeof ctx.rootDirectory == "string" ? new maishu_node_mvc_1.VirtualDirectory(ctx.rootDirectory) : ctx.rootDirectory;
let websiteConfig = HomeController.loadWebsiteConfig(root);
let routers = websiteConfig.routers || {};
let keys = Object.keys(routers);
for (let i = 0; i < keys.length; i++) {
let p = new UrlPattern(keys[i]);
let m = p.match(virtualPath);
if (m) {
Object.assign(m, routers[keys[i]]);
m.html = m.html || "index.html";
return m;
}
}
return null;
});
let HomeController = class HomeController {
g(ctx, d) {
console.log(d);
let staticDir = ctx.rootDirectory.findDirectory("static");
console.assert(staticDir != null);
let htmlPath = staticDir === null || staticDir === void 0 ? void 0 : staticDir.findFile(d.html);
if (!htmlPath)
throw errors_1.errors.physicalPathNotExists(d.html);
let buffer = fs.readFileSync(htmlPath);

@@ -69,20 +87,8 @@ let html = buffer.toString();

__decorate([
maishu_node_mvc_1.action((virtualPath, ctx) => {
let root = typeof ctx.rootDirectory == "string" ? new maishu_node_mvc_1.VirtualDirectory(ctx.rootDirectory) : ctx.rootDirectory;
let websiteConfig = HomeController_1.loadWebsiteConfig(root);
let routers = websiteConfig.routers || {};
let keys = Object.keys(routers);
for (let i = 0; i < keys.length; i++) {
let p = new UrlPattern(keys[i]);
let m = p.match(virtualPath);
if (m)
return m;
}
return null;
}),
__param(0, maishu_node_mvc_1.serverContext)
pgaeAction,
__param(0, maishu_node_mvc_1.serverContext), __param(1, maishu_node_mvc_1.routeData)
], HomeController.prototype, "g", null);
HomeController = HomeController_1 = __decorate([
HomeController = __decorate([
maishu_node_mvc_1.controller("/")
], HomeController);
exports.default = HomeController;

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

import { controller, action, serverContext, ServerContext, ContentResult, VirtualDirectory } from "maishu-node-mvc";
import { controller, action, serverContext, ServerContext, ContentResult, VirtualDirectory, routeData } from "maishu-node-mvc";
import * as path from "path";

@@ -12,4 +12,23 @@ import * as fs from "fs";

let htmlPath = path.join(__dirname, "../static/index.html");
// let htmlPath = path.join(__dirname, "../static/index.html");
let pgaeAction = action(function (virtualPath, ctx) {
let root = typeof ctx.rootDirectory == "string" ? new VirtualDirectory(ctx.rootDirectory) : ctx.rootDirectory;
let websiteConfig = HomeController.loadWebsiteConfig(root);
let routers = websiteConfig.routers || {};
let keys = Object.keys(routers);
for (let i = 0; i < keys.length; i++) {
let p = new UrlPattern(keys[i]);
let m = p.match(virtualPath);
if (m) {
Object.assign(m, routers[keys[i]]);
m.html = m.html || "index.html";
return m;
}
}
return null;
})
@controller("/")

@@ -19,19 +38,13 @@ export default class HomeController {

@action((virtualPath, ctx) => {
let root = typeof ctx.rootDirectory == "string" ? new VirtualDirectory(ctx.rootDirectory) : ctx.rootDirectory;
let websiteConfig = HomeController.loadWebsiteConfig(root);
let routers = websiteConfig.routers || {};
let keys = Object.keys(routers);
for (let i = 0; i < keys.length; i++) {
let p = new UrlPattern(keys[i]);
let m = p.match(virtualPath);
if (m)
return m;
}
return null;
})
g(@serverContext ctx: ServerContext) {
if (!fs.existsSync(htmlPath))
throw errors.physicalPathNotExists(htmlPath);
@pgaeAction
g(@serverContext ctx: ServerContext, @routeData d: { html: string }) {
console.log(d);
let staticDir = ctx.rootDirectory.findDirectory("static");
console.assert(staticDir != null);
let htmlPath = staticDir?.findFile(d.html);
if (!htmlPath)
throw errors.physicalPathNotExists(d.html);
let buffer = fs.readFileSync(htmlPath);

@@ -38,0 +51,0 @@ let html = buffer.toString();

const { sourceVirtualPaths } = require("../index");
let fileVirtualPaths = sourceVirtualPaths(__dirname);
const m = require("maishu-node-mvc");
module.exports = {

@@ -13,3 +15,3 @@ "port": 5262,

}
}
},
}

@@ -29,3 +29,3 @@ {

"name": "maishu-chitu-scaffold",
"version": "1.16.0"
"version": "1.17.0"
}

@@ -15,2 +15,6 @@ export interface WebsiteConfig {

}
export interface ContextData {
}

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