Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. const express = require('express');
  2. const bodyParser = require('body-parser');
  3. const cors = require('cors');
  4. const r = require('rethinkdbdash')({ db: 'tm_tieto' });
  5.  
  6. process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
  7.  
  8. const settings = {
  9. secret: 'd7cad03d66f2d263991b2412dc112b7e',
  10. site: {
  11. name: 'Tm-Tieto Oy',
  12. url: 'http://localhost:3000'
  13. },
  14. email: {
  15. from: "no-reply@tm-tieto.fi",
  16. host: "mail.tm-tieto.fi",
  17. user: "foo@bar.com",
  18. password: "somepassword",
  19. ssl: true
  20. }
  21. };
  22.  
  23. const app = express();
  24. app.use(cors());
  25. app.use(bodyParser.json())
  26. .use(bodyParser.urlencoded({ extended: false }));
  27.  
  28. const auth = require('chaos-auth')(r, settings);
  29.  
  30. app.use('/auth', auth.router);
  31.  
  32. app.get('/test', auth.authorize, (req, res) => {
  33. console.log('test works');
  34. res.send({ success: true, message: 'i am authorized' });
  35. });
  36.  
  37. app.listen(3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement