Skip to content

The development environment for `micro`

License

Notifications You must be signed in to change notification settings

vercel/micro-dev

Repository files navigation

Micro (Dev) — Asynchronous HTTP microservices

This command line interface provides a belt full of tools that make building microservices usingmicroa breeze! It's only meant to be used in development,not in production(that's wheremicrocomes in).

Features

  • Hot Reloading:When making changes to your code, the server will restart by itself
  • Logs:Incoming and outgoing requests will be logged tostdout
  • Beautiful JSON:When JSON bodies are logged, they're styled and prettified
  • Clipboard Support:The local address is pasted to the clipboard automatically
  • Port Selection:Automatic detection and use of an open port (if the specified one is in use)
  • Debug in Your Network:The network address shown in addition to local one
  • Duration Logs:Calculates and shows the duration for each request
  • Pretty Errors:Prettifies theErrorobject if any exceptions are thrown

Usage

Important:This tool is only meant to be used in development. In production, you should usemicro,which is much lighter and faster (and also comes without the belt of tools used when developing microservices).

When preparing your development environment, firstly installmicro-dev:

npm install --save-dev micro-dev

Note:You'll need at least Node.js v7.6.0 to runmicro-dev.

Next, add a newscriptproperty belowmicroinsidepackage.json:

"scripts":{
"start":"micro",
"dev":"micro-dev"
}

As the final step, start the development server like this:

npm run dev

Debugging

The package can be used in conjunction with the Node.js inspector like this:

"scripts":{
"inspect":"node --inspect node_modules/.bin/micro-dev"
}

As the final step, start the development server like this:

npm run inspect

Contributing

  1. Forkthis repository to your own GitHub account and thencloneit to your local device
  2. Move into the directory of the clone:cd micro-dev
  3. Link it to the global module directory of Node.js:npm link

Inside the project where you want to test your clone of the package, you can now either usenpm link micro-devto link the cloned source to your project's local dependencies or runmicro-devright in your terminal.

Authors