kdesign-ui
Version:
kd is from company of klx, it provide quickly genarator company inner business front structure
30 lines (29 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var express_1 = tslib_1.__importDefault(require("express"));
var body_parser_1 = tslib_1.__importDefault(require("body-parser"));
var core_1 = tslib_1.__importDefault(require("./generate/core"));
var shelljs_1 = tslib_1.__importDefault(require("shelljs"));
var fs_1 = tslib_1.__importDefault(require("fs"));
var app = express_1.default();
var port = 4000;
app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("Access-Control-Allow-Credentials", true);
res.header("X-Powered-By", ' 4.2.1');
next();
});
app.use(body_parser_1.default.urlencoded({ extended: false }));
app.use(body_parser_1.default.json());
app.post('/generate', function (req, res) {
var data = core_1.default(req.body);
shelljs_1.default.touch('./index.vue');
fs_1.default.writeFileSync(process.cwd() + '/index.vue', data);
res.download(process.cwd() + '/index.vue', (req.body.id || 'index') + ".vue");
});
app.listen(port, function () {
console.log(port + " port is runing");
});