ericclemmons / polydev

Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.
282 stars 6 forks source link

polydev

Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.

Demo GIF

Rationale

As your project grows, working on a large or monolithic Node.js app gets slower:

Features

Quick Started

  1. Install

    yarn add polydev --dev
  2. Run polydev

    yarn run polydev --open

For customizing the node runtime, you can use NODE_OPTIONS.

For example, TypeScript can be enabled via ts-node:

polydev --require ts-node/register
# Or
NODE_OPTIONS="--require ts-node/register" polydev

Defining routes

The routes folder is similar to Old-Time™ HTML & PHP, where folders mirror the URL structure, followed by an index.js file:

Route Handlers

Route handlers can be any of the following:

  1. Functional middleware:

    module.exports = (req, res) => {
     res.send("Howdy there!")
    }
  2. Express apps:

    const express = require("express")
    
    module.exports = express().get("/", (req, res) => {
     res.send(`Howdy from ${req.path}!`)
    })
  3. A yarn workspace package:

    module.exports = require("my-package-name")
  4. A package.json path:

    module.exports = require.resolve("my-app/package.json")

    These are considered stand-alone apps that will be ran via yarn dev or yarn start (whichever exists) for development only.

    This is good for when you want to have a separate API server open on process.env.PORT that's not part of your application.

Contributing

See CONTRIBUTING.md.

Author