This file contains 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 mongooseLoader = require('./mongoose'); | |
const expressLoader = require('./express'); | |
const passportLoader = require('./passport'); | |
const sessionStore = require('./sessionStore'); | |
module.exports = { | |
run: async ({ expressApp }) => { | |
const db = await mongooseLoader.run(); | |
console.log('✌️ DB loaded and connected!'); |
This file contains 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 MongoStore = require('connect-mongo'); | |
const { databaseURL, databaseName } = require('@config'); | |
module.exports = { | |
run: () => MongoStore.create({ | |
mongoUrl: databaseURL, | |
dbName: databaseName, | |
stringify: false, | |
autoRemove: 'interval', | |
autoRemoveInterval: 1 // In minutes |
This file contains 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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
// Schema to store the information about other logged in accounts | |
const accountSchema = new Schema({ | |
name: String, | |
userId: String, | |
email: String | |
}); |
This file contains 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
var passport = require('passport'); | |
var GoogleStrategy = require('passport-google-oauth20').Strategy; | |
var User = require('@models/user'); | |
var config = require('@config'); | |
passport.use(new GoogleStrategy({ | |
clientID: config.googleClientId, | |
clientSecret: config.googleClientSecret, | |
callbackURL: config.googleCallbackUrl, |
This file contains 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
"coverage": "nyc --reporter=text npm test" |
This file contains 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
describe('Test getUniqueHash'), () => { | |
it('should return a new hash', () => { | |
const item = { | |
hash: '1234567890', | |
}; | |
const newHash = getUniqueHash(item); | |
expect(newHash).to.not.equal(item.hash); | |
}); | |
}); |
This file contains 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
"test": "mocha ./src/tests/*.spec.js --exit" |
This file contains 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
describe('Testing express app routes', () => { | |
afterEach(() => { | |
app = rewire('../app'); | |
sandbox.restore(); | |
}); | |
describe('Testing /item route', () => { | |
let sampleItemVal, hash; | |
beforeEach(() => { |
This file contains 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
- src | |
-- controllers | |
---- item.controller.js | |
---- health.controller.js | |
-- models | |
---- item.model.js | |
-- routes | |
---- index.js | |
---- item.route.js | |
---- health.route.js |
This file contains 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
describe('Testing Item model', () => { | |
let sampleItemVal; | |
beforeEach(() => { | |
sampleItemVal = { | |
name: 'sample item', | |
price: 10, | |
rating: '5', | |
hash: 'hashGreaterThan10Chars' | |
}; |
NewerOlder