express.js framework for creating Restful api

i am using express.js to create restful api for my app business logic. in my script directory i have two directories and a json file called package. one of the 2 directories is the node modules where i have my express while the other directory contains three other directories namely: controller,model, and route. the route directory contains my route. Now i have a test route having

var app = express();
var router = express.Router(); // get an instance of the express Router
var bodyParser = require(‘body-parser’);

// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));

var port = process.env.PORT || 8080; // set our port

// middleware to use for all requests
router.use(function(req, res, next) {
// do logging
console.log(‘Something is happening.’);
next(); // make sure we go to the next routes and don’t stop here

// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
router.get(’/’, function(req, res) {
res.json({ message: ‘hooray! welcome to our api!’ });

// more routes for our API will happen here

// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use(’/api’, router);

i am not able to reference the address to this route, can someone help me.


Let me describe some basic rules with Hosted Scripts:

  1. Any JS file deployed in the hierarchy of the /web/scripts folder (meaning you could put in the subdirectories located within that directory) will be treated as a Node.JS script

  2. Every single script will be invoked to process an HTTP request and must produce a response

  3. To enforce rule #2, every single script which will be invoked from the outside must contain the following function: = function ( request, response )
  1. The request and response objects which will be provided to the script by Backendless are expressjs objects

  2. The script will have restricted amount of time to complete its operation. That amount of time is 5 seconds, but can be increased to 20 seconds when you purchase a Function Pack from the Marketplace.

  3. You do not need to upload backendless.js, it is included into the “scope” of your script automatically.

  4. You can upload Node JS modules to the following directory (create node_modules as it will not be there by default):

  1. You do not need to call Backendless.initApp in your scripts, it will be done automatically for you before a script is called.

  2. To invoke a script, get the file’s public URL and send HTTP requests to that URL. This blog post will describe how to get public URL for a file.

  3. Scripts can connect to Backendless and use Backendless API using either REST or the APIs available in backendless.js

  4. Before connecting to an external server, the server’s domain name must be added to the registered external domains list. See the documentation for details.

Before you start coding your own scripts, it is highly recommended to do the following:

    Navigate to /web/scripts/examples/shoppingcart Get a public URL for index.html located in that directory Open the public URL in a browser Follow the example and see how it works
With regards to your code, there are many things which deviate from the rules described above. I know there is minimal information available on Hosted Scripts and we're working on filling that void. I hope the information I shared with you in this post will get you going in the right direction.


Is it possible to setup a GET or POST handler outside of the scripts path/folder? For example from my Parse app.js I have the following which renders some JSON:
app.get(’/ss/1/config/profile’, function(req, res) {
res.set(‘Content-Type’, ‘application/json’);
});Then I’m able to call this from “http://<my_custom_domain>/ss/1/config/profile” which returns a JSON.

I’m new to Express JS, so forgive my ignorace. With Backendless I can’t seem to figure out how to do this without the need for additional paths to the JS file reference including a .js at the end - something like so: http://<my__custom_domain>/<app_id>/<app_version>/files/web/scripts/hello.js. My current app doesn’t like this and needs accepts only “http://<my_custom_domain>” in front of “/ss/1/config/profile”, how do I achieve this? Please help.


Hi Nishal,

You can setup a GET/POST handler if you use Java. This is the functionality available in Backendless API Engine. We’re expanding the product to support Node.js as well.

As for custom domains, you can do it in Backendless. Here’s the documentation describing the feature:


Sorry for not explaining my issue clearly, I don’t want to install a API service as this again needs a different path to call it. I want to install a GET handler at http://<my_custom_domain>/ss/1/config/profile. Perhaps you can give me a few steps to do this.

I checked the Backendless API Engine documentation you pointed me to, but it looks like this will install a GET handler under http://<my_custom_domain>/<app_version>/services/<service_name>/<service_version>/XXX which my current app cannot cope with. Hope that makes sense. I want to install a GET handler at
http://<my_custom_domain>/ss/1/config/profile instead which was possible in Parse using Express.



We do not provide the same level of path customization.


Thanks Mark for the quick response.

Is it possible to work out a solution using both hosted and imported API perhaps? So the imported API proxies to the hosted one? Perhaps the service proxy can have a different path from the hosted service path? Do you know if Backendless supports this possibility?


Yes, it is possible to proxy invocations from the imported to the hosted services, but it would be rather odd:

Client app > Backendless imported Service > Actual service > Backendless hosted service


Is really helpful for all developer making a website on express js word press I will use plug in my upcoming website.