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

TypeScript body-parser.urlencoded函数代码示例

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

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



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

示例1: initBodyParser

function initBodyParser (app : express.Application) : void {
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: false }));
}
开发者ID:erickgirard,项目名称:supercommit,代码行数:4,代码来源:middlewareconfig.ts


示例2: require

require('source-map-support').install();
import express = require('express');
import path = require('path');
import {newsAPI} from './api/news';

var port: number = process.env.PORT || 8080;
var app = express();
var compression = require('compression');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');

mongoose.connect('mongodb://localhost/coherent-info-portal');

app.use(compression());
app.use(bodyParser.urlencoded({'extended': 'true'}));            // parse application/x-www-form-urlencoded
app.use(bodyParser.json());
app.use(express.static(path.resolve(process.cwd(), 'client/')));

var renderIndex = (req: express.Request, res: express.Response) => {
    res.sendFile(path.resolve(process.cwd(), 'client/index.html'));
};
newsAPI(app);

app.get('/*', renderIndex);

var server = app.listen(port, function() {
    var host = server.address().address;
    var port = server.address().port;
    console.log('This express app is listening on port:' + port);
});
开发者ID:SanyaBoriskin,项目名称:InfoPortal,代码行数:30,代码来源:server.ts


示例3: constructor

    constructor() {
        
        var fs = require('fs');
        var path = require('path');
        var express = require('express');

        var cookieParser = require('cookie-parser');
        var bodyParser = require('body-parser');
        var url = require('url');
        var querystring = require('querystring');

        global.config = new configuration.config();

        //var dal = new nodulus.data.dal();// require('./dal.js');
        //var config = require('./config.js');
        
        var webServer = new web.webServer();
        //var api = require('./api.js');


        var EventEmitter = require('events').EventEmitter;
        global.eventServer = new EventEmitter();
        var app = express();

        var http = require("http").createServer(app);
        var server = require('http').Server(app);
        var socket = require('socket.io');
        var io = socket.listen(server);
        global.socket = io;
        console.log("*** websocket is active");
        var SocketUse = new network.socket(io);
       
        webServer.start(server, app, function (app: any) {
        });


        var regexIso8601 = /^(\d{4}|\+\d{6})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2}):(\d{2})\.(\d{1,})(Z|([\-+])(\d{2}):(\d{2}))?)?)?)?$/;
        app.use(bodyParser.json({
            reviver: function (key: string, value: any) {
                var match: any;
                if (typeof value === "string" && (match = value.match(regexIso8601))) {
                    var milliseconds = Date.parse(match[0]);
                    if (!isNaN(milliseconds)) {
                        return new Date(milliseconds);
                    }
                }
                return value;
            },
            limit: '50mb',
        }));
        app.use(bodyParser.json()); // for parsing application/json
        app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
        app.use('/', express.static(path.resolve('./client/')));
        global.clientAppRoot = path.resolve('./client/'); 

        //load modules
        var nodulus_modules = global.config.modulesSettings;


        console.log("");



        console.log("***************************************************************************");
        console.log("***__active nodules_____________________________________________________***");
        console.log("***_____________________________________________________________________***");
        for (var name of Object.keys(nodulus_modules)) {
            var nodulus_module = nodulus_modules[name];

            console.log("***__ " + name + " " + this.print("_", 65 - name.length) + "***");



            if (nodulus_module.routes !== undefined) {
                for (var x = 0; x < nodulus_module.routes.length; x++) {
                    app.use(nodulus_module.routes[x].route, require('../routes/' + nodulus_module.routes[x].path));
                }
            }

        }

        console.log("***_____________________________________________________________________***");

        app.use("/nodulus", require('../routes/nodulus.js'));
        var a = new rest.api();
       
        a.start(app);
        console.log("***_____________________________________________________________________***");
        // app.use(require("nodulus-run"));


    }
开发者ID:ronokavi,项目名称:nodulus,代码行数:92,代码来源:startup.ts


示例4: 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


示例5: function

export let initAppAndDatabase = async function (): Promise<AppPlusDatabase> {
  try {
    /* config and logger init */
    let mode: string
    let logmode: string
    mode = process.env.NODE_ENV || 'development'
    mode === 'production' ? logmode = 'combined' : logmode = 'short'

    let config = await getServerConfig(mode)
    let logger = getLogger(config.logfile)

    try {
      // database and app init
      let app = express()
      let database = await initDatabase()

      /* express middlewares */

      // security
      app.use(helmet())

      // authentication
      app.use(passport.initialize())
      configurePassport(database, passport)

      // logs
      if (mode === 'development') { app.use(morgan('dev')) }
      app.use(morgan(logmode, { 'stream': logger['morganStream'] }))

      // requests
      app.use(bodyParser.json())
      app.use(bodyParser.urlencoded({ extended: true }))

      /* routes */
      app.use(generateRoutes(database, logger))

      /* handlers */
      // database disconnection and SIGINT handlers
      database.connection.once('disconnected', () => {
        logger.info('server is down')
        process.exit(0)
      })
      process.once('SIGINT', () => {
        logger.info('Server is down')
        database.connection.close(() => {
          process.exit(0)
        })
      })

      // request error handler
      app.use((err, req, res, next) => {
        let stack: string
        mode === 'development' ? stack = err.stack : stack = ''

        return res.status(err['status'] || 500).json({
          message: err.message,
          stack: stack,
          success: false
        })
      })

      return {
        app: app,
        database: database,
        logger: logger
      }
    } catch (err) {
      logger.error(err)
      throw err
    }

  } catch (err) {
    console.log(err)
    throw err
  }
}
开发者ID:chipp972,项目名称:stock_manager_api,代码行数:76,代码来源:app.ts


示例6: function

    //next();
//});

//===============================================
// express config start
//===============================================
router.use(express.static(path.resolve(__dirname, 'public')));
router.set('view engine', 'ejs'); // set up ejs for templating
router.set('views',path.join(__dirname,'/app/views'));
router.use(compression());
//router.use(multer({ dest: './uploads/'}));
//router.use(busboy());
// parse application/json
router.use(bodyParser.json());
// parse application/x-www-form-urlencoded
router.use(bodyParser.urlencoded({extended:true})); // get information from html forms
// parse application/vnd.api+json as json
router.use(bodyParser.json({ type: 'application/vnd.api+json' }));
router.use(cookieParser()); // required before session
router.use(methodOverride());

//===============================================
// express config start
//===============================================

//load file to write url file js
var eio_contents = fs.readFileSync(__dirname + '/node_modules/engine.io-client/engine.io.js').toString();
router.get('/engine.io.js', function(req, res) {
	//res.setHeader("Access-Control-Allow-Origin", "*");
	res.send(eio_contents);
});
开发者ID:Lightnet,项目名称:node-translator-novel,代码行数:31,代码来源:server.ts


示例7: require

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const server = require('http').createServer(app);
const port =  8000;

app.set('jsonp callback name', 'callback');

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({extended: true, limit: '50mb'}));
app.use(function(req, res, next) {
  res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTION');
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
  next();
});

// Start server
server.listen(port, () => console.log('Express server listening on %d, in %s mode', port, app.get('env')));

// API definition
require('./api/sed/sed')(app);

exports = module.exports = app;
开发者ID:KadoTomohiro,项目名称:NoisyGuy,代码行数:24,代码来源:app.ts


示例8: require

/// <reference path="../typings/references.ts" />
/// <reference path="./file-fetcher.ts" />

// to set up node and apache to run on the same server: http://stackoverflow.com/a/18604082/1063392

var express = require('express');
var bodyParser = require('body-parser');
var fileFetcher = require('./file-fetcher');
var domain = require('domain');
var app = express();
app.use(bodyParser.urlencoded({ extended: false, limit: 1048576 }));

app.post('/', (req, res) => {
	var d = domain.create();
	var responseHasBeenSent = false;
	d.on('error', function(er) {
		if (!responseHasBeenSent) {
			responseHasBeenSent = true;
			console.log(er);
			res.status(500).send(er);
		}
	});
	d.run(function() {
		var start = Date.now();
		fileFetcher.fetchFiles(req.body.file, (allFiles: string[]) => {
			console.log('request took ' + (Date.now() - start) + ' ms to complete');
			res.status(200).send(allFiles);
		});
	});
});
开发者ID:nfriend,项目名称:ldraw-visualizer,代码行数:30,代码来源:parts-server.ts


示例9: require

	morgan = require('morgan'),
	bodyParser = require('body-parser'),
	mongoose = require('mongoose');

/* Mongo start */
mongoose.connect('mongodb://localhost/timeline');
require('./utilities/mongoScheme');

/* App */
var app = express();
app.set('port', process.env.PORT || 3000);
app.use(express.static(__dirname + '/public'));

app.use(morgan('combined'));
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.urlencoded({ extended: false })); // parse application/x-www-form-urlencoded

/* Routing */
var auth = require('./routes/auth');

app.post('/api/v1/login', auth.login);
app.post('/api/v1/registration', auth.registration);
app.get('/api/v1/profile', auth.check, auth.profile);

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

app.get('/api/v1/tasks', auth.check, tasks.list);
app.get('/api/v1/tasks/:id', auth.check, tasks.get);
app.post('/api/v1/tasks', auth.check, tasks.create);
app.put('/api/v1/tasks/:id', auth.check, tasks.update);
app.delete('/api/v1/tasks/:id', auth.check, tasks.delete);
开发者ID:soramusoka,项目名称:timeline-project,代码行数:31,代码来源:runserver.ts


示例10: middleware

 private middleware(): void {
     this.express.use(logger('dev'));
     this.express.use(bodyParser.json());
     this.express.use(bodyParser.urlencoded({ extended: false}));
     this.express.use(cors());
 }
开发者ID:evrimulgen,项目名称:Cryptocurrency-Portfolio-API,代码行数:6,代码来源:App.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript bokehjs.Plotting类代码示例发布时间:2022-05-25
下一篇:
TypeScript body-parser.text函数代码示例发布时间: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