Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abc #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion step03_chapter03_foundations_of_express/guestbook/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
/// <reference path="./typings/tsd.d.ts" />
console.log(require('url').parse('http://localhost:3000/1?p=2').pathname);
var express = require("express");
var url = require('url');
var app = express();
app.use(function (req, res, next) {
var parsedUrl = url.parse(req.url);
//few things whicyh is parser by "url.parse()" method
console.log(parsedUrl.path);
console.log(parsedUrl.pathname);
console.log(parsedUrl.query);
console.log(parsedUrl.search);
console.log(parsedUrl.href);
//and etc.
next();
});
app.listen(3000, function () {
console.log("listening at 3000 \ngoto postman and request like this \nhttp://localhost:3000/1?p=2");
});
22 changes: 20 additions & 2 deletions step03_chapter03_foundations_of_express/guestbook/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/// <reference path="./typings/tsd.d.ts" />

import express = require("express");
import url = require('url');
console.log(require('url').parse('http://localhost:3000/1?p=2').pathname);
let app = express();

app.use((req: express.Request, res: express.Response, next) => {
let parsedUrl = url.parse(req.url);

//few things whicyh is parser by "url.parse()" method

console.log(parsedUrl.path);
console.log(parsedUrl.pathname);
console.log(parsedUrl.query);
console.log(parsedUrl.search);
console.log(parsedUrl.href);

//and etc.

next();

});

app.listen(3000, () => {
console.log("listening at 3000 \ngoto postman and request like this \nhttp://localhost:3000/1?p=2");

});