Search code examples
expressparse-platformwebstorm

Running a Parse app locally on WebStorm


I have recently started working with a new stack of technologies and need some help.

I'm working on an existing parse.com app. The guys have been using Sublime 2.

I'm trying to get the app running on WebStorm. After doing some research and trying a couple of things I still can't run it locally.

I have created a new Node.js Express app using WebStorm and that works beautifully, so I'm assuming my environment (WIN10) is set up correctly.

I had to create an package.json for it and change some libraries around like bodyParser (it was using Parse.BodyParser, which is deprecated AFAIK)

I installed all packages/plugins using npm, and WebStorm is no longer complaining about missing references ect..

Here is the first lines:

var express = require('express');
var parseExpressHttpsRedirect = require('parse-express-https-redirect');
var parseExpressCookieSession = require('parse-express-cookie-session');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');

var app = express();
app.set('views', 'cloud/views');
app.set('view engine', 'ejs');
app.use(parseExpressHttpsRedirect()); // Require user to be on HTTPS.
app.use(bodyParser);
app.use(cookieParser('SecretCodeHere'));
app.use(parseExpressCookieSession({
    cookie: {
        maxAge: 86400000
    }
}));

And then we have this gem at the end of the file:

app.listen();

Now I'm assuming that this works because this gets deployed to parse.com and it does some Magic to host it.

Now the app starts when I run it but I cant connect to it. I've tried the following:

Connecting to https://localhost:63342/ProjectName/ (this is the default behavior AFAIK) after running gives me 404 Not Found Index file doesn't exist.

Changing the code to :

app.listen(3000, function () {
    console.log('App listening on port 3000!');
});

That gives me localhost unexpectedly closed the connection. ERR_CONNECTION_CLOSED

Is there anything else I can try?


Solution

  • If you want to host the server on port 3000, you would need to import the http module

    import http = require('http');
    
    http.createServer(app).listen(3000, function () {
      console.log('Express server listening on port 3000'));
    });