New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mrtujiawei/bin

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mrtujiawei/bin - npm Package Compare versions

Comparing version 1.2.6 to 1.2.8

40

dist/server.js

@@ -11,3 +11,3 @@ #!/bin/env node

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "koa", "koa-static", "koa-router", "koa-bodyparser", "@mrtujiawei/node-utils", "./utils"], factory);
define(["require", "exports", "https", "fs", "path", "koa", "koa-static", "koa-router", "koa-bodyparser", "@mrtujiawei/node-utils", "./utils"], factory);
}

@@ -17,2 +17,5 @@ })(function (require, exports) {

Object.defineProperty(exports, "__esModule", { value: true });
const https_1 = __importDefault(require("https"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const koa_1 = __importDefault(require("koa"));

@@ -24,6 +27,12 @@ const koa_static_1 = __importDefault(require("koa-static"));

const utils_1 = require("./utils");
let port = 3000;
if (process.argv[2] == '-p' && process.argv.length == 4) {
if (Number.isInteger(Number(process.argv[3]))) {
port = Number(process.argv[3]);
// 默认配置
const defaultConfig = {
port: 3000,
https: false,
};
let port = defaultConfig.port;
const argv = process.argv.slice(2);
if (argv[0] == '-p' && argv.length == 2) {
if (Number.isInteger(Number(argv[1]))) {
port = Number(process.argv[1]);
}

@@ -34,2 +43,12 @@ }

server
.use(async (context, next) => {
const path = context.path;
/**
* @link {https://developer.mozilla.org/en-US/docs/Web/Manifest#deploying_a_manifest}
*/
if ('/manifest.json' == path) {
context.res.setHeader('Content-Type', 'application/manifest+json');
}
return next();
})
.use((0, koa_bodyparser_1.default)())

@@ -46,3 +65,14 @@ .use((0, koa_static_1.default)(process.cwd()))

});
const httpsOptions = {
key: fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'private_key.pem')),
cert: fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'ca-cert.pem')),
};
https_1.default.createServer(httpsOptions, server.callback()).listen(port + 1, () => {
const ips = (0, node_utils_1.getIps)();
utils_1.logger.info('Server is running at:');
ips.forEach((ip) => {
utils_1.logger.info(`https://${ip}:${port + 1}`);
});
});
});
//# sourceMappingURL=server.js.map

4

package.json
{
"name": "@mrtujiawei/bin",
"version": "1.2.6",
"version": "1.2.8",
"description": "我的命令行工具",

@@ -35,3 +35,3 @@ "main": "",

"dependencies": {
"@mrtujiawei/node-utils": "^0.1.5",
"@mrtujiawei/node-utils": "0.1.8",
"@mrtujiawei/utils": "^2.2.0",

@@ -38,0 +38,0 @@ "koa": "^2.11.0",

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

#!/bin/env node
import {

@@ -2,0 +4,0 @@ logger,

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

#!/bin/env node
/**

@@ -2,0 +4,0 @@ * 自动提交一个文件夹下的所有项目代码

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

#!/bin/env node
import https from 'https';
import fs from 'fs';
import path from 'path';
import Koa from 'koa';

@@ -8,10 +13,20 @@ import Static from 'koa-static';

// 默认配置
let port = 3000;
if (process.argv[2] == '-p' && process.argv.length == 4) {
if (Number.isInteger(Number(process.argv[3]))) {
port = Number(process.argv[3]);
// 开启https
let secure = false;
const argv = process.argv.slice(2);
if (argv[0] == '-p' && argv.length >= 2) {
if (Number.isInteger(Number(argv[1]))) {
port = Number(argv[1]);
}
}
if ('-s' == argv[0] || '-s' == argv[2]) {
secure = true;
}
const server = new Koa();

@@ -23,11 +38,29 @@ const router = new Router();

.use(Static(process.cwd()))
.use(Static(path.resolve('/home/tujiawei/source/')))
.use(router.routes())
.use(router.allowedMethods());
server.listen(port, () => {
const ips = getIps();
logger.info('Server is running at:');
ips.forEach((ip) => {
logger.info(`http://${ip}:${port}`);
if (secure) {
const httpsOptions = {
key: fs.readFileSync(
path.resolve(__dirname, '..', 'pem', 'private_key.pem')
),
cert: fs.readFileSync(path.resolve(__dirname, '..', 'pem', 'ca-cert.pem')),
};
https.createServer(httpsOptions, server.callback()).listen(port, () => {
const ips = getIps();
logger.info('Server is running at:');
ips.forEach((ip) => {
logger.info(`https://${ip}:${port}`);
});
});
});
} else {
server.listen(port, () => {
const ips = getIps();
logger.info('Server is running at:');
ips.forEach((ip) => {
logger.info(`http://${ip}:${port}`);
});
});
}

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