本文整理汇总了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 = 'protractor@test.goo';
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'));
示例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 = 'test@test.tes';
beforeEach(function (done) {
host.get('/test-login?username=' + userEmail + '&password=pw')
.expect(302)
.then(() => Bluebird.all([
playersCollection.drop(),
tribesCollection.drop()
]))
.then(done, done.fail);
示例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
示例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 = 'awesome.o@super.coo';
userDataService.findOrCreate(email, function (err, user) {
示例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 () {
示例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));
});
示例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) {
示例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();
示例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:otpu73q7n7h9o1ff9lvmbifs8q@ds047315.mongolab.com:47315/heroku_21q1wxnl');
var mongoose = require('mongoose'); // #al# : mongoose connection
//mongoose.connect('mongodb://localhost/MATA'); // #al# : mongoose connection
mongoose.connect('mongodb://heroku_21q1wxnl:otpu73q7n7h9o1ff9lvmbifs8q@ds047315.mongolab.com: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;
}
示例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;
示例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:pass@ds060968.mongolab.com: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;
}
示例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) {