Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Advanced Express Web Application Development
Advanced Express Web Application Development

Advanced Express Web Application Development: For experienced JavaScript developers this book is all you need to build highly scalable, robust applications using Express. It takes you step by step through the development of a single page application so you learn empirically.

eBook
$9.99 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Advanced Express Web Application Development

Chapter 2. Building a Web API

With the foundations in place, we begin the process of building a Web API for our Vision project. We will start by setting up a persistence layer using MongoDB. We will then implement, feature-by-feature, the various aspects of our Web API.

Persisting data with MongoDB and Mongoose


MongoDB is an open source document-oriented database system. MongoDB stores structured data such as JSON-like documents, simplifying integration.

Let's start by creating a MongoDB schema for our project. The schema contains some basic information related to the project such as the project's name, a GitHub access token, a user, and a list of repositories.

Let's install Mongoose, a MongoDB Object Document Mapper for Node.js; it provides a schema-based solution to modeling your data.

npm install mongoose --save

Let's configure our application to use MongoDB and Mongoose; we add a URL for MongoDB to our configuration files ./lib/config/*.js:

{
  "express": {
    "port": 3000
  },
  "logger" : {
    "filename": "logs/run.log",
    "level": "silly"
  },
  "mongo": {
    "url":  "mongodb://localhost/vision"
  }
}

Let's create a MongoDB connection module, ./lib/db/index.js, which simply pulls in the MongoDB URL from our Winston configuration and opens a connection...

GitHub tokens


In order to acquire a GitHub token, log in to your GitHub account and go to the Accounts section of your Settings page. Here you will need to enter your password. Now click on Create new token, and name the token, if you prefer. Click on the copy to clipboard button in order to copy the token into the following login file.

Let's create a login file—./test/login.js—with the data from GitHub. We will use this in order to call the GitHub API; this will be removed in a later chapter.

module.exports = {
  user : '#USER#'
  token : '#TOKEN#'
}

Feature: Create a project


As a vision user
I want to create a new project
So that I can monitor the activity of multiple repositories

Let's add a test to our existing set of tests for our feature Create a project. This resource will POST a project to the route /project and return a 201 Created status code. The following test: ./test/project.js is the 201 Created test.

Tip

This book will not document the full set of tests for a feature. Please refer to the source code for the full set of tests.

In this example, SuperTest executes an end function that returns a response; this allows us to check the headers and body of the response.

describe('when creating a new resource /project', function(){
  var project = {
    name: "new project"
    , user: login.user  
    , token: login.token
    , repositories    : [ "12345", "9898" ]
  };

  it('should respond with 201', function(done){
    request(app)
    .post('/project')
    .send(project)
    .expect('Content-Type', /json/)
    .expect(201)
    .end...

Feature: Get a project


As a vision user
I want to get a project
So that I can monitor the activity of selected repositories

Let's add a test to the existing set of tests ./test/project.js for our feature Get a project. This resource will GET a project from route /project/:id, and return a 200 OK status.

Let's install underscore.js; a utility-belt library that provides functional programming support:

npm install underscore --save
describe('when requesting an available resource /project/:id', function(){
  it('should respond with 200', function(done){
    request(app)
    .get('/project/' + id)
    .expect('Content-Type', /json/)
    .expect(200)
    .end(function (err, res) {
      var proj = JSON.parse(res.text);
      assert.equal(proj._id, id);
      assert(_.has(proj, '_id'));
      assert(_.has(proj, 'name'));
      assert(_.has(proj, 'user'));
      assert(_.has(proj, 'token'));
      assert(_.has(proj, 'created'));
      assert(_.has(proj, 'repositories'));
      done();
    });
  }...

Feature: Edit a project


As a vision user
I want to update a project
So that I can change the repositories I monitor

Let's add a test to our existing set of tests ./test/project.js for our Edit a project feature. This resource will PUT a project to route /project/:id, and return a 204 No Content status:

describe('when updating an existing resource /project/:id', function(){
  var project = {
    name: "new test name"
    , user: login.user  
    , token: login.token
    , repositories    : [ "12345", "9898" ]
  };

  it('should respond with 204', function(done){

    request(app)
    .put('/project/' + id)
    .send(project)
    .expect(204, done);
  });
});

Let's implement the Edit a project feature ./lib/project/index.js and add a put function. We attempt to retrieve a project by calling the static function Project.findOne. If we get an error, we return it; if we cannot find the project, we return null. If we find the project, we update it and return the project:

Project.prototype.put = function...

Feature: Delete a project


As a vision user
I want to delete a project
So that I can remove projects no longer in use

Let's add a test to ./test/project.js for our feature Delete a project. This resource will DELETE a project at route /project/:id and return a 204 No Content status:

describe('when deleting an existing resource /project/:id', function(){
  it('should respond with 204', function(done){
    request(app)
    .del('/project/' + id)
    .expect(204, done);
  });
});

Let's implement the Delete a project feature ./lib/project/index.js and add a del function. We attempt to delete a project by calling the static function Project.findOne. If we get an error, we return it; if we cannot find the project, we return null. If we find the project, we delete it and return an empty response.

Project.prototype.del = function(id, callback){
  var query = {'_id': id};

  ProjectSchema.findOne(query, function(error, project) {
    if (error) return callback(error, null);
    if (project == null) return...

Feature: List projects


As a vision user
I want to see a list of projects
So that I can select a project I want to monitor

Let's add a test to ./test/project.js for our feature List projects. This resource will GET all projects from route /project and return a 200 Ok status.

describe('when requesting resource get all projects', function(){
  it('should respond with 200', function(done){
    request(app)
    .get('/project/?user=' + login.user)
    .expect('Content-Type', /json/)
    .expect(200)
    .end(function (err, res) {
      var proj = _.first(JSON.parse(res.text))
      assert(_.has(proj, '_id'));
      assert(_.has(proj, 'name'));
      assert(_.has(proj, 'user'));
      assert(_.has(proj, 'token'));
      assert(_.has(proj, 'created'));
      assert(_.has(proj, 'repositories'));
      done();
    });
  });
});

Let's implement the List projects feature ./lib/project/index.js and add an all function. We attempt to retrieve all projects by calling the static function Project.find and...

GitHub API


Our project API is complete but things are about to get a little more complicated as we attempt to communicate with the GitHub API. Let's install the following modules.

The github module provides an object-oriented wrapper for the GitHub v3 API; the complete API for this module can be found at http://mikedeboer.github.io/node-github/.

npm install github --save

The async module is a utility module that provides around 20 powerful functions for working with asynchronous JavaScript. The async module is a control-flow module and will allow us to do operations over IO in a clean, controlled way.

npm install async --save

The moment.js is a library for parsing, validating, manipulating, and formatting dates.

npm install moment --save

Feature: List repositories


As a vision user
I want to see a list of all repositories for a GitHub account
So that I can select and monitor repositories for my project

Let's add a test to ./test/github.js for our feature List repositories. This resource will GET all repositories for a project from the route project/:id/repos and return a 200 Ok status:

describe('when requesting an available resource /project/:id/repos', function(){
  it('should respond with 200', function(done){
    this.timeout(5000);
    request(app)
    .get('/project/' + id + '/repos/')
    .expect('Content-Type', /json/)
    .expect(200)
    .end(function (err, res) {
      var repo = _.first(JSON.parse(res.text))
      assert(_.has(repo, 'id'));
      assert(_.has(repo, 'name'));
      assert(_.has(repo, 'description'));
      done();
    });
  });
});

The first thing we need to do is create a GitHubRepo module in ./lib/github/index.js. We start by importing the required modules including github. We define a constructor...

Feature: List commits


As a vision user
I want to see a list of multiple repository commits in real time
So that I can review those commits

Let's add a test to ./test/github.js for our List commits feature. This resource will GET the 10 most recent commits for all repositories in a project via the route project/:id/commits and return a 200 OK status:

describe('when requesting an available resource /project/:id/commits', function(){
  it('should respond with 200', function(done){
    this.timeout(5000);
    request(app)
    .get('/project/' + id + '/commits')
    .expect('Content-Type', /json/)
    .expect(200)
    .end(function (err, res) {
      var commit = _.first(JSON.parse(res.text))
      assert(_.has(commit, 'message'));
      assert(_.has(commit, 'date'));
      assert(_.has(commit, 'login'));
      assert(_.has(commit, 'avatar_url'));
      assert(_.has(commit, 'ago'));
      assert(_.has(commit, 'repository'));
      done();
    });
  });
});

Let's implement the List commits feature...

Feature: List issues


As a vision user
I want to see a list of multiple repository issues in real time
So that I can review and fix issues

Let's add a test to ./test/project.js for our List issues feature. This resource will GET all projects from the route project/:id/issues and return a 200 OK response:

describe('when requesting an available resource /project/:id/issues', function(){
  it('should respond with 200', function(done){
    this.timeout(5000);
    request(app)
    .get('/project/' + id + '/issues')
    .expect('Content-Type', /json/)
    .expect(200)
    .end(function (err, res) {
      var issue = _.first(JSON.parse(res.text))
      assert(_.has(issue, 'title'));
      assert(_.has(issue, 'state'));
      assert(_.has(issue, 'updated_at'));
      assert(_.has(issue, 'login'));
      assert(_.has(issue, 'avatar_url'));
      assert(_.has(issue, 'ago'));
      assert(_.has(issue, 'repository'));
      done();
    });
  });
});

Let's implement the feature List issues and add it to...

Validating parameters with param middleware


You will have noticed that we have repeated the id validation in each of our routes. Let's improve things using app.params.

Here is the offending line of code that simply checks to see if our id is a valid MongoDB id:

if (req.params.id.match(/^[0-9a-fA-F]{24}$/) == null)
  return res.json(400, 'Bad Request');

Let's add a middleware to handle this ./lib/middleware/id.js. We define a validate function that takes four parameters, with the last being the value of id. We then validate the id parameter, returning a 400 Bad Request, if it's invalid. We then call next(), which calls the next middleware in our Express stack:

exports.validate = function(req, res, next, id){
  if (id.match(/^[0-9a-fA-F]{24}$/) == null)
  return res.json(400, 'Bad Request');
  next();
}

Now we can use this id middleware in our Express server. Let's include the param middleware and add this line before the first route so that it applies to all of our routes: ./lib/express/index...

Route improvements


We now have quite a few routes required in our Express server; let's clean this up. A common pattern in node.js is to include an index file that returns all files in its current directory. We will use require-directory to do this for us:

npm install require-directory –save

Let's create a new module ./lib/routes/index.js. with the following code:

var requireDirectory = require('require-directory');
module.exports = requireDirectory(module, __dirname, ignore);

Now, all routes in the ./lib/routes/ folder will be exposed under a single variable, routes:

  var express = require('express')
  , http = require('http')
  , config = require('../configuration')
  , db = require('../db')
  , routes = require('../routes')
  , notFound = require('../middleware/notFound')
  , id = require('../middleware/id')
  , app = express();

app.use(express.bodyParser());
app.set('port', config.get('express:port'));
app.use(express.logger({ immediate: true, format: 'dev' }));
app.param('id', id.validate...

Summary


We have now completed our Web API. We have implemented a basic MongoDB provider; we are using Mongoose to give us a bit of schema support. We have also made a small improvement to our Express server, cleaning up the routes.

In the next chapter, we will consume this API when we build our client.

Left arrow icon Right arrow icon

Key benefits

  • Learn how to build scalable, robust, and reliable web applications with Express using a test-first, feature-driven approach
  • Full of practical tips and real world examples, and delivered in an easy-to-read format
  • Explore and tackle the issues you encounter in commercially developing and deploying an Express application

Description

Building an Express application that is reliable, robust, maintainable, testable, and can scale beyond a single server requires a bit of extra thought and effort. Express applications that need to survive in a production environment will need to reach out to the Node ecosystem and beyond, for support.You will start by laying the foundations of your software development journey, as you drive-out features under test. You will move on quickly to expand on your existing knowledge, learning how to create a web API and a consuming client. You will then introduce a real-time element in your application.Following on from this, you will begin a process of incrementally improving your application as you tackle security, introduce SSL support, and how to handle security vulnerabilities. Next, the book will take you through the process of scaling and then decoupling your application. Finally, you will take a look at various ways you can improve your application's performance and reliability.

Who is this book for?

If you are an experienced JavaScript developer who wants to build highly scalable, real-world applications using Express, this book is ideal for you. This book is an advanced title and assumes that the reader has some experience with Node.js, JavaScript MVC web development frameworks, and has heard of Express before, or is familiar with it. You should also have a basic understanding of Redis and MongoDB.

What you will learn

  • Drive Express development via test
  • Build and consume a RESTful web API using client and server-side templating
  • Secure and protect Express with passport authentication and SSL via stud
  • Scale Express beyond a single server with Redis and Hipache
  • Decouple Express for improved scalability and maintainability
  • Support real-time application development with Socket.IO
  • Handle failures with a minimum impact to service availability using cluster and domains
  • Understand and cope with Express limitations, including when and where to go for help
Estimated delivery fee Deliver to Ecuador

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 25, 2013
Length: 148 pages
Edition : 1st
Language : English
ISBN-13 : 9781783282494
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Ecuador

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Publication date : Nov 25, 2013
Length: 148 pages
Edition : 1st
Language : English
ISBN-13 : 9781783282494
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 153.97
Express Web Application Development
$54.99
Advanced Express Web Application Development
$43.99
Mastering Node.js
$54.99
Total $ 153.97 Stars icon
Banner background image

Table of Contents

7 Chapters
Foundations Chevron down icon Chevron up icon
Building a Web API Chevron down icon Chevron up icon
Templating Chevron down icon Chevron up icon
Real-time Communication Chevron down icon Chevron up icon
Security Chevron down icon Chevron up icon
Scaling Chevron down icon Chevron up icon
Production Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(8 Ratings)
5 star 50%
4 star 12.5%
3 star 37.5%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Gabriela Jack Dec 20, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was given a copy of this book to review it and I'm pleased because it is a really good book.Although not completely unfamiliar, I am a newbie when it comes to Node.js, Express and related technologies. I have read my fair share of beginners tutorials and books, though, so it wasn't really hard to follow along, plus the book is well structured and the code included with it works without having to debug it or troubleshoot it, which makes life so much easier.There are several things I really liked about this book. First of all, the fact that it doesn't just offer a collection of short snippets and mini-tutorials, but sticks with one complete, real-life like application from end to end, while also teaching you best practices and the correct approach towards designing and structuring your applications. It's really hard to find a book about Express or Node.js that does that. Most of the books and tutorials I've found deal with short and simplified examples of how to build your own chat application and such.Of course, a more realistic example also means that you will find yourself incorporating all sorts of dependencies, libraries and such while working your way through the chapters of this book, because this is what you're likely to find in a real life application. If you, like me, are unfamiliar with some of these libraries, modules and technologies, I recommend that you spend sometime reading about them so you don't just copy and execute the commands included in the book without knowing what you're doing. While the book usually tells you what those libraries and dependencies are, why we need them and how we'll use them in the application, it's really beyond its scope to go into much detail about any of them. It can feel a bit overwhelming for a newbie! That's why I plan on returning to the book and working through all the parts of the example application all over again after I become more comfortable with Grunt, MongoDB and Redis.I was also greatly impressed by the fact that the example application in this book incorporates TDD, specially because that was one of the reasons that first got me interested in learning about Node.js.The only problem I had with this book was that I was never able to access the github repository that the book directs the reader to in chapter one to obtain the source code. I had to get the source code from Packtpub, instead.I would recommend this book to all that want to learn about Node.js and Express beyond the basic tutorials. This is not a tutorial, no, but it is a fine "blueprint" for what a real-life Node.js application looks like.
Amazon Verified review Amazon
Jamie Moon Dec 18, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Recently I started the web service project that transform the legacy APIs and some function to REST open API.In this project, of course, I also had to make the web UI for it and backend system to monitor the usage of each API, user....Although I'm a newbie of Node.js and the way of getting things done, practical examples and experiences were definitelyhelpful.Why did I choose this rating?Node.js is great, but I think people who doesn't have much experiences about Linux system and administration thingscan be confused. this books introduced the things like that with proper depth.Who should I recommend this product to?My project members and everyone who want to know real world node.js examples
Amazon Verified review Amazon
Doug Duncan Dec 20, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Advanced Express Web Application Development by Andrew Keig walks you through building an application that serves as a dashboard for software projects and ties into GitHub to give a single-screen snapshot of the project's issues and commits.The book is well written and easy to follow along with. Being that the author walks you through building a sample application, each chapter logically builds on the previous and steps you through the changes one would make to code as design progresses through the application design.The application is built on Node.js and uses the express framework, but there are numerous other node modules in use including the use of both MongoDB and Redis as data stores. The book is written in a way that even someone pretty new to node should be able to follow along without too many problems.The book progresses through setting up a real simple version of the application and going through iterations where you add in real-time updates and security. It finally ends with how to handle scalability and advice for production deployments.I would definitely recommend this book to anyone who's interested in using node and express for web development.
Amazon Verified review Amazon
David Melamed Dec 15, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had the chance to read an early release of the book and it is just amazing. It is fuelled with all the best practices in the node.js world, the most useful modules everyone should know and gives a great insight about to build a high-scalable node.js based project from scratch.I particularly loved how the sample project - a Github project manager - was structured in a very decoupled and organised way, which allows a clear understanding of the structure as well as more code reuse.Don't be intimated by the "Advanced" adjective! This book should be read by everyone and even newbies in the field will understand most of it.
Amazon Verified review Amazon
Brandon Taylor Jan 28, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
There seem to be some environmental differences from the author's development environment to mine, as I've had to make some adjustments to get testing with grunt and mocha to work as expected.Aside from a couple of errata, this is a well written book that is pretty easy to follow. The author was kind enough to assist me on Github, although we seem to have a difference in opinion on the definition of errata, as you'll see in the comments.In an effort to offer a more constructive review, this has been one of the better books I've purchased for developing with Node. The writing style is easy to follow, without a lot of rambling. I like how the code in the sample application is organized and I think the functionality of the sample project fits very well to modern development contexts.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela