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

@seasketch/geoprocessing

Package Overview
Dependencies
Maintainers
1
Versions
1065
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seasketch/geoprocessing - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

1

dist/src/handlers.js

@@ -92,2 +92,3 @@ "use strict";

}
console.log('context', context);
let task = await Tasks.create(settings.serviceName, request.cacheKey, context.requestId);

@@ -94,0 +95,0 @@ if (isContainerImage(functionOrContainerImage)) {

98

dist/src/plugin/index.js

@@ -46,2 +46,3 @@ "use strict";

this.serverless = serverless;
this.tasksTableName = serverless.service.service + "-tasks";
this.hooks = {

@@ -51,3 +52,6 @@ "package:initialize": async () => {

await this.addFunctionDefinitions();
}
},
"after:deploy:functions": async () => {
await this.cleanup();
},
};

@@ -57,5 +61,61 @@ }

this.serverless.cli.log("Create common resources: database");
if (!this.serverless.service.resources || !this.serverless.service.resources.Resources) {
this.serverless.service.resources = { Resources: {} };
}
this.serverless.service.resources.Resources.tasksTable = {
Type: "AWS::DynamoDB::Table",
Properties: {
TableName: this.tasksTableName,
KeySchema: [
{
AttributeName: 'id',
KeyType: 'HASH'
},
{
AttributeName: 'service',
KeyType: "RANGE"
}
],
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' },
{ AttributeName: 'service', AttributeType: 'S' },
],
BillingMode: 'PAY_PER_REQUEST'
}
};
if (!this.serverless.service.provider.iamRoleStatements) {
this.serverless.service.provider.iamRoleStatements = [];
}
this.serverless.service.provider.iamRoleStatements.push({
Effect: "Allow",
Action: [
"dynamodb:BatchGet*",
"dynamodb:DescribeStream",
"dynamodb:DescribeTable",
"dynamodb:Get*",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWrite*",
"dynamodb:CreateTable",
"dynamodb:Delete*",
"dynamodb:Update*",
"dynamodb:PutItem"
],
Resource: { 'Fn::GetAtt': ["tasksTable", "Arn"] }
});
}
async cleanup() {
const custom = this.serverless.service.custom || {};
if ('geoprocessing' in custom) {
const geoprocessingConfig = custom.geoprocessing;
if ('services' in geoprocessingConfig) {
for (const serviceName in geoprocessingConfig.services) {
const newHandlerPath = path_1.default.join(".", `${serviceName}.ts`);
fs_1.default.unlinkSync(newHandlerPath);
}
}
}
}
async addFunctionDefinitions() {
console.log(this.serverless.service);
console.log(this.serverless.service.provider);
this.serverless.cli.log("Add function definitions");

@@ -66,34 +126,2 @@ const custom = this.serverless.service.custom || {};

if ('services' in geoprocessingConfig) {
const basePath = path_1.default.join(this.serverless.config.servicePath, ".geoprocessing");
try {
fs_1.default.mkdirSync(basePath);
}
catch (e) {
// already exists probably
}
const tasksTableName = this.serverless.service.service + "-tasks";
if (!this.serverless.service.resources || !this.serverless.service.resources.Resources) {
this.serverless.service.resources = { Resources: {} };
}
this.serverless.service.resources.Resources.tasksTable = {
Type: "AWS::DynamoDB::Table",
Properties: {
TableName: tasksTableName,
KeySchema: [
{
AttributeName: 'id',
KeyType: 'HASH'
},
{
AttributeName: 'service',
KeyType: "RANGE"
}
],
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' },
{ AttributeName: 'service', AttributeType: 'S' },
],
BillingMode: 'PAY_PER_REQUEST'
}
};
for (const serviceName in geoprocessingConfig.services) {

@@ -107,3 +135,3 @@ const conf = geoprocessingConfig.services[serviceName];

host: "https://example.com",
tasksTable: tasksTableName
tasksTable: this.tasksTableName
});

@@ -110,0 +138,0 @@ const newHandlerPath = path_1.default.join(".", `${serviceName}.ts`);

{
"name": "@seasketch/geoprocessing",
"version": "0.1.5",
"version": "0.1.6",
"description": "",

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

@@ -138,2 +138,3 @@ import { ExecutionMode, RateLimitPeriod } from "./service";

}
console.log('context', context);
let task: GeoprocessingTask = await Tasks.create(

@@ -140,0 +141,0 @@ settings.serviceName,

@@ -42,3 +42,4 @@ /// <reference path='./Serverless.d.ts' />

serverless: Serverless.Instance;
hooks: { [key: string]: Function }
hooks: { [key: string]: Function };
tasksTableName: string;

@@ -48,8 +49,12 @@ constructor(serverless: Serverless.Instance, options: Serverless.Options) {

this.serverless = serverless;
this.tasksTableName = serverless.service.service + "-tasks";
this.hooks = {
"package:initialize": async () => {
await this.addCommonResources()
await this.addFunctionDefinitions()
}
await this.addCommonResources();
await this.addFunctionDefinitions();
},
"after:deploy:functions": async () => {
await this.cleanup();
},
}

@@ -60,6 +65,63 @@ }

this.serverless.cli.log("Create common resources: database");
if (!this.serverless.service.resources || !this.serverless.service.resources.Resources) {
this.serverless.service.resources = { Resources: {} };
}
this.serverless.service.resources.Resources.tasksTable = {
Type: "AWS::DynamoDB::Table",
Properties: {
TableName: this.tasksTableName,
KeySchema: [
{
AttributeName: 'id',
KeyType: 'HASH'
},
{
AttributeName: 'service',
KeyType: "RANGE"
}
],
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' },
{ AttributeName: 'service', AttributeType: 'S' },
],
BillingMode: 'PAY_PER_REQUEST'
}
}
if (!this.serverless.service.provider.iamRoleStatements) {
this.serverless.service.provider.iamRoleStatements = [];
}
this.serverless.service.provider.iamRoleStatements.push({
Effect: "Allow",
Action: [
"dynamodb:BatchGet*",
"dynamodb:DescribeStream",
"dynamodb:DescribeTable",
"dynamodb:Get*",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWrite*",
"dynamodb:CreateTable",
"dynamodb:Delete*",
"dynamodb:Update*",
"dynamodb:PutItem"
],
Resource: { 'Fn::GetAtt': ["tasksTable", "Arn"] }
});
}
async cleanup() {
const custom = (this.serverless.service as any).custom || {};
if ('geoprocessing' in custom) {
const geoprocessingConfig = custom.geoprocessing;
if ('services' in geoprocessingConfig) {
for (const serviceName in geoprocessingConfig.services) {
const newHandlerPath = path.join(".", `${serviceName}.ts`);
fs.unlinkSync(newHandlerPath);
}
}
}
}
async addFunctionDefinitions() {
console.log(this.serverless.service);
console.log(this.serverless.service.provider)
this.serverless.cli.log("Add function definitions");

@@ -70,33 +132,2 @@ const custom = (this.serverless.service as any).custom || {};

if ('services' in geoprocessingConfig) {
const basePath = path.join(this.serverless.config.servicePath, ".geoprocessing");
try {
fs.mkdirSync(basePath)
} catch (e) {
// already exists probably
}
const tasksTableName = this.serverless.service.service + "-tasks";
if (!this.serverless.service.resources || !this.serverless.service.resources.Resources) {
this.serverless.service.resources = { Resources: {} };
}
this.serverless.service.resources.Resources.tasksTable = {
Type: "AWS::DynamoDB::Table",
Properties: {
TableName: tasksTableName,
KeySchema: [
{
AttributeName: 'id',
KeyType: 'HASH'
},
{
AttributeName: 'service',
KeyType: "RANGE"
}
],
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' },
{ AttributeName: 'service', AttributeType: 'S' },
],
BillingMode: 'PAY_PER_REQUEST'
}
}
for (const serviceName in geoprocessingConfig.services) {

@@ -110,3 +141,3 @@ const conf = geoprocessingConfig.services[serviceName];

host: "https://example.com",
tasksTable: tasksTableName
tasksTable: this.tasksTableName
});

@@ -113,0 +144,0 @@ const newHandlerPath = path.join(".", `${serviceName}.ts`);

@@ -17,2 +17,3 @@ // copied from https://github.com/prisma/serverless-plugin-typescript/blob/master/src/Serverless.d.ts

stage: string;
iamRoleStatements: Array<any>;
}

@@ -19,0 +20,0 @@ functions: {

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