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

sls-helper-plugin-janis

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sls-helper-plugin-janis

A Serverless Helper plugin to add custom helpers for JANIS Commerce

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
310
decreased by-44.24%
Maintainers
1
Weekly downloads
 
Created
Source

Serverless Helper Plugin JANIS

A plugin for JANIS Commerce to use with the Serverless Helper Framework.

Helpers

base

Used to implement a base service with minimal setup

OptionTypeDescriptionAttributesDefault value
serviceNamestringThe service nameRequired
servicePortnumberThe service portRequired
apiSecretsObjectA mapping of stages to Service API Secretundefined

templates

Used to implement Lambda APIs requests and response templates as custom props

No options

authorizers

Used to implement APIs authorizers as custom props

No options

cors

Used to implement APIs CORS configuration as custom props

If options is undefined or set to true it will use the default CORS config for every property. You can also customize or override every property:

OptionTypeDescriptionDefault value
replacebooleanIndicates whether it should replace the CORS properties or merge then with the defaultfalse
originsarrayAn array of allowed originsSee below
headersarrayAn array of allowed headersSee below
allowCredentialsbooleanIndicates whether the credentials header should be settrue
maxAgenumberThe time in seconds thar CORS headers should be cached600
CORS Default origins:
[
	'https://${self:custom.janisDomains.${self:custom.stage}}',
	'https://app.${self:custom.janisDomains.${self:custom.stage}}',
	'http://localhost:3001',
	'http://janis.localhost:3001',
	'http://app.janis.localhost:3001'
]
CORS Default headers:
[
	'content-type',
	'janis-api-key',
	'janis-api-secret',
	'janis-client',
	'x-api-key',
	'x-janis-page',
	'x-janis-page-size'
]

apiList, apiGet, apiPost and apiPut

Used to implement JANIS CRUD APIs.

OptionTypeDescriptionAttributesDefault value
entityNamestringThe entity nameRequired
handlerstringThe lambda handler path and functionsrc/lambda/RestApi/index.handler
pathstringThe API path/[entity-name] (for apiList and apiPost) or /[entity-name]/{id} (for apiGet and apiPut)
cachingbooleanSet to true to enable cachefalse
corsbooleanSet to true to enable corsfalse
queryParametersobjectA key value to map query string parameters to a boolean indicating if it's required or not
requestHeadersobjectA key value to map headers to a boolean indicating if it's required or not
authorizerstringThe name of the authorizerValid authorizers: FullAuthorizer, NoClientAuthorizer, LoggedAuthorizer, ApiKeyAuthorizer, UserAuthorizer, DevUserAuthorizer, ServiceAuthorizer, ServiceNoClientAuthorizer, ClientAuthorizer

eventListener

Used to implement JANIS Events listeners

OptionTypeDescriptionAttributesDefault value
entityNamestringThe entity nameRequired
eventNamestringThe event nameRequired
mustHaveClientbooleanIndicates if authorizer must validate that client or notfalse
listenersDirNamestringIndicates the path where the event listener files are placed'event-listeners'

Examples

Basic Service with one CRUD operation set and an event listener

// serverless.js

'use strict';

const { helper } = require('sls-helper'); // eslint-disable-line

module.exports = helper({
	hooks: [

		['janis.base', {
			serviceName: 'Catalog',
			servicePort: 5000,
			apiSecrets: {
				beta: 'foo',
				qa: 'bar',
				prod: 'baz'
			}
		}],

		'janis.templates',

		'janis.authorizers',

		'janis.cors',

		['janis.apiList', {
			entityName: 'product',
			authorizer: 'FullAuthorizer',
			cors: true
		}],

		['janis.apiGet', {
			entityName: 'product',
			authorizer: 'FullAuthorizer',
			cors: true
		}]

		['janis.apiPost', {
			entityName: 'product',
			authorizer: 'FullAuthorizer',
			cors: true
		}],

		['janis.apiPut', {
			entityName: 'product',
			authorizer: 'FullAuthorizer',
			cors: true
		}],

		['janis.eventListener', {
			entityName: 'product',
			eventName: 'created',
			mustHaveClient: true
		}]

	]
}, {});

Keywords

FAQs

Package last updated on 26 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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