www-express
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

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).catch(console.error)

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).catch(console.error)

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

Readme

Keywords

Package Sidebar

Install

npm i www-express

Weekly Downloads

8

Version

2.0.5

License

MIT

Unpacked Size

13.9 kB

Total Files

9

Last publish

Collaborators

  • emanuelmoraes-dev