当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript data.connect函数代码示例

本文整理汇总了TypeScript中@nodulus/data.connect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript connect函数的具体用法?TypeScript connect怎么用?TypeScript connect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connect函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

router.get('/languages', function (req: any, res: any) {

    var lang = req.query.lang;
    
    dal.connect(function (err: any, db: any) {

        if (db === null) {
            return res.json(err);

        }

        db.collection("Languages").find({ "name": lang }).toArray(function (err: any, data: any) {
            var result: any = {}
            if (data !== null && data.length > 0) {
                data = data[0]
                for (var i = 0; i < data.values.length; i++) {
                    result[data.values[i].Key] = data.values[i].Value;
                }

            }
                
            return res.json(result);
        });


    });


});
开发者ID:nodulusteam,项目名称:generator-nodulus,代码行数:29,代码来源:translations.ts

示例2: JSZip

        fs.readFile(path.join(global.nodulsRepo, module_name + ".zip"), (err: any, data: any) => {
            if (err) throw err;

            var zip = new JSZip(data);
            var fileData = zip.file(consts.MANIFEST_NAME).asText();
            fs.writeFileSync(path.join(baseFolder, consts.MANIFEST_NAME), fileData, 'utf8');
            var manifest_file = fs.readJsonSync(path.join(baseFolder, consts.MANIFEST_NAME), { throws: true });


            if (manifest_file.files !== undefined) {
                for (var i = 0; i < manifest_file.files.length; i++) {
                    var filename = manifest_file.files[i];
                    if (zip.file(filename)) {
                        var fileData = zip.file(filename).asText();

                        if (filename.indexOf('/') > -1) {
                            var directoryPath = (path.join(baseFolder, path.normalize(filename)));
                            directoryPath = path.dirname(directoryPath);//.substr(0, directoryPath.lastIndexOf('\\'));
                            if (!fs.existsSync(directoryPath))
                                mkdirp.sync(directoryPath);
                        }



                        fs.writeFileSync(path.join(baseFolder, filename), fileData, 'utf8');
                    }

                }
            }

            if (manifest_file.routes !== undefined) {
                for (var i = 0; i < manifest_file.routes.length; i++) {
                    var filename = manifest_file.routes[i].path;
                    if (zip.folder("routes").file(filename)) {
                        var fileData = zip.folder("routes").file(filename).asText();
                        fs.writeFileSync(path.join(serverRoot, "routes", filename), fileData, 'utf8');
                    }
                    //attach the new route to express
                    app.use(module_name, require('../routes/' + filename));
                }
            }

            if (manifest_file.scripts !== undefined) {
                fs.ensureDirSync(path.join(baseFolder, "scripts"));
                for (var i = 0; i < manifest_file.scripts.length; i++) {
                    var filename = manifest_file.scripts[i];
                    if (zip.folder("scripts").file(filename)) {
                        var fileData = zip.folder("scripts").file(filename).asText();
                        fs.writeFileSync(path.join(baseFolder, "scripts", filename), fileData, 'utf8');
                    }

                }
            }


            var aboutfilename = "about.html";
            if (zip.file(aboutfilename) !== null) {
                var fileData = zip.file(aboutfilename).asText();
                fs.writeFileSync(path.join(baseFolder, aboutfilename), fileData, 'utf8');
            }







            var modules_file: any = {};

            modules_file = config.modulesSettings;

            if (modules_file[module_name] === undefined) {
                modules_file[module_name] = {}
            }


            //merge the manifest into the  file
            if (manifest_file === null)
                callback("invalid json, try using ascii file");

            //update navigation
            if (manifest_file.navigation)
                dal.connect((err: any, db: any) => {

                    for (var i = 0; i < manifest_file.navigation.length; i++) {
                        db.collection("Navigation").save(manifest_file.navigation[i], (err: any, data: any) => {

                        });
                    }
                })


            modules_file[module_name] = manifest_file;

            if (manifest_file.npm !== undefined) {
                var arr: Array<any> = [];
                for (var x in manifest_file.npm) {
                    arr.push({ name: x, ver: manifest_file.npm[x] });
                }
                //install npm dependencies
//.........这里部分代码省略.........
开发者ID:nodulusteam,项目名称:-nodulus-modules,代码行数:101,代码来源:utility.ts

示例3: function

            function (error: any, stdout: any, stderr: any) {

                //callback(stderr, stdout);
                //console.log('stdout: ' + stdout);
                //console.log('stderr: ' + stderr);
                if (error !== null) {
                    console.log('exec error: ' + error);
                }
                var basePath = path.join(process.cwd(), 'node_modules', module_name);
                app.use('/' + module_name, app.static(path.join(basePath, 'public')));
                var manifest_file = require(path.join(basePath, consts.MANIFEST_NAME));

                var modules_file: any = {};

                modules_file = config.modulesSettings;

                if (modules_file[module_name] === undefined) {
                    modules_file[module_name] = {}
                }



                if (manifest_file.routes !== undefined) {
                    for (var x = 0; x < manifest_file.routes.length; x++) {
                        try {
                            var pathRoute = path.join(basePath, 'routes', manifest_file.routes[x].path);
                            app.use('/' + module_name + manifest_file.routes[x].route, require(pathRoute));
                        }
                        catch (error) {
                            console.error(error);
                        }
                    }
                }

                //merge the manifest into the modules.js file
                if (manifest_file === null)
                    callback("invalid json, try using ascii file");

                //update navigation
                if (manifest_file.navigation)
                    dal.connect((err: any, db: any) => {

                        for (var i = 0; i < manifest_file.navigation.length; i++) {
                            db.collection("Navigation").save(manifest_file.navigation[i], (err: any, data: any) => {

                            });
                        }
                    })


                modules_file[module_name] = manifest_file;


                if (manifest_file.npm !== undefined) {
                    var arr: Array<any> = [];
                    for (var f in manifest_file.npm) {
                        arr.push({ name: f, ver: manifest_file.npm[f] });
                    }
                    //install npm dependencies
                    var async = require("async");
                    async.each(arr, instance.npm_install, () => {
                        //fs.writeFileSync(modules_configuration_path, JSON.stringify(modules_file));
                        config.persistModules();
                        callback(null, manifest_file);
                    })
                }
                else {
                    config.persistModules();
                    // fs.writeFileSync(modules_configuration_path, JSON.stringify(modules_file));
                    callback(null, manifest_file);
                }


            });
开发者ID:nodulusteam,项目名称:-nodulus-modules,代码行数:74,代码来源:utility.ts


注:本文中的@nodulus/data.connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。