Guest User

Untitled

a guest
Apr 6th, 2017
83
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. host: "mail.tm-tieto.fi",
  16. password: "somepassword",
  17. ssl: true
  18. }
  19. };
  20.  
  21. const app = express();
  22. app.use(cors());
  23. app.use(bodyParser.json())
  24. .use(bodyParser.urlencoded({ extended: false }));
  25.  
  26. const auth = require('chaos-auth')(r, settings);
  27.  
  28. app.use('/auth', auth.router);
  29.  
  30. app.get('/test', auth.authorize, (req, res) => {
  31. console.log('test works');
  32. res.send({ success: true, message: 'i am authorized' });
  33. });
  34.  
  35. app.listen(3000);
Advertisement
Add Comment
Please, Sign In to add comment