New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

njserver

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

njserver

Nodejs webserver

latest
npmnpm
Version
1.5.7
Version published
Maintainers
1
Created
Source

njserver

安装njserver

npm install njserver

njserver命令

  • 初始化项目文件:npm njserver init
  • 更新项目文件:npm njserver update
  • 启动njserver程序:npm njserver start

启动njserver

var njserver = require('njserver');

njserver.use('/', './assets/');

njserver.use('/', {
    dir: './controller/'
});

njserver.use('/', {
    before: function (req, res, next) {
        require('./interceptor/access')(req, res, next);
    },

    after: function (req, res, chunk, next) {
        require('./interceptor/content')(req, res, chunk, next);
    }
});

njserver.listen();

config.js配置文件示例

global.sysConfig = {
    serverName: 'test', //应用名称
    serverDescription: '测试系统', //应用描述
    isDebug: true, //是否调试模式
    servers: [{ //监听协议及端口
            protocol: 'http',
            port: 8081
        },
        {
            protocol: 'https',
            port: 443,
            key: '94xh.com.key',
            cert: '94xh.com.pem'
        },
        {
            protocol: 'http2',
            port: 8082,
            key: '94xh.com.key',
            cert: '94xh.com.pem'
        }
    ],
    session: {
        timeout: 1800000, //session过期时间,单位ms,默认30min
        store: 'mysql', //session存储介质,默认为空使用内存存储,可设置数据库类型:mysql
        table: 'sessions' //存储在数据库中的表名称,结构:`njsid` varchar(255) 主键 && `session` json && `update` datetime(0)
    },
    sessionClearTime: '0 */30 * * * *', //每30分钟清理一次过期session
    requestTimeout: 120000, //request请求超时时间,单位ms,默认120s
    responseTimeout: 120000, //response响应超时时间,单位ms,默认120s
    fileCacheControl: 'max-age=7200', //静态文件客户端缓存配置,默认2h过期
    page404: '', //自定义404页面路径,默认不设置为空
    page500: '', //自定义500页面路径,默认不设置为空
    mysql: { //mysql数据库连接配置
        host: '127.0.0.1', //mysql数据库主机
        user: 'root', //mysql数据库用户名
        password: '123456', //mysql数据库密码
        database: 'test', //mysql数据库名称
        supportBigNumbers: true, //处理大数字(BIGINT和DECIMAL)时需要启动此项
        bigNumberStrings: true, //使用supportbignumbers和bignumberstrings时总是返回JavaScript字符串对象
        multipleStatements: true, //mysql数据库查询是否支持多条语句
        connectionLimit: 10, //mysql连接池创建的最大连接数
        connectTimeout: 10000, //mysql连接超时时间,单位ms,默认10s
        acquireTimeout: 10000, //mysql从连接池中获取连接超时时间,单位ms,默认10s
        timeout: 60000, //mysql查询超时时间,单位ms,默认10s
        timezone: '08:00' //mysql时区设置
    },
    mssql: { //mssql数据库连接配置
        server: '127.0.0.1', //mssql数据库主机
        user: 'sa', //mssql数据库用户名
        password: '123456', //mssql数据库密码
        database: 'test', //mssql数据库名称
        connectionTimeout: 15000, //mssql连接超时时间,单位ms,默认15s
        requestTimeout: 600000, //mssql查询超时时间,单位ms,默认15s
        parseJSON: true, //将json数据集转化成json对象
        multipleStatements: true, //mssql数据库查询是否支持多条语句
        pool: {
            max: 10, //mssql连接池创建的最大连接数
            acquireTimeoutMillis: 10000, //mysql从连接池中获取连接超时时间,单位ms,默认不限制
            idleTimeoutMillis: 30000 //mssq连接池空闲连接保持时间,单位ms,默认30s
        }
    },
    tableRoute: { //数据库名称加密映射
        '0000000x': 'dw_log'
    },
    mail: {
        service: 'QQex',
        auth: {
            user: 'test@qq.com',
            pass: '123456'
        }
    },
    mime: { //服务器支持的MIME类型
        css: 'text/css',
        gif: 'image/gif',
        html: 'text/html',
        htm: 'text/html',
        ico: 'image/x-icon',
        jpeg: 'image/jpeg',
        jpg: 'image/jpeg',
        js: 'text/javascript',
        json: 'application/json',
        pdf: 'application/pdf',
        png: 'image/png',
        svg: 'image/svg+xml',
        swf: 'application/x-shockwave-flash',
        tiff: 'image/tiff',
        txt: 'text/plain',
        woff: 'application/font-woff',
        woff2: 'application/font-woff',
        ttf: 'application/octet-stream',
        wav: 'audio/x-wav',
        wma: 'audio/x-ms-wma',
        wmv: 'video/x-ms-wmv',
        xml: 'text/xml',
        exe: 'application/octet-stream',
        docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
        doc:'application/msword',
        xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        xls:'application/vnd.ms-excel',
        zip: 'application/zip',
        rar:' application/octet-stream',
        mp4: 'video/mp4 application/octet-stream',
        ppt:'application/vnd.ms-powerpoint',
        pptx:'application/vnd.openxmlformats-officedocument.presentationml.presentation',
        mp3:'audio/mpeg',
        bmp:'image/bmp'
    },
    uploadType: ['gif', 'jpg', 'png', 'bmp', 'xls', 'xlsx', 'doc', 'docx', 'ppt', 'pptx', 'pdf', 'zip', 'rar', 'txt'], //允许上传文件的格式
    uploadTemp: './tmp', //上传文件的临时保存路径
    uploadMaxFieldsSize: 10485760, //允许POST参数大小,单位byte,默认10mb
    uploadMaxFields: 1000, //允许POST参数数量
    uploadMaxFileSize: 104857600, //允许上传文件的大小,单位byte,默认100mb
    downloadBufferSize: 1048576, //下载文件块大小,单位byte,默认1mb
    downloadFileSize: 104857600, //允许下载文件的大小,单位byte,默认100mb
    log4js: { //日志配置
        appenders: {
            'rule-console': { //控制台打印
                type: 'console'
            },
            'rule-access': { //用户访问记录
                type: 'dateFile',
                filename: './logs/access/acc.log',
                encoding: 'utf-8',
                pattern: 'yyyy-MM-dd',
                daysToKeep: 30,
                keepFileExt: true,
                alwaysIncludePattern: true
            },
            'rule-system': { //服务器日志记录
                type: 'dateFile',
                filename: './logs/system/sys.log',
                encoding: 'utf-8',
                pattern: 'yyyy-MM-dd',
                daysToKeep: 30,
                keepFileExt: true,
                alwaysIncludePattern: true
            }
        },
        categories: {
            default: {
                appenders: ['rule-console', 'rule-system'],
                level: 'debug' //服务器日志记录级别
            },
            access: {
                'appenders': ['rule-access'],
                'level': 'info' //服务器日志记录级别
            }
        },
        pm2: true, //使用pm2启动应用
        disableClustering: true //每个进程单独记录日志
    }
};

Keywords

web

FAQs

Package last updated on 29 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts