node.js - Express app - Host on Heroku and use Parse as backend -
for express app want use parse handle data. parse's hosting options web apps seem limited (caped @ 500 files , 500mb), want use heroku host app. have managed set express app on heroku, can not quite figure out how access parse app in it. i've searched around, there not seem documentation on this, , struggling work.
here index.js express app:
var express = require('express'); var bodyparser = require('body-parser') var app = express(); app.set('port', (process.env.port || 5000)); app.use(express.static(__dirname + '/public')); // views directory template files app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.use(bodyparser.urlencoded({ extended: true })); app.use(bodyparser.json()); app.get('/', function(request, response) { response.render('pages/public'); }); app.get('/login', function(request, response) { response.render('pages/login'); }); // clicking submit on login form triggers this. app.post('/login', function(req, res) { parse.user.login(req.body.username, req.body.password).then(function() { // login succeeded, redirect homepage. res.redirect('pages/loggedin'); }, function(error) { // login failed, redirect login form. res.redirect('pages/login'); }); });
in app.post('/login'
i have parse function use log in users, parse not connected throws error. how let express app data parse?
my package.json files looks so:
{ "name": "node-js-getting-started", "version": "0.1.4", "description": "a simple node.js app using express 4", "main": "index.js", "scripts": { "start": "node index.js" }, "dependencies": { "ejs": "^2.3.1", "express": "~4.9.x", "body-parser": "1.13.x" }, "engines": { "node": "0.12.2" }, "repository": { "type": "git", "url": "https://github.com/heroku/node-js-getting-started" }, "keywords": [ "node", "heroku", "express" ], "license": "mit" }
thanks help!
another hour of googling , came across these links proved useful: https://medium.com/@spacekid/getting-started-with-parse-node-js-express-b2c79798cc7d http://blog.parse.com/learn/engineering/the-javascript-sdk-in-node-js/
Comments
Post a Comment