Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. err: {}
  2.  
  3. const express = require('express');
  4. const helmet = require('helmet');
  5. const {
  6. Stitch,
  7. RemoteMongoClient,
  8. AnonymousCredential,
  9. StitchAppClientConfiguration
  10. } = require('mongodb-stitch-server-sdk');
  11.  
  12. const app = express();
  13.  
  14. app.use(helmet())
  15.  
  16. const client = Stitch.initializeAppClient('<app-id>', new StitchAppClientConfiguration.Builder().withDataDirectory('/tmp').build());
  17.  
  18. const db = client.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas').db('insight');
  19.  
  20. app.get('*', (req, res) => {
  21. client.auth.loginWithCredential(new AnonymousCredential()).then(user => {
  22. res.set('Content-Type', 'application/json');
  23. res.status(200).send({user});
  24. }).catch(err => {
  25. res.status(500).send({err});
  26. });
  27. })
  28.  
  29. module.exports = app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement