This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from '../../models'; | |
import moment from 'moment'; | |
const getAllUserEarnings = async (req, res) => { | |
// get the beginning of the current month | |
const currentDateMonth = moment().startOf('month').format(); | |
let cars, carIds, totalEarnings, currentMonthEarnings; | |
// Use raw SQL queries to select all cars which belongs to the user | |
cars = await db.sequelize.query('SELECT "id" FROM Cars" WHERE "Cars"."ownerId" = (:id)', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// passing the model type to return the result as the instance of the model | |
currentMonthEarnings = await db.sequelize.query('SELECT SUM("priceEstimate") FROM "Orders" WHERE "assignedCarId" IN(:ids) AND "createdAt" < (:createdDate)', { | |
replacements: {ids: carIds, createdDate: currentDateMonth}, | |
model: db.Order, | |
mapToModel: true | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cars = await db.sequelize.query('SELECT "id" FROM Cars WHERE "Cars"."ownerId" = ?', { | |
replacements: ['active'], type: sequelize.QueryTypes.SELECT | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const fs = require('fs'); | |
const path = require('path'); | |
const Sequelize = require('sequelize'); | |
const basename = path.basename(__filename); | |
const config = require('<path-to-sequelize-config>'); | |
const db = {}; | |
const sequelize = new Sequelize(config.url, config); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
const util = require('util'); | |
// get application version from package.json | |
const appVersion = require('../package.json').version; | |
// promisify core APIs | |
const readDir = util.promisify(fs.readdir); | |
const writeFile = util.promisify(fs.writeFile); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"build": "node build/build.js && npm run post:build", | |
"post:build": "node build/post-build.js" | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
export const refreshPageMixin = { | |
data() { | |
return { | |
currentHash: '{{POST_BUILD_ENTERS_HASH_HERE}}', | |
token: localStorage.getItem('user-token'), | |
hashChanged: false, | |
newHash: '' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div id="app"> | |
<router-view></router-view> | |
<div class="refresh-container" v-if="hashChanged && $root.env !== 'development'"> | |
<div class="notification-header"> | |
<button type="button" class="close-refresh-modal" @click="closeModal" aria-label="Close"> | |
<span aria-hidden="true"><i class="fal fa-times fa-sm"></i></span> | |
</button> | |
</div> | |
<div class="notification-body"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "service_account", | |
"project_id": "<project-id>", | |
"private_key_id": "<private-key-id>", | |
"private_key": "<private-key>", | |
"client_email": "<client-email>", | |
"client_id": "<client-id>", | |
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | |
"token_uri": "https://oauth2.googleapis.com/token", | |
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
import firebase from 'firebase-admin'; | |
var serviceAccount = require('./firebase-service-account.json'); | |
export default firebase.initializeApp({ | |
credential: firebase.credential.cert(serviceAccount), | |
databaseURL: process.env.FIREBASE_DATABASE_URL | |
}) |
OlderNewer