How to use the cookies.express function in cookies

To help you get started, we’ve selected a few cookies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github verdaccio / verdaccio / src / api / endpoint / api / user.ts View on Github external
token,
        });
      });
    }
  });

  route.delete('/-/user/token/*', function(req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
    res.status(HTTP_STATUS.OK);
    next({
      ok: API_MESSAGE.LOGGED_OUT,
    });
  });

  // placeholder 'cause npm require to be authenticated to publish
  // we do not do any real authentication yet
  route.post('/_session', Cookies.express(), function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
    res.cookies.set('AuthSession', String(Math.random()), createSessionToken());

    next({
      ok: true,
      name: 'somebody',
      roles: [],
    });
  });
}
github codejamninja / reactant / packages / redux / src / redux.web.server.js View on Github external
willInit(app) {
    const expressApp = app.app;
    expressApp.use(Cookies.express());
    return app;
  }
github TheDrone7 / Wumpi / src / ws.js View on Github external
mongoose.connect(db_url, {useNewUrlParser: true, useFindAndModify: false, useCreateIndex: true}, (err) => {
            if (err) return console.error(err);
            console.log('Connected to MongoDB.');
        }).catch();
        this.app = Express();
        this.app.engine('hbs', hbs({
            extname: 'hbs',
            layoutsDir: path.join(__dirname, 'layouts'),
            defaultLayout: 'layout',
        }));
        this.app.set('views', path.join(__dirname, 'views'));
        this.app.set('view engine', 'hbs');
        this.app.use(Express.static(path.join(__dirname, 'public')));
        this.app.use(bodyParser.urlencoded({extended: false}));
        this.app.use(bodyParser.json());
        this.app.use(cookies.express(["some", "random", "keys"]));
        this.registerWebPages();
        this.Server = this.app.listen(3000);
        console.log(this.Server.address().port);
    }
github taylorhughes / skit / lib / SkitServer.js View on Github external
}

      if (shouldLog) {
        var time = new Date() - start;
        var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || '-';
        console.log(ip, '-', req.headers['host'], '-', '"' + req.method, req.url, 'HTTP/1.1"',
            res.statusCode, time + 'ms', '"' + (req.headers['referer'] || '-') + '"', '"' + (req.headers['user-agent'] || '-') + '"');
      }

      end.apply(res, arguments);
    };

    next();
  });
  app.use(compression());
  app.use(Cookies.express());
  app.use(this.serve.bind(this));

  var httpServer = http.createServer(app);
  httpServer.listen(port);
};
github codejamninja / reactant / packages / base / src / init / native / server.js View on Github external
config.level === 'trace'
  ) {
    setLevel('trace');
  } else if (config.env === 'development') {
    setLevel('debug');
  } else {
    setLevel(config.level);
  }
  if (!global.window) global.window = {};
  if (config !== 'production') {
    const reactant = { config };
    global.window.reactant = reactant;
    global.reactant = reactant;
  }
  app.use(express.static(config.paths.distWebPublic));
  app.use(Cookies.express());
  app.get('/*', async (req, res, next) => {
    const css = new Set();
    let context = {};
    try {
      context = await createWebStore({
        cookieJar: new NodeCookiesWrapper(new Cookies(req, res)),
        insertCss: (...styles) => {
          return styles.forEach(style => css.add(style._getCss()));
        },
        location: req.url
      });
      context.persistor = await new Promise(resolve => {
        const { store } = context;
        const persistor = persistStore(store, config.initialState, () => {
          return resolve(persistor);
        });
github codejamninja / reactant / packages / base / src / init / server.js View on Github external
config.level === 'trace'
  ) {
    setLevel('trace');
  } else if (config.env === 'development') {
    setLevel('debug');
  } else {
    setLevel(config.level);
  }
  if (!global.window) global.window = {};
  if (config !== 'production') {
    const reactant = { config };
    global.window.reactant = reactant;
    global.reactant = reactant;
  }
  app.use(express.static(config.paths.distWebPublic));
  app.use(Cookies.express());
  app.get('/*', async (req, res, next) => {
    const css = new Set();
    let context = {};
    try {
      context = await createWebStore({
        cookieJar: new NodeCookiesWrapper(new Cookies(req, res)),
        insertCss: (...styles) => {
          return styles.forEach(style => css.add(style._getCss()));
        },
        location: req.url
      });
      context.persistor = await new Promise(resolve => {
        const { store } = context;
        const persistor = persistStore(store, config.initialState, () => {
          return resolve(persistor);
        });