Permalink
Browse files

Added openshift support

  • Loading branch information...
1 parent c2960db commit bac6c3930506b66433fd943d9bb578e0dc6ade74 @itswadesh committed Nov 15, 2015
Showing with 52 additions and 42 deletions.
  1. +2 −1 package.json
  2. +36 −36 public/app/products.js
  3. +7 −2 public/index.html
  4. +7 −3 server.js
View
@@ -10,5 +10,6 @@
"express": "^4.13.3",
"mongoose": "^4.1.3",
"node-restful": "^0.2.2"
- }
+ },
+ "main": "server.js"
}
@@ -1,37 +1,37 @@
-app.controller('ProductsCtrl', function($scope, Product, ngProgress, toaster) {
-
-$scope.product = new Product();
-
-var refresh = function() {
- $scope.products = Product.query();
- $scope.product ="";
-}
-refresh();
-
-$scope.add = function(product) {
- Product.save(product,function(product){
- refresh();
- });
-};
-
-$scope.update = function(product) {
- product.$update(function(){
- refresh();
- });
-};
-
-$scope.remove = function(product) {
- product.$delete(function(){
- refresh();
- });
-};
-
-$scope.edit = function(id) {
- $scope.product = Product.get({ id: id });
-};
-
-$scope.deselect = function() {
- $scope.product = "";
-}
-
+app.controller('ProductsCtrl', function($scope, Product, ngProgress, toaster) {
+
+$scope.product = new Product();
+
+var refresh = function() {
+ $scope.products = Product.query();
+ $scope.product ="";
+}
+refresh();
+
+$scope.add = function(product) {
+ Product.save(product,function(product){
+ refresh();
+ });
+};
+
+$scope.update = function(product) {
+ product.$update(function(){
+ refresh();
+ });
+};
+
+$scope.remove = function(product) {
+ product.$delete(function(){
+ refresh();
+ });
+};
+
+$scope.edit = function(id) {
+ $scope.product = Product.get({ id: id });
+};
+
+$scope.deselect = function() {
+ $scope.product = "";
+}
+
})
View
@@ -1,12 +1,17 @@
<!DOCTYPE>
<html ng-app="myApp">
<head>
+ <title>Simple demonstration of AngularJS with ReSTful API - AngularCode</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/ngProgress.css">
<link rel="stylesheet" href="css/toaster.css">
-
+<style>
+[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
+display: none !important;
+}
+</style>
</head>
-<body>
+<body ng-cloak>
<div class="container" ng-controller="ProductsCtrl">
<form name="Codenx" novalidate>
<table class="table">
View
@@ -5,7 +5,8 @@ var mongoose = require('mongoose');
var bodyParser = require('body-parser');
// MongoDB
-mongoose.connect('mongodb://localhost/products-demo');
+
+mongoose.connect(process.env.OPENSHIFT_MONGODB_DB_URL || 'mongodb://localhost/products-demo');
// mongoose.connection.on('error', function(){});
// Express
@@ -20,5 +21,8 @@ app.use(bodyParser.urlencoded({ extended: true }));
app.use('/api', require('./routes/api'));
// Start server
-app.listen(3000);
-console.log('Server is running on port 3000');
+var port = process.env.OPENSHIFT_NODEJS_PORT || 8080
+, ip = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
+app.listen(port, ip, function() {
+ console.log('Express server listening on %d', port);
+});

0 comments on commit bac6c39

Please sign in to comment.