Gathering detailed insights and metrics for nanonode-express
Gathering detailed insights and metrics for nanonode-express
Gathering detailed insights and metrics for nanonode-express
Gathering detailed insights and metrics for nanonode-express
npm install nanonode-express
Typescript
Module System
Node Version
NPM Version
56.1
Supply Chain
87.9
Quality
73.9
Maintenance
50
Vulnerability
96.7
License
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Minified
Minified + Gzipped
Latest Version
0.5.4
Package Id
nanonode-express@0.5.4
Unpacked Size
61.25 kB
Size
14.34 kB
File Count
13
NPM Version
7.5.3
Node Version
12.21.0
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
A tiny and very opinionated nanoservices framework inspired by expressjs.
This is library to host all the common and boring features shared between our nanoservices.
WARNING: This library is a work in progress and isn't intended to be general purpose.
Things like:
npm install --save nanonode-express
1import * nano from 'nanonode-express'; 2 3// 4// Entry point for the nanoservice. 5// The 'export' keyword is for testing. 6// 7export async function main(service: INanoService): Promise<void> { 8 9 // 10 // Handle a message, do some work, then publish a new message. 11 // This uses Rabbitmq under the hood for reliable message handling. 12 // The callback is wrapped for error handling, performance metrics and message tracing. 13 // A bit like Express's post function. 14 // 15 service.on("do-some-work", async (args, res) => { 16 // 17 // ... do some work ... 18 // 19 20 // 21 // Emit an outgoing event. 22 // 23 await service.emit("another-event", { your: "json data goes here" }); 24 25 // 26 // Acknowledge that the message was handled correctly. 27 // 28 await res.ack(); 29 }); 30 31 // 32 // Create a HTTP GET request handler for a particular route. 33 // Do some work and return some json. 34 // Under the hood this is handled by Express, but the callback is wrapped for 35 // error handling, performance metrics and request tracing. 36 // 37 service.get('/another-end-point', async (req, res) => { 38 // 39 // ... do some work ... 40 // 41 42 // 43 // Respond to the request with some JSON data. 44 // 45 await res.json({ 46 your: "json data" 47 }); 48 }); 49 50 // 51 // End points can be easily forwarded to internal services. 52 // 53 service.get('/another-end-point', async (req, res) => { 54 // 55 // Proxy the request to 'another-service'. 56 // 57 service.forwardRequest("another-service", "/a-different-end-point", { optionalQueryParameters: "go here" }, res); 58 }); 59 60 // 61 // Initiate the service (a bit like like Express' listen function). 62 // 63 await service.start(); 64 65} 66 67if (require.main === module) { 68 69 70 // 71 // Run nano service as normal. 72 // 73 const service = nano(); 74 75 main(service) 76 .then(() => logger.info("Online")) 77 .catch(err => { 78 console.error("Failed to start!"); 79 console.error(err && err.stack || err); 80 }); 81} 82else { 83 // 84 // Don't start nanoservice, this allows the service to be loaded for unit testing. 85 // 86}
Open folder in Visual Studio Code and hit Ctrl+Shift+B
Or
npm build
Or
npx tsc [-w]
npm test
Or
npm run test:watch
Or
npx mocha --opts ./src/test/mocha.opts
Or
npx mocha --watch --watch-extensions ts --opts ./src/test/mocha.opts
No vulnerabilities found.
No security vulnerabilities found.