• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript monk.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: require

import {browser, element, By} from "protractor";
import * as monk from "monk";
import e2eHelp from "./e2e-help";
import * as pluck from 'ramda/src/pluck'

const config = require("../../config/config");
const hostName = 'http://' + config.publicHost + ':' + config.port;
const database = monk.default(config.tempMongoUrl);
const tribeCollection = database.get('tribes');

const userEmail = '[email protected]';

function authorizeAllTribes() {
    return tribeCollection.find({}, {})
        .then(function (tribeDocuments) {
            const authorizedTribes = pluck('id', tribeDocuments);
            return e2eHelp.authorizeUserForTribes(authorizedTribes);
        });
}

let updateTextBox = function (selector: any, text: string) {
    element(selector).clear();
    element(selector).sendKeys(text);
};

describe('The edit tribe page', function () {

    const checkedOption = element(By.css('#pairing-rule option:checked'));
    const tribeIdElement = element(By.id('tribe-id'));

    const deleteButton = element(By.className('delete-tribe-button'));
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:31,代码来源:edit-tribe.e2e.ts


示例2: require

import * as Bluebird from "bluebird";
import * as monk from "monk";
import * as pluck from 'ramda/src/pluck'
import * as find from 'ramda/src/find'

let config = require('../../config/config');
let server = 'http://localhost:' + config.port;

let path = '/api/tribes';
let host = supertest.agent(server);

function clean(object) {
    return JSON.parse(JSON.stringify(object));
}

let database = monk.default(config.tempMongoUrl);
let tribesCollection = database.get('tribes');
let playersCollection = database.get('players');
let usersCollection = monk.default(config.mongoUrl).get('users');

describe(path, function () {
    let userEmail = '[email protected]';

    beforeEach(function (done) {
        host.get('/test-login?username=' + userEmail + '&password=pw')
            .expect(302)
            .then(() => Bluebird.all([
                playersCollection.drop(),
                tribesCollection.drop()
            ]))
            .then(done, done.fail);
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:31,代码来源:tribes-spec.ts


示例3: require

"use strict";
import * as monk from "monk";
import CouplingDataService from "../../lib/CouplingDataService";

const config = require('../../config/config');

const mongoUrl = config.testMongoUrl + '/UsersTest';
const database = monk.default(mongoUrl);

describe('CouplingDataService', function () {
    const frodo = {name: 'Frodo', _id: undefined, tribe: null};
    const expectedPlayers = [
        {name: 'Gandalf'},
        {name: 'Sam'},
        {name: 'Merry'},
        {name: 'Pippin'},
        frodo
    ];

    const pairSetOne = {
        pairs: [
            [
                {name: 'Gandalf'},
                frodo
            ],
            [
                {name: 'Merry'},
                {name: 'Pippin'}
            ]
        ], date: new Date(2013, 8, 1),
        _id: undefined
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:31,代码来源:CouplingDataService-spec.ts


示例4: require

import * as monk from "monk";
import * as Promise from "bluebird";
import UserDataService from "../../lib/UserDataService";

var config = require('../../config/config');

var mongoUrl = config.testMongoUrl + '/UsersTest';
var database = monk.default(mongoUrl);
var userDataService = new UserDataService(database);

const kotlinLogging = require('kotlin-logging');

var safeDone = function (error, done) {
    if (error) {
        done.fail(error);
    } else {
        done();
    }
};
describe('UserDataService', function () {
    var usersCollection = database.get('users');

    beforeEach(function (done) {
        usersCollection.drop()
            .then(done, done.fail);
    });

    describe('findOrCreate', function () {
        it('will create a user if it does not already exist', function (done) {
            var email = '[email protected]';
            userDataService.findOrCreate(email, function (err, user) {
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:31,代码来源:UserDataService-spec.ts


示例5: require

import Badge from "../../../common/Badge";
import Tribe from "../../../common/Tribe";
import PairingRule from "../../../common/PairingRule";
import Comparators from "../../../common/Comparators";
import ApiGuy from "../e2e/apiGuy";

let config = require('../../config/config');

let server = 'http://localhost:' + config.port;
let superAgent = supertest.agent(server);

let tribeId = 'endpointTest';
let pinId = monk.id();
let path = '/api/' + tribeId + '/spin';

let database = monk.default(config.testMongoUrl + '/CouplingTemp');
let pinCollection = database.get('pins');
let tribeCollection = database.get('tribes');
let historyCollection = database.get('history');

describe(path, function () {

    beforeEach(async function () {
        await tribeCollection.drop()
    });

    beforeAll(async function () {
        removeTestPin();
    });

    beforeEach(async function () {
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:31,代码来源:game-spec.ts


示例6: encodeURIComponent

import config from '../config';

const u = config.mongodb.user ? encodeURIComponent(config.mongodb.user) : null;
const p = config.mongodb.pass ? encodeURIComponent(config.mongodb.pass) : null;

const uri = `mongodb://${u && p ? `${u}:${p}@` : ''}${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`;

/**
 * monk
 */
import mongo from 'monk';

const db = mongo(uri);

export default db;

/**
 * MongoDB native module (officialy)
 */
import * as mongodb from 'mongodb';

let mdb: mongodb.Db;

const nativeDbConn = async (): Promise<mongodb.Db> => {
	if (mdb) return mdb;

	const db = await ((): Promise<mongodb.Db> => new Promise((resolve, reject) => {
		mongodb.MongoClient.connect(uri, { useNewUrlParser: true }, (e: Error, client: any) => {
			if (e) return reject(e);
			resolve(client.db(config.mongodb.db));
		});
开发者ID:ha-dai,项目名称:Misskey,代码行数:31,代码来源:mongodb.ts


示例7: require

var express = require('express');
var router = express.Router();

var mongo = require('mongodb');
var monk = require('monk');
var db = monk('localhost:27017/zssport');

var sportDB = db.get('sport');

var createSport = function(body) {
    return {
        title: body.title
    }
};

var getSports = function(response) {
	sportDB.find(
        {},
		function(error, results) {
            if (results) {
                response.json(results);
            } else {
                response.end();
            }
	});
};

var getSport = function(response, query) {
	sportDB.find(
        query,
		function(error, results) {
开发者ID:zsagasport,项目名称:zssport-app,代码行数:31,代码来源:sport.router.ts


示例8: require

const debug = require('debug')('my-application');
const pathModule = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
// Database
const mongo = require('mongodb');
const monk = require('monk');
const db = monk('localhost:27017/nodetest2');

class ServerAppComponent {
    beforeRegister() {
        this.is = 'server-app';
    }

    ready() {
        this.port = process.env.PORT || 3000;

        this.listenCallback = () => {
            console.log('Express server listening on port ' + this.port);
            debug('Express server listening on port ' + this.port);
        };

        this.configCallback = (app) => {
            // view engine setup
            app.set('views', pathModule.resolve(__dirname, 'views'));
            app.set('view engine', 'pug');
        };

        this.loggerMW = logger('dev');
        this.bodyParserJsonMW = bodyParser.json();
开发者ID:scramjs,项目名称:node-tutorial-2-restful-app,代码行数:31,代码来源:app.component.ts


示例9: startApp

    startApp() {
        var http = require('http');

        var express = require('express');
        var path = require('path');
        var favicon = require('serve-favicon');
        var logger = require('morgan');
        var cookieParser = require('cookie-parser');
        var bodyParser = require('body-parser');
        var multer = require('multer');
		//Retrive
        var mongo = require('mongodb');
        var monk = require('monk');
        //var db = monk('127.0.0.1:27017/MATA');
        var db = monk('mongodb://heroku_21q1wxnl:[email protected]:47315/heroku_21q1wxnl');
        var mongoose = require('mongoose'); // #al# : mongoose connection 
        //mongoose.connect('mongodb://localhost/MATA'); // #al# : mongoose connection
        mongoose.connect('mongodb://heroku_21q1wxnl:[email protected]:47315/heroku_21q1wxnl'); // #al# : mongoose connection 
        
        var easyimg = require('easyimage');
        var imagemagick = require('imagemagick');

        var routes = require('./routes');

        var app = express();   

        app.locals.moment = require('moment');     

        // view engine setup
        //app.set('views', path.join(__dirname, 'views'));
        app.set('views', path.join(__dirname, 'ViewsStyled'));
        app.set('view engine', 'jade');        

        // uncomment after placing your favicon in /public
        //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
        app.use(logger('dev'));
        app.use(bodyParser.json());
        app.use(bodyParser.urlencoded({ extended: false }));
        app.use(cookieParser());
        app.use(express.static(path.join(__dirname, 'public')));  
        app.use(multer({dest:'./uploads/fullsize/'}).single('image'));  
		//app.use(multer({dest:'./uploads/profilepictures/'}).single('image')); 
        // Make our db accessible to our router
        app.use(function(req, res, next) {
            req.db = db;
            req.mongoose = mongoose;
            next();
        });
        app.use('/', routes);    

        // catch 404 and forward to error handler
        app.use(function(req, res, next) {
            var err = new Error('Not Found');
            err.status = 404;
            next(err);
        });
		
        // error handlers
        // development error handler
        // will print stacktrace
        if (app.get('env') === 'development') {
            app.use(function(err, req, res, next) {
                res.status(err.status || 500);
                res.render('error', {
                    message: err.message,
                    error: err
                });
            });
        }
		
        // production error handler
        // no stacktraces leaked to user
        app.use(function(err, req, res, next) {
            res.status(err.status || 500);
            res.render('error', {
                message: err.message,
                error: {}
            });
        });

        module.exports = app;
    }
开发者ID:TylerWardle,项目名称:MATA_Clone,代码行数:82,代码来源:app.ts


示例10: require

/// <reference path="../typings/tsd.d.ts" />

import express = require('express');
import bodyParser = require('body-parser');

import MemberRoutes = require('./routes/member.routes');
import EventRoutes = require('./routes/event.routes');
import TaskRoutes = require('./routes/task.routes');

// New Code
var mongo = require('mongodb');
var monk = require('monk');

var db = monk('localhost:27017/goteamup');

var app = express();

// configure our app to use bodyParser(it let us get the json data from a POST)
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

app.use(function(req:any, res:any, next:any) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS");
  next();
});

// Make our db accessible to our router
app.use(function(req:any, res:any, next:any){
    req.db = db;
开发者ID:joensindholt,项目名称:app-seed,代码行数:31,代码来源:index.ts


示例11: constructor

    constructor() {
        var express = require('express');
        var path = require('path');
        var favicon = require('serve-favicon');
        var logger = require('morgan');
        var cookieParser = require('cookie-parser');
        var bodyParser = require('body-parser');
        var mongo = require('mongodb');
        var monk = require('monk');
        var db = monk('user:[email protected]:60968/wecode_db');
        var routes = require('./routes/index');
        var users = require('./routes/users');
        var multer = require('multer');
        var http = require('http');
        var deviantart = require('./public/node_modules/node-deviantart');
        var app = express();

        // view engine setup
        app.set('views', path.join(__dirname, 'views'));
        app.set('view engine', 'ejs');

        // uncomment after placing your favicon in /public
        //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
        app.use(logger('dev'));
        app.use(bodyParser.json());
        app.use(bodyParser.urlencoded({extended: false}));
        app.use(cookieParser());
        app.use(express.static(path.join(__dirname, 'public')));
        //app.use(multer({ dest: './public/images'}).array("file"));

        // THIS IS THE MULTER CODE (DO NOT TOUCH)
        app.use(multer({
            dest: './public/images',
            limits: { fileSize: 1024 * 1024},
        }).array("file"));

        // Make our db accessible to our router
        app.use(function(req, res, next) {
            req.currentUser = currentUser;
            req.db = db;
            req.currentSecurityResponse = currentSecurityResponse;
            req.deviantart = deviantart;
            next();
        });

        app.use('/', routes);
        app.use('/users', users);

        // catch 404 and forward to error handler
        app.use(function (req, res, next) {
            var err = new Error('Not Found');
            err.status = 404;
            next(err);
        });

        // viewed at http://localhost:3000
        app.get('/', function(req, res) {
            res.sendFile(path.join(__dirname + '/*.html'));
        });

        // error handlers

        // development error handler
        // will print stacktrace
        if (app.get('env') === 'development') {
            app.use(function (err, req, res, next) {
                res.status(err.status || 500);
                res.render('error', {
                    message: err.message,
                    error: err
                });
            });
        }

        // production error handler
        // no stacktraces leaked to user
        app.use(function (err, req, res, next) {
            res.status(err.status || 500);
            res.render('error', {
                message: err.message,
                error: {}
            });
        });
        app.listen(3030);
        module.exports = app;
    }
开发者ID:ShuHaoLi,项目名称:ComicCollab,代码行数:86,代码来源:app.ts


示例12: require

ďťż/// <reference path="server/typings/express/express.d.ts" />
var http = require('http');
var express = require('express');
var path = require("path");
var app = express.createServer();
var application_root = __dirname;

var home = process.env.deployPath || '';
var api = home + '/api';
var apiCollection = home + '/api/:collectionName';
var apiObject = home + '/api/:collectionName/:id';

var monk = require('monk');  
var db = monk('localhost/SIMDB'); // connect to SIMDB

app.configure(function () {
    app.use(express.favicon());
    app.use(express.logger());
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(application_root, "public")));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.use(function (err, req, res, next) {
    console.error(err.stack);
    res.send(500, err.stack);
});

app.get(api, function (req, res) {
开发者ID:Sally-Xu,项目名称:Fayde.Demo,代码行数:31,代码来源:server.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript monk.id函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mongoskin.db函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap