1.0.0 • Published 4 years ago

@emanuelmoraes-dev/www-express v1.0.0

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

www-express

Simple utility that provides a function that loads a express js application with JavaScript/TypeScript

Examples

Simple Example

import express from 'express'
import { www } from 'www-express'

const app = express()

app.get('/', (_, res) => {
	res.status(200).write('wellcome')
	res.end()
})

www(app)

Most Complete Example

import express from 'express'
import { www } from 'www-express'

import fdebug from 'debug' // optional
import path from 'path' // optional
import cookieParser from 'cookie-parser' // optional
import logger from 'morgan' // optional

const app = express()

const debug = fdebug('example:server') // optional

app.use(logger('dev')) // optional
app.use(express.json()) // optional
app.use(express.urlencoded({ extended: false })) // optional
app.use(cookieParser()) // optional
app.use(express.static(path.join(__dirname, 'public'))) // optional

app.get('/', (_, res) => {
	res.status(200).write('wellcome')
	res.end()
})

// "debug" is optional (default value: null)
www(app, debug)

Run (Deafult Port: 3000)

node example.js

Run By Changing The Default Port (Unix Like)

PORT=3001 node example.js

Run By Changing The Default Port (Windows)

set PORT=3001 & node example.js

Run With Debug Package (Unix Like)

DEBUG=example:* node example.js

Run With Debug Package (Windows)

set DEBUG=example:* & node example.js