Last active
December 15, 2021 19:24
-
-
Save kvarela/6440be152e683cb45c0a3ff627fd0e45 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