Socket
Socket
Sign inDemoInstall

faas-js-runtime

Package Overview
Dependencies
Maintainers
9
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faas-js-runtime - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

lib/utils.js

4

index.d.ts
import { Server } from 'http';
import { CloudEventFunction, HTTPFunction, InvokerOptions } from './lib/types';
import { CloudEventFunction, HTTPFunction, InvokerOptions, Function } from './lib/types';
import { LogLevel } from 'fastify';

@@ -24,5 +24,5 @@

INCLUDE_RAW: boolean,
}
};
// re-export
export * from './lib/types';

@@ -10,2 +10,3 @@ const qs = require('qs');

const fastifyRawBody = require('fastify-raw-body');
const { isPromise } = require('./lib/utils');

@@ -45,3 +46,6 @@ // HTTP framework

if (typeof func.init === 'function') {
func.init();
const initRet = func.init();
if (isPromise(initRet)) {
await initRet;
}
}

@@ -84,6 +88,6 @@ if (typeof func.shutdown === 'function') {

port: config.port,
host: '::'
host: '::',
});
return server.server;
} catch(err) {
} catch (err) {
console.error('Error starting server', err);

@@ -106,8 +110,8 @@ process.exit(1);

bindings: bindings => ({
pid: bindings.pid,
hostname: bindings.hostname,
node_version: process.version
})
}
}
pid: bindings.pid,
hostname: bindings.hostname,
node_version: process.version,
}),
},
},
});

@@ -125,5 +129,8 @@

// Give the Function an opportunity to clean up before the process exits
shutdown(_ => {
shutdown(async _ => {
if (typeof config.shutdown === 'function') {
config.shutdown();
const shutdownRet = config.shutdown();
if (isPromise(shutdownRet)) {
await shutdownRet;
}
}

@@ -135,3 +142,4 @@ server.close();

// Add a parser for application/x-www-form-urlencoded
server.addContentTypeParser('application/x-www-form-urlencoded',
server.addContentTypeParser(
'application/x-www-form-urlencoded',
function(_, payload, done) {

@@ -149,14 +157,19 @@ var body = '';

payload.on('error', done);
});
}
);
// Add a parser for everything else - parse it as a buffer and
// let this framework's router handle it
server.addContentTypeParser('*', { parseAs: 'buffer' }, function(req, body, done) {
try {
done(null, body);
} catch (err) {
err.statusCode = 500;
done(err, undefined);
server.addContentTypeParser(
'*',
{ parseAs: 'buffer' },
function(req, body, done) {
try {
done(null, body);
} catch (err) {
err.statusCode = 500;
done(err, undefined);
}
}
});
);

@@ -220,3 +233,3 @@ // Initialize the invocation context

return yaml.load(fs.readFileSync(yamlFile, 'utf8'));
} catch(err) {
} catch (err) {
console.warn(err);

@@ -228,2 +241,5 @@ }

module.exports = exports = { start, defaults: { LOG_LEVEL, PORT, INCLUDE_RAW } };
module.exports = exports = {
start,
defaults: { LOG_LEVEL, PORT, INCLUDE_RAW },
};

@@ -22,3 +22,3 @@ 'use strict';

function callProtect(request, reply) {
reply.header('Content-Type', 'text/plain; charset=utf8');
reply.header('Content-Type', 'text/plain; charset=utf-8');
protect(request, reply, _ => reply.send('OK'));

@@ -25,0 +25,0 @@ }

@@ -13,3 +13,3 @@ /**

headers: {
'content-type': 'application/json; charset=utf8',
'content-type': 'application/json; charset=utf-8',
'access-control-allow-methods':

@@ -75,3 +75,3 @@ 'OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH',

if (typeof fnReturn === 'string') {
payload.headers['content-type'] = 'text/plain; charset=utf8';
payload.headers['content-type'] = 'text/plain; charset=utf-8';
payload.response = fnReturn;

@@ -102,5 +102,5 @@ return payload;

if (typeof fnReturn.body === 'string') {
payload.headers['content-type'] = 'text/plain; charset=utf8';
payload.headers['content-type'] = 'text/plain; charset=utf-8';
} else if (typeof fnReturn.body === 'object') {
payload.headers['content-type'] = 'application/json; charset=utf8';
payload.headers['content-type'] = 'application/json; charset=utf-8';
}

@@ -111,3 +111,3 @@ }

// Finally, the user may have supplied a simple object response
payload.headers['content-type'] = 'application/json; charset=utf8';
payload.headers['content-type'] = 'application/json; charset=utf-8';
payload.response = fnReturn;

@@ -114,0 +114,0 @@ }

@@ -12,8 +12,8 @@ /* eslint-disable no-unused-vars */

// The initialization function, called before the server is started
// This function is optional and should be synchronous.
init?: () => any;
// This function is optional.
init?: () => (any | Promise<any>);
// The shutdown function, called after the server is stopped
// This function is optional and should be synchronous.
shutdown?: () => any;
// This function is optional.
shutdown?: () => (any | Promise<any>);

@@ -20,0 +20,0 @@ // The liveness function, called to check if the server is alive

{
"name": "faas-js-runtime",
"version": "2.2.3",
"version": "2.3.0",
"repository": {

@@ -16,2 +16,3 @@ "type": "git",

"lint": "eslint --ignore-path .gitignore .",
"fix-lint": "eslint --fix --ignore-path .gitignore .",
"test": "npm run test:source && npm run test:types",

@@ -37,26 +38,26 @@ "test:source": "nyc --reporter=lcovonly tape test/test*.js | colortape",

"dependencies": {
"cloudevents": "^7.0.1",
"cloudevents": "^8.0.0",
"commander": "^11.0.0",
"death": "^1.1.0",
"fastify": "^4.19.2",
"fastify-raw-body": "^4.2.0",
"fastify": "^4.21.0",
"fastify-raw-body": "^4.2.1",
"js-yaml": "^4.1.0",
"node-os-utils": "^1.3.7",
"overload-protection": "^1.2.3",
"prom-client": "^14.1.1",
"prom-client": "^15.0.0",
"qs": "^6.11.2"
},
"devDependencies": {
"@cyclonedx/cyclonedx-npm": "^1.12.1",
"@types/node": "^20.3.3",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.61.0",
"@cyclonedx/cyclonedx-npm": "^1.16.1",
"@types/node": "^20.4.7",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.1",
"colortape": "^0.1.2",
"eslint": "^8.44.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.7.0",
"nyc": "^15.1.0",
"supertest": "^6.3.1",
"tape": "^5.6.4",
"tape": "^5.7.4",
"tsd": "^0.28.1",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},

@@ -63,0 +64,0 @@ "tsd": {

Sorry, the diff of this file is too big to display

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