-
-
Save pbredenberg/29864bc9055f2e4fe703b14c012e812a to your computer and use it in GitHub Desktop.
Sample function connecting to typeorm
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 * as lambda from 'aws-lambda' | |
import connectionOptions from '../db/ConnectionOptions' | |
import { Connection } from 'typeorm' | |
import { Database } from '../db' | |
import { User } from '../entities' | |
import 'reflect-metadata' | |
import 'envkey' | |
exports.api = async (event: lambda.APIGatewayProxyEvent, serverlessContext: lambda.Context) => { | |
// This enables Lambda function to complete | |
serverlessContext.callbackWaitsForEmptyEventLoop = false | |
const database = new Database() | |
let dbConn: Connection = await database.getConnection(connectionOptions) | |
const users = await dbConn.getRepository(User).find() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment