1.0.4 • Published 2 years ago

@koihii/lazy-net v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

lazy-net

lazy-net-image

A simple, lightweight plugin for printing local network when starting Node.js or Express.js server. I made this so you don't have to.

There are currently 2 options for this module.

With outline. with-outline-image

No outline. no-outline-image

Installation

Before installing this module, you have to:

$ npm install nodejs

After that, simply install this module by using this command:

$ npm install @koihii/lazy-net

Usage

lazy-net supports both ESModule and CommonJS. You can either:

// with commonjs.
const lazyNet = require('@koihii/lazy-net');

// with esmodule.
import lazyNet from ('@koihii/lazy-net');

When dealing with Node.js server.

const http = require('http')
const lazyNet = require('@koihii/lazy-net')

const port = process.env.PORT || 3000

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'application/json' })
  res.write("Server's starting with Node.JS")
  res.end()
})

server.listen(port, error => {
  if (error) throw error
  layNet(port)
  // lazyNet(port, true) 'if you want to print outline'.
})

Before using with Express.js server. You must install Express.js framework first by using this command:

$ npm install express
const express = require('express')
const app = express()

const port = process.env.PORT || 3000

app.get('/', (req, res) => {
  res.send("Server's starting with Express.js")
})

app.listen(port, () => {
  layNet(port)
  // lazyNet(port, true) 'if you want to print outline'.
})

Follow this link to see sample files.

Credits

lazy-net is created because I'm tired to create a same piece of code again and again.

License

MIT

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago