Skip to content

Commit

Permalink
change serverless-functions to export-serverless. Add iamStatements. …
Browse files Browse the repository at this point in the history
…Remove logs from model (only test)
  • Loading branch information
maguimarijuan committed May 20, 2020
1 parent 33042b5 commit 3445e30
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
42 changes: 42 additions & 0 deletions lib/export-serverless.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const path = require('path');

const handlerPath = path.join(process.env.MS_PATH || '', 'lambda', 'ExportProcess', 'index.handler');
const clientModelPath = path.join(process.env.MS_PATH || '', 'models', 'client.js');
const controllersPath = path.join(process.env.MS_PATH || '', 'controllers', 'export', '**');
const modelsPath = path.join(process.env.MS_PATH || '', 'models', '**');

const resourceAux = '${self:custom.stage}';// eslint-disable-line

module.exports = serviceName => [
[
'janis.apiPost', {
entityName: 'export',
authorizer: 'ImportExportAuthorizer',
cors: true,
timeout: 10,
package: { include: [modelsPath, controllersPath] }
}
],

[
'function', {
functionName: 'ExportProcess',
handler: handlerPath,
description: 'Export Process Lambda',
timeout: 60,
package: { include: ['schemas/mongo/**', clientModelPath] }
}
],

[
'iamStatement', {
action: [
's3:PutObject',
's3:GetObject'
],
resource: `arn:aws:s3:::janis-${serviceName}-service-${resourceAux}/*`// eslint-disable-line
}
]
];
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ModelExport = require('./model-export');
const ControllerExport = require('./controller-export');
const CreatedListener = require('./created-listener');
const ProcessedListener = require('./processed-listener');
const exportFunctions = require('./serverless-functions');
const exportServerless = require('./export-serverless.js');
const ExportHelper = require('./export-helpers/export-helper');
const UserHelper = require('./export-helpers/user-helper');
const ExportFormatters = require('./export-formatters');
Expand All @@ -19,5 +19,5 @@ module.exports = {
ExportHelper,
UserHelper,
ExportFormatters,
exportFunctions
exportServerless
};
29 changes: 0 additions & 29 deletions lib/serverless-functions.js

This file was deleted.

4 changes: 4 additions & 0 deletions tests/model-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ describe('Models', () => {
sendingError: 'sending-error'
});
});

it('Should return false', () => {
assert.strictEqual(ModelExport.shouldCreateLogs, false);
});
});
});
});

0 comments on commit 3445e30

Please sign in to comment.