Code Monkey home page Code Monkey logo

serve's Introduction

Serve ๐Ÿ›

Ultralight http server with live reload.
CLI + API


Simple CLI and API

With live reload

Light and modern

No dependencies


One command

npm init serve

Or one function

import serve from 'create-serve';

serve.start();

To start ๐Ÿ›


CLI

By default, it serves public if the folder exists, otherwise root /.
Or you can specify a different folder.

npm init serve [folder]

API

import serve from 'create-serve';

serve.start({
    port: 7000,
    root: '.',
    live: true
});

Live reload

serve.update();

Use any file watcher


Chokidar

import serve from 'create-serve';
import chokidar from 'chokidar';

serve.start();

chokidar.watch('.').on('change', () => {
    serve.update();
});

esbuild

Use the official wrapper for esbuild's watch ย  โ†’ ย  esbuild-serve


Log

Import the util functions to log updates with colours.

import serve, { error, log } from 'create-serve';

serve.update();

hasError
    ? error('ร— Failed') // Red
    : log('โœ“ Updated'); // Green



Native Web

serve's People

Contributors

hum-n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serve's Issues

issue with nodeJs v18

Hello with nodeJs v 18, !i have this issue when I launch serve.start:
node_modules/create-serve/src/utils/getIp.js:6 .find(ip => ip.family == 'IPv4' && !ip.internal).address

Using query params to serve static file leads to 404

Hi,

I'm serving some static files with serve. Notably this one http://172.16.1.169:7000/app.css. I use a timestamp in the query string for cache invalidation, for example http://172.16.1.169:7000/app.css?v=12345. However as soon as we use a query string serve will return a 404 error.

Is that on the purpose?
Thanks

[Request] Open Browser

I really like this repo!

It would be awesome if something like browser: 'chrome' could be added, to open the browser automatically.

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.