當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript passport.initialize函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。