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

TypeScript passport.initialize函数代码示例

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

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



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

示例1: express

 return new Promise<void>((resolve, reject) => {
     let app: express.Application = express();
     app.set('env', 'test');
     PassportInitialize();
     app.use(Passport.initialize());
     app.use(Passport.session());
     Server.passportAuth('jwt', 'roles');
     Server.setFileLimits({
         fieldSize: 1024 * 1024
     });
     Server.loadControllers(app, ['test/data/*', '!**/*.yaml'], `${__dirname}/../..`);
     Server.setParamConverter((value, type) => {
         if (type.name === 'Person' && value['salary'] === 424242) {
             value['salary'] = 434343;
         }
         return value;
     });
     Server.swagger(app, './test/data/swagger.yaml', 'api-docs', 'localhost:5674', ['http']);
     server = app.listen(5674, (err: any) => {
         if (err) {
             return reject(err);
         }
         resolve();
     });
 });
开发者ID:garyevari,项目名称:typescript-rest,代码行数:25,代码来源:test.spec.ts


示例2: require

    app.configure(function(){
        app.engine('html', require('ejs').renderFile);
        app.set('view engine', 'html');
        app.use(express.logger('dev'));
        app.use(express.json());
        app.use(express.urlencoded());
        app.use(express.methodOverride());
        app.use(express.cookieParser());

        // Persist sessions with mongoStore
        app.use(express.session({
            secret: 'angular-fullstack secret',
            /*
            store: new mongoStore({
                url: config.mongo.uri,
                collection: 'sessions'
            }, function () {
                console.log("db connection open");
            })
            */
        }));

        //use passport session
        app.use(passport.initialize());
        app.use(passport.session());

        // Router (only error handlers should come after this)
        app.use(app.router);
    });
开发者ID:swcho,项目名称:ex_ossdb,代码行数:29,代码来源:express.ts


示例3: constructor

        constructor() {

            var session = require('cookie-session');
            var flash = require('flash');

            var app = express();

            app.use(express.static('build/client'));
            app.use('/server', express.static('server'));
            app.use('/client', express.static('client'));
            app.use('/bower_components', express.static('bower_components'));
            app.use('/node_modules', express.static('node_modules'));

            app.use(cookieParser());
            app.use(session({ secret: 'victoriasecret', resave: true, saveUninitialized: true }));
            app.use(passport.initialize());
            app.use(passport.session());
            app.use(bodyParser.json());
            app.use(bodyParser.urlencoded({ extended: true }));
            app.use('/api/auth', Auth());

            Database.init('test');
            Passport.init();

            app.listen(3000);
        }
开发者ID:zzeneg,项目名称:NodeSimpleWebsite,代码行数:26,代码来源:server.ts


示例4: function

export default function(app) {
  let env = app.get('env');

  app.set('views', config.root + '/server/views');
  app.set('view engine', 'jade');
  app.use(compression());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  app.use(methodOverride());
  app.use(cookieParser());
  app.use(passport.initialize());

  app.set('appPath', path.join(config.root, 'client'));

  if ('production' === env) {
    app.use(favicon(path.join(config.root, 'client', 'favicon.ico')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('dev'));
  }

  if ('development' === env) {
    app.use(require('connect-livereload')());
  }

  if ('development' === env || 'test' === env) {
    app.use(express.static(path.join(config.root, '.tmp')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('dev'));
    app.use(errorHandler()); // Error handler - has to be last
  }
}
开发者ID:Jeremy-Doucet,项目名称:Blog-Example-Typescript,代码行数:31,代码来源:express.ts


示例5: start

  start() {
    let app: express.Express = express();
    app.use('/', express.static('public'));
    var upload: multer.Instance = multer(); // for parsing multipart/form-data

    //Server Middlewares configuration part
    app.use(allowCrossDomain);
    app.use(cookieParser()); // read cookies (needed for auth)
    app.use(bodyParser.json()); // for parsing application/json
    app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
    app.use(expressSession({secret: 'swcmi'}));

    

    //To use passport 
    app.use(passport.initialize());
    app.use(passport.session()); // persistent login sessions

    //start router
    this.apiRouter.init(app);


    //port
    app.listen(10000, function () {
      console.log('SuWon church API Server listening on port 10000!')
    });

  }
开发者ID:jcdby,项目名称:SuwonCMIAPIServer,代码行数:28,代码来源:server.ts


示例6: before

    before((done) => {
        const app = express();

        passport.use(new JwtStrategy({
            jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
            secretOrKey: JWT_SECRET
        }, (payload: any, done: VerifiedCallback) => {
            done(null, payload.name);
        }));

        app.use(passport.initialize());
        app.use(passport.authenticate('jwt', { session: false }));

        app.get('/', (req, res) => {
            res.send('hello world! ' + req.user);
        });

        server = app.listen(3000, () => {
            done();
        });

        client = axios.create({
            baseURL: 'http://localhost:3000',
            validateStatus: status => true
        });
    });
开发者ID:loki2302,项目名称:nodejs-experiment,代码行数:26,代码来源:passport-jwt.spec.ts


示例7: initialize

 public initialize(router: express.Router): void {
     router.use(passport.initialize());
     const useSession = _.get(this.options, 'authOptions.session', true);
     if (useSession) {
         router.use(passport.session());
         if (this.options.serializeUser && this.options.deserializeUser) {
             passport.serializeUser((user: any, done: (a: any, b: string) => void) => {
                 Promise.resolve(this.options.serializeUser(user))
                     .then((result: string) => {
                         done(null, result);
                     }).catch((err: Error) => {
                         done(err, null);
                     });
             });
             passport.deserializeUser((user: string, done: (a: any, b: any) => void) => {
                 Promise.resolve(this.options.deserializeUser(user))
                     .then((result: any) => {
                         done(null, result);
                     }).catch((err: Error) => {
                         done(err, null);
                     });
             });
         }
     }
 }
开发者ID:thiagobustamante,项目名称:typescript-rest,代码行数:25,代码来源:passport.ts


示例8: startServer

function startServer(callback) {
    const fileStore = sessionFileStore(expressSession);

    let app = express();
    app.use(cookieParser());
    app.use(bodyParser.urlencoded({extended: true}));
    app.use(expressSession({
        store: new fileStore(),
        secret: 'alarm-clock',
        resave: false,
        saveUninitialized: true,
        cookie: {
            expires: new Date(253402300000000) // Approximately Fri, 31 Dec 9999 23:59:59 GMT
        }
    }));
    app.use(passport.initialize());

    routes(app);
    app.use(express.static(path.join(__dirname, '../../web/static')));
    app.use(express.static(path.join(__dirname, '../../build-web')));
    app.use(function (req: express.Request, res: express.Response, next: express.NextFunction) {
        console.log('Invalid path: ' + req.originalUrl);
        next();
    });
    app.listen(PORT, callback)
}
开发者ID:joeferner,项目名称:alarm-clock,代码行数:26,代码来源:index.ts


示例9: function

module.exports = function(app) {

    var env = config.env;

    app.set('view engine', 'html');
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());
    app.use(compression());
    app.use(morgan('dev')); 
    app.use(passport.initialize()); 
    app.use(express.static(path.join(config.root, 'client')));
    app.set('appPath', 'client'); 

    app.use(session({
        secret: config.secrets.session,
        resave: true,
        saveUninitialized: true,
        store: new mongoStore({ mongooseConnection: mongoose.connection })
    })); 

    if (env === 'development' || env === 'test') {
        app.use(require('errorhandler')());
    }

};
开发者ID:rhushi-lokhande,项目名称:Team-Stack,代码行数:25,代码来源:express.ts


示例10: async

export const start = async (port: string) => {
  await MongooseClient.InitMongoConnection();

  const app = express();
  const appRootUrl = siteName ? `https://${siteName}.azurewebsites.net` : `http://localhost:${port}`;

  initPassport(appRootUrl);
  enableSessions(app, SocketServer);
  initSockets();
  app.use(json())
  app.use(passport.initialize());
  app.use(passport.session());
  const server = createServer(app);
  SocketServer.attach(server);

  app.use(Routes);

  await new Promise(resolve => {
    server.listen(port, () => {
      console.log(`Server listening at port ${port}`);
      resolve()
    });
  })

  return async function close() {
    await new Promise(resolve => server.close(resolve))
    await MongooseClient.disconnect()
  }
};
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:29,代码来源:app.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript passport.serializeUser函数代码示例发布时间:2022-05-25
下一篇:
TypeScript passport.deserializeUser函数代码示例发布时间: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