Socket
Socket
Sign inDemoInstall

rjweb-server

Package Overview
Dependencies
Maintainers
1
Versions
373
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rjweb-server - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

35

index.js

@@ -100,3 +100,3 @@ const sleep = (milliseconds) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds)

const ctr = {
let ctr = {
// Properties

@@ -125,2 +125,3 @@ header: headers,

res.setHeader('X-Powered-By', 'rjweb-server')
if (exists) {

@@ -130,8 +131,18 @@ res.writeHead(200, corsHeaders)

await urls[executeUrl].code(ctr).catch((e) => {
res.write(e.message)
res.end()
if (!options.hasOwnProperty('reqError')) {
res.statusCode = 500
res.write(e.message)
res.end()
} else {
ctr.error = e.message
options.reqError(ctr).catch((e) => {
res.statusCode = 500
res.write('error errored')
res.end()
}); return res.end()
}
}); return res.end()
} else {
if (!options.hasOwnProperty('notfound')) {
if (!options.hasOwnProperty('notFound')) {
let pageDisplay = ''

@@ -147,5 +158,15 @@ Object.keys(urls).forEach(function(url) {

} else {
await options.notfound(ctr).catch((e) => {
res.write(e.message)
res.end()
await options.notFound(ctr).catch((e) => {
if (!options.hasOwnProperty('reqError')) {
res.statusCode = 500
res.write(e.message)
res.end()
} else {
ctr.error = e.message
options.reqError(ctr).catch((e) => {
res.statusCode = 500
res.write('error errored')
res.end()
}); return res.end()
}
}); return res.end()

@@ -152,0 +173,0 @@ }

2

package.json
{
"name": "rjweb-server",
"version": "0.1.4",
"version": "0.2.0",
"description": "Easy Way to create a Web Server in Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -57,3 +57,3 @@ <h1 align="center">Welcome to rjweb-server 👋</h1>

Custom 404 Page
Custom 404 / 500 Page
```js

@@ -71,5 +71,8 @@ /* ************ *

urls: routes,
notfound: async(ctr) {
notFound: async(ctr) {
ctr.status(404)
ctr.print(`page "${ctr.requestPath.pathname}" not found`)
}, reqError: async(ctr) => {
ctr.status(500)
ctr.print(`ERROR!!! ${ctr.error}`)
}

@@ -76,0 +79,0 @@ }).then((res) => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc