Gathering detailed insights and metrics for neumatter
Gathering detailed insights and metrics for neumatter
Gathering detailed insights and metrics for neumatter
Gathering detailed insights and metrics for neumatter
@neumatter/random-bytes
Random Bytes function. Works in node and browser.
@neumatter/record
Module for scanning file directories. Can configure automatic routes with middleware.
@neumatter/is
Module for type checking in javascript.
@neumatter/bvon
Serialize data into buffer. Browser or NodeJS.
npm install neumatter
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
56 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Sep 22, 2023
Latest Version
1.1.6
Package Id
neumatter@1.1.6
Unpacked Size
118.60 kB
Size
30.58 kB
File Count
33
NPM Version
8.11.0
Node Version
16.15.1
Published on
Sep 27, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
8
1
A quick http server framework. ES6 async/await and ECMAScript modules.
request.get
request.emitErr
request.isValidEmail
request.protocol
request.isSecure
request.host
request.hostname
request.port
request.path
request.query
request.href
request.ip
request.URL
request.searchParams
request.params
request.app
response.get
response.set
response.status
response.redirect
response.send
response.json
response.html
response.download
response.file
response.render
response.sent
response.isHead
response.hasContentLength
response.hasType
response.locals
response.viewer
1npm i neumatter --save
There are two options, using a configuration file or by using the constructor.
neumatter.config.json
in root folder."env"
is the options object, that will be passed to the constructor.
"routes"
required. path to routes/pages directory.
"middleware"
optional. path to middleware directory.
1{ 2 "env": { 3 "port": 8080, 4 "static": "./public", 5 "viewer": { 6 "views": "./views", 7 "blocks": "./views/blocks", 8 "layouts": "./views/layouts" 9 } 10 }, 11 "middleware": "./server/middleware", 12 "routes": "./server/routes" 13}
1import Neumatter from 'neumatter' 2 3// loads the configuration and returns Promise<Neumatter> 4const app = await Neumatter.load() 5 6app.listen()
string
Method that will be used to parse NeuRequest.body
.function
Error Handler.boolean
Trust proxy.string
Often set as 'development' or 'production'.number
Port that the application will use.string
Hostname.string
Path to static folder that will be scoped to '/'.object
User defined object, that adds context to application.object
string
Path to view folder.object
string
Path to views folder.string
Path to layouts folder.object
User defined object, that adds data by default to a rebdered view.object
string
Name of the logger.string
Path to folder to hold logs.number
Max size of logs to cache before writing to logs.boolean
If logger is virtual only.boolean
If logger should use json.1import Neumatter from 'neumatter' 2 3const app = new Neumatter() 4 5app.get('/', (req, res) => { 6 res.send('Hello World') 7}) 8 9app.listen()
1import Neumatter from 'neumatter' 2import productRouter from './routes/products.js' 3import productMiddlewareFn from './middleware.js' 4import middlewareFn from './middleware.js' 5 6const app = new Neumatter() 7 8await app.use({ 9 middleware: [middlewareFn] 10}) 11 12await app.use({ 13 path: '/products', 14 middleware: [productMiddlewareFn], 15 router: productRouter 16}) 17 18app.listen()
MiddlewareFn: (request, response, next)
request
: NeuRequest
response
: NeuResponse
next
: NextFunction
1const middlewareFn = (req, res, next) => { 2 // do something 3 next() // call NextFunction 4}
ResponseFn: (request, response, next?)
request
: NeuRequest
response
: NeuResponse
next
: NextFunction
1const responseFn = (req, res) => { 2 // do something 3 res.json({ data: 'Hello World!' }) // send response 4}
neumatter.use(data: { path?, middleware, router? })
data.path
: string|null
data.middleware
: Array<MiddlewareFn>
data.router
: NeuRouter
1import Neumatter from 'neumatter' 2import productRouter from './routes/products.js' 3 4const app = new Neumatter() 5 6const middlewareFn = (req, res, next) => { 7 // do something 8 next() // call NextFunction 9} 10 11await app.use({ 12 middleware: [middlewareFn] 13}) 14 15await app.use({ 16 path: '/products', 17 middleware: [middlewareFn], 18 router: productRouter 19})
neumatter.useMany(prop: [data: { path?, middleware, router? }])
prop
: Array<data>
data.path
: string|null
data.middleware
: Array<MiddlewareFn>
data.router
: NeuRouter
1import Neumatter from 'neumatter' 2import productRouter from './routes/products.js' 3 4const app = new Neumatter() 5 6const middlewareFn = (req, res, next) => { 7 // do something 8 next() // call NextFunction 9} 10 11await app.useMany([ 12 { 13 middleware: [middlewareFn] 14 }, 15 { 16 path: '/products', 17 middleware: [middlewareFn], 18 router: productRouter 19 } 20])
neumatter.listen(options?: { port?, host? })
options.port
: number
Port that the server will run on.options.host
: string
Set the servers host. Defaults to localhost.neumatter.listener()
The function that will be called on server requests. Creating a server and using the function manually will skip the neumatter.init
function.
1import Neumatter from 'neumatter' 2import http from 'http' 3 4const app = new Neumatter() 5 6const server = http.createServer(Neumatter.serverOptions, app.listener())
neumatter.init(serverFn)
serverFn
: typeof http.createServer
1import Neumatter from 'neumatter' 2import http from 'http' 3 4const app = new Neumatter() 5 6const server = app.init(http.createServer)
neumatter['METHOD'](path, middlewareFn|responseFn)
path
: string
Path for url lookup.middlewareFn|responseFn
: MiddlewareFn|Array<MiddlewareFn>|ResponseFn
METHODS
:
get
post
put
patch
trace
options
connect
delete
1import Neumatter from 'neumatter' 2import http from 'http' 3 4const app = new Neumatter() 5 6app.get('/', (req, res) => { 7 res.json({ data: 'Hello World!' }) 8}) 9 10app.post('/page', 11 (req, res, next) => { 12 if (!req.body.name) res.redirect('/') 13 next() 14 }, 15 (req, res) => { 16 // do something 17 res.send('success') 18 } 19)
Neumatter.load()
The function to load the configuration file and return the application.
1import Neumatter from 'neumatter' 2 3const app = await Neumatter.load() 4 5app.listen()
Neumatter.Logger
The class that can be used to create a new Logger instance.
1import Neumatter from 'neumatter' 2 3const logger = new Neumatter.Logger({ virtual: true })
Neumatter.Router
The class that can be used to create a new Router instance.
1import Neumatter from 'neumatter' 2 3const router = new Neumatter.Router()
No vulnerabilities found.
No security vulnerabilities found.