Search Posts

Category: express

How To Mange Role based access control using postgres,nodejs,angularjs,express (PEAN.JS)?

I am able to login successfully, but how to use session and catch user id,name,roles that are stored in postgres database and send it to angularjs to authenticate the user based on their roles and restrict page which is only for admin. versions-> nodejs – 6.11.2, angularjs – 1.2, postgres – 9.5, express – 4.15 app.post(‘*/login-check’, function (request, response) { console.log(request.body) var uid = request.body.username; console.log(uid); db.one(‘SELECT passwrd,email,user_role FROM mtcpl_user_profile WHERE uid = $1’, [uid]) […]

What is ‘API first architecture’ in modern web application

I try to understand the API first architecture to apply on web application, and found some info here, Advantages of a separate REST backend API? Below I attach an example for better answer of the questions. I start using Angular.js for front-end. Node.js, Express.js for server. folder structure |– server.js |– app |– models |– views |– index.html |– about.html |– contact.html |– controllers |– app.js |– node-modules app folder is a MVC structure for […]

Nodejs Express redirecting does not work

I’m currently trying to redirect a user to a success screen after he click the login button. Everything seems to be working fine but the page does not change. Tried searching online but none of the solution helped. Update It seems that the root cause is because of ‘/’ in routes. Changed it to ‘/home’ and it works now Solved Below is my html, server and route codes index.html <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”> […]

how to save image to folder and save imagePaths to database in MEAN stack using Multer

I have a image collection of following schema: { “productId”: {type: String}, “imagePaths”: {type: Array} } I want to upload multiple images and store corresponding image-paths to database. I searched, and came to know that Multer can perform this action, but I am unable to upload and save image-paths for multiple images. I tried with this Angular code, scope.demoMethod = function(){ console.log(‘Method fired.’); var product = $scope.product; $http.post(‘/demo/upload’, $scope.product) .then(function (res) { console.log(‘Form Data ::’ […]