lazy-net
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.
Installation
Before installing this module, you have to:
- Download and install Node.js. If you're in
Linux platform
.
$ 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.