Skip to content

Instantly share code, notes, and snippets.

@airscholar
Created July 18, 2022 18:56
Show Gist options
  • Save airscholar/72cea60ed77b23a043d65684c236c7ae to your computer and use it in GitHub Desktop.
Save airscholar/72cea60ed77b23a043d65684c236c7ae to your computer and use it in GitHub Desktop.
import { DatabaseService } from './db.service';
import { Global, Module } from '@nestjs/common';
@Global()
@Module({
providers: [DatabaseService],
exports: [DatabaseService],
})
export class DbModule {}
import { Injectable } from '@nestjs/common';
import * as AWS from 'aws-sdk';
@Injectable()
export class DatabaseService {
connect(): AWS.DynamoDB.DocumentClient {
return process.env.IS_OFFLINE
? new AWS.DynamoDB.DocumentClient({
region: 'localhost',
endpoint: process.env.DYNAMODB_ENDPOINT,
})
: new AWS.DynamoDB.DocumentClient();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment