zeekExpress(app.js, package.json) and files created by express and npm(package-lock.json, node_modules)

package.json


{
  "name""zeekexpress",
  "version""1.0.0",
  "description""package created while studying and exploring node and express",
  "main""app.js",
  "scripts": {
    "test""echo \"Error: no test specified\" && exit 1"
  },
  "author""Zeeshan",
  "license""ISC",
  "dependencies": {
    "express""^4.17.1"
  }
} 



app.js

// Express.js, or simply Express, is a back end web application framework for Node.js,
. It is designed for building web applications and APIs.

//Download postman by https://www.postman.com/downloads/ .Postman is an application
 used for API testing. It is an HTTP client that tests HTTP requests, utilizing a 
graphical user interface, through which we obtain different types of responses that 
need to be subsequently validated.


const express = require("express");

const app = express();
const port = 80;

app.get("/", (reqres=> {
    res.send("This is homepage of my first express app")
});
app.get("/about", (reqres=> {
    res.send("This is about page of my first express app")
});
app.post("/about", (reqres=> {
    res.send("This is post of about page of my first express app")
});
app.post("/this", (reqres=> {
    res.status(404).send("Page not found")
});

app.listen(port, () => {
    console.log(`Application is running at port ${port}`)
});






//TERMINAL



//..... INITIALISING NPM AS PACKAGE MANAGER..........


// PS C:\Users\abc\Desktop\webpart\Complete Web Development Part\Express> npm init


// COMPUTER RESPONSE[

// This utility will walk you through creating a package.json file.
// It only covers the most common items, and tries to guess sensible defaults.
// See `npm help json` for definitive documentation on these fields
// and exactly what they do.
// Use `npm install <pkg>` afterwards to install a package and
// save it as a dependency in the package.json file.

//]


//...... Using NPM AS PACKAGE MANAGER...............


// Press ^C at any time to quit.
// package name: (express) zeekexpress
// version: (1.0.0)
// description: package created while studying and exploring node and express
// entry point: (index.js) app.js
// test command:
// git repository:
// keywords:
// author: Zeeshan
// license: (ISC)
// About to write to C:\Users\abc\Desktop\webpart\Complete Web Development Part\Express\package.json:


// COMPUTER RESPONSE[

// {
//   "name": "zeekexpress",
//   "version": "1.0.0",
//   "description": "package created while studying and exploring node and express",
//   "main": "app.js",
//   "scripts": {
//     "test": "echo \"Error: no test specified\" && exit 1"
//   },
//   "author": "Zeeshan",
//   "license": "ISC"
// }

//]


// Is this OK? (yes) yes

//............ INSTALL EXPRESS USING NPM...............


// PS C:\Users\abc\Desktop\webpart\Complete Web Development Part\Express> npm install express


// COMPUTER RESPONSE[

// npm notice created a lockfile as package-lock.json. You should commit this file.
// npm WARN zeekexpress@1.0.0 No repository field.
// + express@4.17.1
// added 50 packages from 37 contributors and audited 50 packages in 10.897s
// found 0 vulnerabilities

//]


//..... RUNNING  EXPRESS ON TERMINAL.......

// PS C:\Users\abc\Desktop\webpart\Complete Web Development Part\Express> node app.js

// COMPUTER RESPONSE[

// Application is running at port 80

//]



Comments

Popular posts from this blog

INDEX OF ZEEK HTML,CSS and JS