now-heck
A hacky dev server for ZEIT's Now service (with Next.js support)
Last updated a year ago by davidkaneda .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install now-heck 
SYNC missed versions from official npm registry.

now-hack

A hacky (<100 lines) dev server for ZEIT’s Now v2 service (with Next.js support). now-hack reads from your now.json configuration and:

  • Uses micro-dev to serve any @now/node builds (including glob patterns)
  • Reads your routes config and forward to either a @now/node endpoint or a static file, with support for headers and methods fields
  • Starts a Next.js server to handle any unmatched routes from the previous methods

That said, this project is really just an RFC and I'm curious to see if anyone else finds it useful. If you give it a shot and hit an error, please file a GitHub issue, as I put this together very quickly to meet my own needs and I'm sure there are a lot of cases it doesn't handle.

Installation

yarn add now-hack -D

Usage

Usage
  $ now-hack

Options
  --directory, -d  Directory with the now.json config file
  --port, -p  Port used for the server

Why?

ZEIT’s Now v2 is an awesome service for quickly building and deploying lambdas, but local development can be somewhat tricky. Defining routes is necessary to get the most out of using separate lambdas, especially when using Next.js, but the only way to use these routes seems to be:

  • Use now dev, which appears to be in beta, and currently seems to sacrifice speed for correctness (it creates actual lambdas and can take minutes to start)
  • Use a custom server locally and recreate any routes defined in now.json, which is error-prone and has led to deployment issues for me

TODO

If this seems useful to people, I'd be happy to keep going, and aim to knock these things out next:

  • Watch & livereload microservices (I thought we'd get this for free with micro-dev, but it doesn't seem like it when using it programmatically)
  • Add support for @now/static (This should be pretty straight-forward with serve-handler)
  • Dynamic detection of distDir from next.config.js
  • Proper detection of Next (currently we just launch it from the current path, regardless)
  • Better automatic handling for ENV variables & secrets, possibly through now-env
  • Potentially support @now/node-server (though I feel like this would imply adding a proxy — and is fairly easy to avoid by just exporting a handler from your server instead and using @now/node)
  • Actually give this project some structure (and maybe even a test or two)

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |