本文整理汇总了TypeScript中root-path.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
/// <reference path="../../typings/tsd.d.ts" />
var root = require('root-path');
var metadata = require(root('/server/db/meta'));
var breeze_sequel = require(root('/server/breeze_sequel/main'));
import breeze = require('breeze-client');
import _ = require('lodash');
var DT = breeze.DataType;
var Identity = breeze.AutoGeneratedKeyType.Identity;
var Validator = breeze.Validator;
var camelCaseConvention: breeze.NamingConvention = breeze.NamingConvention.none;
// Breeze Labs: breeze.metadata.helper.js
var helper = new breeze_sequel.breeze.config.MetadataHelper();
// Helper convenience methods
var addDataService = helper.addDataService.bind(helper);
var addTypeToStore = helper.addTypeToStore.bind(helper);
var setDefaultNamespace = helper.setDefaultNamespace.bind(helper);
var dataNameSpace = 'afrikNetMarket';
export interface DataProperty {
[name: string]: DataPropertyDefinition
}
export interface DataPropertyDefinition {
dataType?: breeze.DataTypeSymbol;
defaultValue?: any;
示例2: load_apis
function load_apis(context: ctx.AppContext) {
var files: string[] = fs.readdirSync(root('/api/controllers'));
_.each(files, fn => {
var ext = path.extname(fn);
if (ext === '.js') {
var _skip_file = _.find(skip_files, f => {
return f === fn;
}) != undefined;
if (!_skip_file) {
var _api = require(root('/api/controllers/' + fn));
_api(context);
}
}
});
}
示例3: require
_.each(files.sort(), fn => {
var ext = path.extname(fn);
if (ext === '.js') {
var model = require(root('/api/models/' + fn));
if (_.isFunction(model)) {
model();
}
}
});
示例4: upload_file
export function upload_file(req: Express.Request, res: Express.Response) {
var options = {
dirname: root('/assets/images'),
saveAs: (__newFileStream, cb) => {
cb(null, path.basename(__newFileStream.filename));
}
};
(req as any)['file']('file').upload(options, function (err, files:any[]) {
if (err) {
console.log('error');
}
else {
console.log(files);
}
var path = files[0].fd;
base64.base64(path, (err, data) => {
var product_id = req.params['product_id'];
var params = '/products/' + product_id + '/images?file[data][$binary]=' + data;
sch_client['post'](params, (err, result) => {
});
/*
sch_client[info.fn].apply(sch_client, params);
POST /products/<id>/images?file[data][$binary]=<base64 encoded image data>&caption=<optional caption>
*/
});
res.send(files[0]);
});
}
示例5: load_models
function load_models(context: ctx.AppContext) {
var files: string[] = fs.readdirSync(root('/api/models'));
_.each(files.sort(), fn => {
var ext = path.extname(fn);
if (ext === '.js') {
var model = require(root('/api/models/' + fn));
if (_.isFunction(model)) {
model();
}
}
});
}
示例6: function
export var upload_file = function (req: express.Request, res: express.Response, next) {
var uploadOptions = {
dirname: root('/assets/images'),
saveAs: function (__newFileStream, cb) {
cb(null, path.basename(__newFileStream.filename));
},
}
req['file']('file').upload(uploadOptions, function (err, files) {
if (err) {
console.log('error');
}
else {
console.log(files);
}
res.send(files[0]);
});
}
示例7: require
/// <reference path="../appcontext.ts" />
/// <reference path="../../typings/tsd.d.ts" />
/// <reference path="utils.ts" />
/// <reference path="adapter.ts" />
/// <reference path="store.ts" />
var root = require('root-path');
import ctx = require('../appcontext');
import Q = require('q');
var br_sequel = require( root('/server/breeze_sequel/main'));
var sequel_manager = br_sequel.SequelizeManager;
var sequel_query = br_sequel.SequelizeQuery;
var sequel_save = br_sequel.SequelizeSaveHandler;
var __sequel = require('sequelize');
import utils = require('./utils');
import _ = require('lodash');
import Store = require('./store');
import breeze = require('breeze-client');
require('./adapter');
br_sequel.breeze.config.initializeAdapterInstance('dataService', 'adapter_webApi', true);
export interface ApiInfo {
serviceName: string,
getInstance: (ctx: ctx.AppContext) => ServiceApi
}
示例8: start_db
/// <reference path="../../typings/tsd.d.ts" />
/// <reference path="../../typings/express/express.d.ts" />
var root = require('root-path');
import path = require('path');
var fs = require('fs');
//import breeze = require('breeze-client');
var bs = require(root('/server/breeze_sequel/main'));
var s_mgr = bs.SequelizeManager;
//var s_qury = bs.SequelizeQuery;
//var s_shandle = bs.SequelizeSaveHandler
//var squlz = require('sequelize');
//require('./adapter');
//bs.breeze.config.initializeAdapterInstance('dataService', 'adapter_webApi', true);
var Con = require(root('/config/connections'));
var dbconn = Con.connections.dbconnection;
export function start_db(app: Express.Application) {
var conn = new s_mgr(dbconn.config, dbconn.extra);
//conn.sequelize.query("select top 10 * from occp", { type: squlz.QueryTypes.SELECT }).then(list => {
// var d = list;
//});