Skip to content

Proposal - require dependency directly from databases instead of use Store.use #122

@jacklam718

Description

@jacklam718

Proposal

require dependency directly from databases instead of use Store.use

For example:
aws = require('aws-sdk); instead of aws = Store.use('aws-sdk');
I propose this idea because I have some issues.

Background

I using AWS Lambda with serverless and serverless-webpack
I want to use eventstore with dynamodb from lambda but I got some errors. btw, I've installed aws-sdk and works on my local.

1. Implementation for db \"dynamodb\" does not exist!.

my code:

import eventstore from 'eventstore';
eventstore({ type: 'dynamodb' });

then I tried pass the DynamoDB class to eventstore, but I got another error Cannot find module 'aws-sdk' from parent
my code:

import eventstore from 'eventstore';
import DynamoDB from 'eventstore/lib/databases/dynamodb';
eventstore({ type: DynamoDB });

Some of my thoughts

About the issue 1 and 2. I think it's because it cannot find modules via require after webpack bundled.
https://github.com/adrai/node-eventstore/blob/master/index.js#L42
https://github.com/adrai/node-eventstore/blob/master/lib/databases/dynamodb.js#L2
https://github.com/adrai/node-eventstore/blob/master/lib/base.js#L172

So, that's why I propose this idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions