Example #1
0
  database  : 'the_hub'
};

const serviceSetupCallBack = function (connection) {
  return {
    signupDataService                 : new SignupDataService(connection),
    setupQuestionnaireDataService     : new SetupQuestionnaireDataService(connection),
    loginDataService                  : new LoginDataService(connection),
    viewQuestionnnaireDataService     : new ViewQuestionnnaireDataService(connection),
    questionDataService               : new QuestionDataService(connection),
    allocateQuestionnaireDataService  : new AllocateQuestionnaireDataService(connection),
    answerDataService                 : new AnswerDataService(connection)
  }
};

app.use(connectionPv(dbOptions, serviceSetupCallBack));
app.use(cookieParser('shhhh, very secret'));
app.use(session({ secret : 'keyboard cat', cookie :{ maxAge : 3600000 }, resave : true, saveUninitialized : true }));
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended : false }));
app.use(bodyParser.json());
app.use(compression());
app.engine('handlebars', exhbs({defaultLayout : 'main'}));
app.set('view engine', 'handlebars');

app.get('/signup', router.signup);
app.post('/signup/add',signup.add);
app.get('/', router.login);
app.post('/login', login.userLogin);
app.get('/dashboard', router.dashboard);
app.get('/questionnaire/setup/step1', router.questionnaire);
Example #2
0
var serviceSetupCallback = function(connection){
     return {
        loginDataService     : new LoginDataService(connection),
        spazaDataServise     : new SpazaDataService(connection),
        productDataService   : new ProductDataService(connection),
        categoryDataService  : new CategoryDataService(connection),
        purchaseDataService  : new PurchaseDataService(connection),
        salesDataService     : new SalesDataService(connection),
        searchDataService    : new SearchDataService(connection),
        suppliersDataService : new SuppliersDataService(connection),
        usersDataService     : new UsersDataService(connection)
    }
};

app.use(compression());
app.use(connectionProvider(dbOptions, serviceSetupCallback));
app.use(cookieParser('shhhh, very secret'));
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 3600000 }, resave: true, saveUninitialized: true}));
app.use(express.static('public'));
app.engine('handlebars', exphbs({defaultLayout: "main"}));
app.set('view engine', 'handlebars');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.get('/products_list',login.userCheck, Products.show);
app.get('/salesPerProduct',login.userCheck, sales.showAllSales);
app.get('/Products/products_edit/:Id',login.userCheck, Products.get);
app.post('/Products/update/:Id',login.userCheck, Products.update);
app.post('/Products/add',login.userCheck, Products.add);
app.get('/Products/delete/:Id',login.userCheck, Products.delete);