How to create APIs in node and Executable file for Node.js project - Software Testing

Empowering Technology

Post Top Ad

Responsive Ads Here

May 13, 2019

How to create APIs in node and Executable file for Node.js project

Prerequisite: Node should already installed  in the system
  1. Create a project directory and From inside the directory open CMD and type "npm init” This will ask some basic details to  create package.json.
  2. Install dependencies like express JS etc as per project requirements.
  3. After creating package.json create a main file ex- app.js
Create your  app.js file as.

var express = require("express");
var bodyParser = require('body-parser');
// Set up the express app
const app = express();
app.get("/", function(req, res) {
          return res.send({"Response":"your project is ready"});
const PORT = 5000;
app.listen(PORT, () => {
  console.log('server running on port',PORT)

Your project is now ready. Execute it via using below command:
node app.js
You can Test the request using URL- http://localhost:5000/

Now it's time to create .exe

  1. Install node package pkg. Using command “npm install pkg -g” .exe
  2. After installing run “$ pkg app.js --output EDS.exe” from project directory.
  3. Your .exe will be available on the same directory.
  4. Can be used as windows startup service. (create shortcut and place shortcut to shell:startup directory.)
NOW execute it and enjoy your routes…

1 comment:

  1. After going through your contents I realize that this is the best of my knowledge as it provides the best information and suggestions. This is very helpful and share worthy. If you are looking for the best Google Search Api then visit SERP House. Keep sharing more.


Thanks a lot for your valuable Comment!

Post Bottom Ad

Responsive Ads Here