Post

Episode 12: Deployment & Final Polish

Prepare your full-stack e-Commerce application for production deployment. Ensure all core features work reliably through testing, and deploy the backend and frontend using a production-ready service (e.g., Render, Railway, Vercel, or Netlify).

Episode 12: Deployment & Final Polish

1. Manual Feature Testing

Test all critical use cases in development mode:

FeatureTest Description
User Register/LoginCreate user, login/logout, invalid credentials
JWT AuthEnsure tokens expire and validate correctly
CartAdd/remove/update items in cart
CheckoutCreate order, view past orders
Admin AccessRestricted to admin users only
OAuthTest Google/GitHub login
CookiesConfirm cookies are set, expire, and secure

2. Optional: Automated Testing (Jest + Supertest)

Install:

1
npm install --save-dev jest supertest

Example test (tests/auth.test.js):

1
2
3
4
5
6
7
8
9
10
11
12
const request = require('supertest');
const app = require('../app');

describe('Auth Routes', () => {
  it('should register a new user', async () => {
    const res = await request(app).post('/api/auth/register').send({
      email: 'test@example.com',
      password: 'password123'
    });
    expect(res.statusCode).toBe(200);
  });
});

In package.json:

1
2
3
"scripts": {
  "test": "jest"
}

Run:

1
npm test

3. Prepare for Production

  • Disable console.logs
  • Enable compression middleware:
    1
    2
    
    const compression = require('compression');
    app.use(compression());
    

Set Secure Cookie Options:

1
2
3
4
5
res.cookie('token', token, {
  httpOnly: true,
  secure: true, // use with HTTPS only
  sameSite: 'Lax',
});
This post is licensed under CC BY 4.0 by the author.