codex-lv4-may-2025

Level Navigation: 1 2 3 (4ℹ️) (5ℹ️) 6 7 8 9 10 11 12 13 14⚡ 15⚡ (16ℹ️) 17 18 19 20 21 22 23 24 25 26⚡ 27⚡ 28⚡ 29 30 31 32 33 34 35 36 37 38 39⚡ 40⚡

Level 40 (Challenge): Deploy with Render

Deploy your Express server to Render so it’s accessible on the internet. This allows you to share your API with others and test it from anywhere.

Setup:

  1. Create an account at render.com
    • Note: You may need a credit card for ID verification (free tier available)
  2. Connect your Git repository (GitHub, GitLab, or Bitbucket)
  3. Create a new Web Service (not a Static Site)
  4. Configure your service:
    • Build Command: npm install (or leave default)
    • Start Command: npm start (make sure your package.json has a start script)
    • Environment: Node
  5. Ensure your server listens on the port provided by Render’s PORT environment variable:
Show Me: Render deployment configuration

// src/index.js
import app from './app.js';

// Use Render's PORT environment variable, or default to 3000 for local development
const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

Note: Since you’ve already refactored your app in Level 31, your src/index.js should already have the PORT setup. Just make sure it uses process.env.PORT || 3000 so Render can set the port dynamically.

  1. Deploy and test your live API endpoints using the URL Render provides (e.g., https://your-app.onrender.com)

Success Criteria: