Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- err: {}
- const express = require('express');
- const helmet = require('helmet');
- const {
- Stitch,
- RemoteMongoClient,
- AnonymousCredential,
- StitchAppClientConfiguration
- } = require('mongodb-stitch-server-sdk');
- const app = express();
- app.use(helmet())
- const client = Stitch.initializeAppClient('<app-id>', new StitchAppClientConfiguration.Builder().withDataDirectory('/tmp').build());
- const db = client.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas').db('insight');
- app.get('*', (req, res) => {
- client.auth.loginWithCredential(new AnonymousCredential()).then(user => {
- res.set('Content-Type', 'application/json');
- res.status(200).send({user});
- }).catch(err => {
- res.status(500).send({err});
- });
- })
- module.exports = app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement