Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodecaf

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodecaf - npm Package Compare versions

Comparing version 0.13.1-rc2 to 0.13.1

lib/run.js

3

lib/api.js

@@ -80,2 +80,5 @@ const assert = require('assert');

if(spec)
this.context.log.warn('`api` is deprecated. This option will be dropped on `v0.14.0`. Use `routes` instead.');
spec?.call(context, proxy);

@@ -82,0 +85,0 @@ }

35

lib/main.d.ts

@@ -1,3 +0,3 @@

import { Server } from 'http';
import WebSocket from 'ws';
import { Server } from 'http'
import WebSocket from 'ws'

@@ -22,2 +22,9 @@ declare namespace Nodecaf {

type RunOptions = {
/** Single or array of Conf object or file path */
conf: ConfObject | string | (ConfObject | string)[],
/** Path to the nodecaf module to be run */
path: string
}
class Logger {

@@ -132,3 +139,3 @@ debug(...args: unknown[]): void

websocket: () => Promise<WebSocket.WebSocket>
} & Record<string, unknown>;
} & Record<string, unknown>

@@ -153,3 +160,3 @@ type RouteHandler = (this: Nodecaf, input: RouteHandlerArgs) => Promise<void> | void

handler: RouteHandlerArgs
};
}

@@ -159,3 +166,6 @@ type AppOpts = {

routes: Route[],
/** A function to build your api endpoints */
/**
* A function to build your api endpoints
* @deprecated This option will be removed on `v0.14.0`. Use `routes` instead.
**/
api?: (this: Nodecaf, methods: Nodecaf.EndpointBuilders) => void,

@@ -203,14 +213,17 @@ /** A function to run whenever the app is starting */

/** Define a POST endpoint to `path` that when triggered will run the `handler` function */
static post: (path: string, handler: Nodecaf.RouteHandler) => Nodecaf.Route
static post(path: string, handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Define a PUT endpoint to `path` that when triggered will run the `handler` function */
static put: (path: string, handler: Nodecaf.RouteHandler) => Nodecaf.Route
static put(path: string, handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Define a PATCH endpoint to `path` that when triggered will run the `handler` function */
static patch: (path: string, handler: Nodecaf.RouteHandler) => Nodecaf.Route
static patch(path: string, handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Define a GET endpoint to `path` that when triggered will run the `handler` function */
static get: (path: string, handler: Nodecaf.RouteHandler) => Nodecaf.Route
static get(path: string, handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Define a DELETE endpoint to `path` that when triggered will run the `handler` function */
static del: (path: string, handler: Nodecaf.RouteHandler) => Nodecaf.Route
static del(path: string, handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Define a fallback `handler` function to be triggered when there are no matching routes */
static all: (handler: Nodecaf.RouteHandler) => Nodecaf.Route
static all(handler: Nodecaf.RouteHandler): Nodecaf.Route
/** Run a given nodecaf app handling uncaught errors and node process signals */
static run(opts: Nodecaf.RunOptions): void
/** A user controlled object whose properties wil be spread in route handler args. */

@@ -217,0 +230,0 @@ global: Record<string, unknown>

@@ -202,2 +202,3 @@ const

module.exports.all = handler => ({ all: true, handler });
module.exports.all = handler => ({ all: true, handler });
module.exports.run = require('./run');
{
"name": "nodecaf",
"version": "0.13.1-rc2",
"version": "0.13.1",
"description": "Nodecaf is a light framework for developing RESTful Apps in a quick and convenient manner.",

@@ -42,12 +42,12 @@ "main": "lib/main.js",

"confort": "^0.2.0",
"cookie": "^0.4.1",
"cookie": "^0.5.0",
"cookie-signature": "^1.1.0",
"cors": "^2.8.5",
"golog": "^0.5.0",
"ws": "^8.6.0"
"ws": "^8.7.0"
},
"devDependencies": {
"muhb": "^3.1.0",
"muhb": "^3.1.1",
"toml": "^3.0.0"
}
}

@@ -33,3 +33,3 @@ # [Nodecaf](https://gitlab.com/GCSBOSS/nodecaf)

const Nodecaf = require('nodecaf');
const api = require('./api');
const routes = require('./routes');

@@ -41,4 +41,4 @@ module.exports = () => new Nodecaf({

// Load your routes and API definitions.
api,
// Load your routes.
routes,

@@ -57,10 +57,12 @@ // Perform your server initialization logic.

4. Add your routes in `lib/api.js`
4. Add your routes in `lib/routes.js`
```js
module.exports = function({ post, get, del, head, patch, put, all }){
const { post, get, del, head, patch, put, all } = require('nodecaf');
module.exports = [
// Define routes with their handler functions (async or regular no matter).
get('/foo/:f/bar/:b', FooBar.read);
post('/foo/:f/bar', FooBar.write);
get('/foo/:f/bar/:b', FooBar.read),
post('/foo/:f/bar', FooBar.write),
// ...

@@ -70,3 +72,3 @@

all(Foo.atLast)
};
];
```

@@ -76,3 +78,2 @@

## How to Run my App

@@ -216,3 +217,3 @@

console.log(conf.key); //=> 'value'
});
})
```

@@ -310,3 +311,3 @@

res.end('My regular function works!');
});
})

@@ -316,3 +317,3 @@ get('/my/other/thing', async function({ res }){

res.end('My async function works too!');s
});
})
```

@@ -328,3 +329,3 @@

throw new Error('Should respond with a 500');
});
})
```

@@ -343,3 +344,3 @@

});
});
})
```

@@ -358,3 +359,3 @@

}
});
})
```

@@ -374,3 +375,3 @@

doStuff();
});
})
```

@@ -413,3 +414,3 @@

// use your global stuff
});
})
```

@@ -416,0 +417,0 @@

Sorry, the diff of this file is not supported yet

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