Skip to content

Instantly share code, notes, and snippets.

View Rishabh570's full-sized avatar
👋

Rishabh Rawat Rishabh570

👋
View GitHub Profile
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!');
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
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
});
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,
"coverage": "nyc --reporter=text npm test"
describe('Test getUniqueHash'), () => {
it('should return a new hash', () => {
const item = {
hash: '1234567890',
};
const newHash = getUniqueHash(item);
expect(newHash).to.not.equal(item.hash);
});
});
"test": "mocha ./src/tests/*.spec.js --exit"
describe('Testing express app routes', () => {
afterEach(() => {
app = rewire('../app');
sandbox.restore();
});
describe('Testing /item route', () => {
let sampleItemVal, hash;
beforeEach(() => {
@Rishabh570
Rishabh570 / final-project-structure
Created April 19, 2022 18:33
Final project structure of our express API, with all the unit tests and respective modules in place.
- src
-- controllers
---- item.controller.js
---- health.controller.js
-- models
---- item.model.js
-- routes
---- index.js
---- item.route.js
---- health.route.js
describe('Testing Item model', () => {
let sampleItemVal;
beforeEach(() => {
sampleItemVal = {
name: 'sample item',
price: 10,
rating: '5',
hash: 'hashGreaterThan10Chars'
};