Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var bodyParser = require('body-parser');
var paypal = require('paypal-rest-sdk');
var express = require('express');
var app = express();
// Initialize the app with a service account, granting admin privileges
var serviceAccount = require("path/to/serviceAccountKey.json");
paypal.configure({
'mode': 'sandbox', //sandbox or live
'client_id': 'REPLACE WITH PAYPAL APP CLIENT_ID',
'client_secret': 'REPLACE WITH PAYPAL APP SECRET'
});
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: "https://.firebaseio.com"
});
// configure body parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 5000; // set our port
// START THE SERVER
// =============================================================================
app.listen(port);
console.log('Magic happens on port ' + port);
// get an instance of the express Router
private_key_id: process.env.FBTEST_PRIVATE_KEY_ID,
private_key: process.env.FBTEST_PRIVATE_KEY,
client_email: process.env.FBTEST_CLIENT_EMAIL,
client_id: process.env.FBTEST_CLIENT_ID,
auth_uri: process.env.FBTEST_AUTH_URI,
token_uri: process.env.FBTEST_TOKEN_URI,
auth_provider_x509_cert_url: process.env.FBTEST_AUTH_PROVIDER_X509_CERT_URL,
client_x509_cert_url: process.env.FBTEST_CLIENT_X509_CERT_URL
}
if(!serviceAccount.private_key) {
serviceAccount = require('../tests/secret-firebase-test-server');
}
const key = {
apiKey: 'AIzaSyBzVhw7ppsPkNKEahvABSl8ojMHqEd5lAg',
credential: firebaseAdmin.credential.cert(serviceAccount),
authDomain: 'istanbul-test.firebaseapp.com',
databaseURL: 'https://istanbul-test.firebaseio.com/'
}
firebaseAdmin.initializeApp(key);
} else {
// process.env - config vars set-up on heroku side
let serviceAccount = {
type: process.env.FIREBASE_TYPE,
project_id: process.env.FIREBASE_PROJECT_ID,
private_key_id: process.env.FIREBASE_PRIVATE_KEY_ID,
private_key: process.env.FIREBASE_PRIVATE_KEY,
client_email: process.env.FIREBASE_CLIENT_EMAIL,
client_id: process.env.FIREBASE_CLIENT_ID,
auth_uri: process.env.FIREBASE_AUTH_URI,
token_uri: process.env.FIREBASE_TOKEN_URI,
auth_provider_x509_cert_url: process.env.FIREBASE_AUTH_PROVIDER_X509_CERT_URL,
var app = express();
var stocks = [];
// Enable CORS
app.use(cors());
app.set('port', (process.env.PORT || 5000));
app.set('projectId', (process.env.PROJECT_ID || ''));
app.set('clientEmail', (process.env.CLIENT_EMAIL || ''));
app.set('privateKey', (process.env.PRIVATE_KEY || ''));
app.set('firebaseDB', (process.env.FIREBASE_DB || ''));
// Initialize Firebase
firebase.initializeApp({
credential: firebase.credential.cert({
projectId: app.get('projectId'),
clientEmail: app.get('clientEmail'),
privateKey: app.get('privateKey').replace(/\\n/g, '\n')
}),
databaseURL: app.get('firebaseDB')
});
var db = firebase.database();
var ref = db.ref('stocks');
function getRandomInt(min, max) {
return (Math.floor(Math.random() * (max - min + 1)) + min);
}
function loadSymbols() {
let csv = fs.readFileSync('./companies.csv', 'utf8');
module.exports = () => {
const firebaseDBUrl = process.env.FIREBASE_DB_URL
const serviceAccountBase64 = process.env.FIREBASE_SERVICE_ACCOUNT_BASE64
firebase.initializeApp({
credential: firebase.credential.cert(b64ToObject(serviceAccountBase64)),
databaseURL: firebaseDBUrl
})
let database = firebase.database()
return {
saveTeam (id, data, done) {
database.ref(`teams/${id}`).set(data, (err) => {
if (err) {
return done(err)
}
return done(null)
})
},
const getAccessToken = () => __awaiter(this, void 0, void 0, function* () {
const accessToken = yield admin.credential
.applicationDefault()
.getAccessToken();
return accessToken.access_token;
});
const getRecentTemplatesAtVersion = (accessToken, version) => __awaiter(this, void 0, void 0, function* () {
const express = require('express')
const bodyParser = require('body-parser')
const session = require('express-session')
const FileStore = require('session-file-store')(session)
const next = require('next')
const admin = require('firebase-admin')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const firebase = admin.initializeApp(
{
credential: admin.credential.cert(require('./credentials/server')),
},
'server'
)
app.prepare().then(() => {
const server = express()
server.use(bodyParser.json())
server.use(
session({
secret: 'geheimnis',
saveUninitialized: true,
store: new FileStore({ secret: 'geheimnis' }),
resave: false,
rolling: true,
httpOnly: true,
describe('Login', function() {
const admin = require('firebase-admin');
const config = require('../config.json');
admin.initializeApp({
credential: admin.credential.cert(config.firebase.serviceAccount),
databaseURL: config.firebase.databaseURL
});
const mocks = require('../../mocks');
const UpdateUser = require('./updateUser.onCreate');
const database = admin.database();
const usersPath = 'quiver-functions/users';
const usersRef = database.ref(usersPath);
const userRef = usersRef.child(mocks.mockUser.uid);
function cleanUp(done) {
return Promise.all([usersRef.remove()]).then(() => done());
}
const admin = require("firebase-admin");
const credential = process.env.FIREBASE_SVC_ACC
? admin.credential.cert(JSON.parse(process.env.FIREBASE_SVC_ACC))
: admin.credential.applicationDefault();
admin.initializeApp({
credential,
projectId: "copenhagenjsdk",
databaseURL: "https://copenhagenjs.firebaseio.com"
});
export { admin };
export let db = admin.firestore();
export interface FirebaseResult {
size: number;
docs: FirebaseResultItem[];
}
export interface FirebaseResultItem {
"use strict";
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const firebase = require("firebase");
const crypto = require("crypto");
const moment = require("moment");
var serviceAccount = require("./config/serviceKey.json");
var clientAccount = require("./config/clientKey.json");
const fs = require("fs");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: clientAccount.databaseURL,
storageBucket: clientAccount.storageBucket
});
firebase.initializeApp(clientAccount);
const nodemailer = require("nodemailer");
const gmailEmail = functions.config().gmail.email;
const gmailPassword = functions.config().gmail.password;
const mailTransport = nodemailer.createTransport({
service: "gmail",
auth: {
user: gmailEmail,
pass: gmailPassword
}
functions.config().sqreen.app &&
functions.config().sqreen.app.name &&
functions.config().sqreen.token
) {
process.env.SQREEN_APP_NAME = functions.config().sqreen.app.name;
process.env.SQREEN_TOKEN = functions.config().sqreen.token;
require("sqreen");
}
const admin = require("firebase-admin");
if (process.env.NODE_ENV === "development") {
const serviceAccount = require("../../serviceAccount.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://zero-width-shortener.firebaseio.com"
});
debugAgent.start({
projectId: "zero-width-shortener",
keyFilename: "../../serviceAccount.json",
allowExpressions: true,
serviceContext
});
} else {
const profiler = require("@google-cloud/profiler");
admin.initializeApp();
profiler.start({
serviceContext