Skip to content

Instantly share code, notes, and snippets.

@nsdevaraj
Created August 5, 2024 14:09
Show Gist options
  • Save nsdevaraj/a41fb09683c3055ab25e7a2c43a15dba to your computer and use it in GitHub Desktop.
Save nsdevaraj/a41fb09683c3055ab25e7a2c43a15dba to your computer and use it in GitHub Desktop.
Prevention of Injection Attacks
import { getRepository } from 'typeorm';
import { User } from './entity/User';
async function getUser(username: string): Promise<User | undefined> {
const userRepository = getRepository(User);
return await userRepository.findOne({ where: { username } });
}
// Usage
const user = await getUser(username);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment