Git Product home page Git Product logo

Comments (3)

flaming-codes avatar flaming-codes commented on June 2, 2024 2

Adding my 2 cents, the micro-dev-package might be redundant with the built-in live reload feature w/ Node 18.

Specifically, you can use the --watch-flag to get an automated code reload on file changes.

Therefore, the following setup might be sufficient by leveraging the serve-function from the lib. Ofc this only works when you opt-out of the micro-command.

Node.js

18.12.1

package.json

{
  "scripts": {
    "dev": "node --watch index.js",
    "start": "node index.js",
  }
}

index.js

import 'dotenv/config';
import http from 'node:http';
import { send, serve } from 'micro';

const handler = async (req,res) => {
  // ...
};

const server = new http.Server(serve(handler));

server.listen(Number(process.env.PORT) || 8080);

I'm using such a setup in production for a small endpoint to generate OG-images at runtime: https://github.com/flaming-codes/crane-app/tree/main/services/og-img-gen

from micro-dev.

leerob avatar leerob commented on June 2, 2024

Open to contributions 🙏

from micro-dev.

thinkverse avatar thinkverse commented on June 2, 2024

Open to contributions 🙏

Uno-reverse huh? 👀 Guess I'm tinkering with this then, feel free to assign me. 👍

from micro-dev.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.