Created
July 18, 2022 18:56
-
-
Save airscholar/72cea60ed77b23a043d65684c236c7ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DatabaseService } from './db.service'; | |
import { Global, Module } from '@nestjs/common'; | |
@Global() | |
@Module({ | |
providers: [DatabaseService], | |
exports: [DatabaseService], | |
}) | |
export class DbModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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