DEV Community

Cover image for How to Secure TypeScript Applications...??

How to Secure TypeScript Applications...??

Shafayet Hossain Yashfi on January 01, 2025

In an era where application security is paramount, developing secure applications is not merely an option, it's a necessity. TypeScript, with its r...
Collapse
 
quedicesebas profile image
Sebastián Rojas Ricaurte

I think Angular that's care of most of it

Collapse
 
shafayeat profile image
Shafayet Hossain Yashfi

True, Angular does handle many security aspects like input sanitization and CSRF protection. But even with Angular, it's crucial to maintain secure practices. Think about safe API usage, authentication, and validating data on both client and server. Tools can only do so much; a strong security mindset is always key!!

Collapse
 
quedicesebas profile image
Sebastián Rojas Ricaurte

Agree

Collapse
 
teeksha_s_f1d4a3191898e40 profile image
Teeksha S

Great article. It will help me alot. I have one query. If In the user ID have combination with numbers and alphabets. Then how to take users ID number or string. Please help me this sinario.

Collapse
 
shafayeat profile image
Shafayet Hossain Yashfi

Thank you for your kind words!🖤 For your query, you can use regular expressions to separate the numbers and letters. Here's an example:

function extractParts(userId: string) {
  const numbers = userId.match(/\d+/g)?.join('') || '';
  const letters = userId.match(/[a-zA-Z]+/g)?.join('') || '';
  return { numbers, letters };
}

const result = extractParts("abc123");
console.log(result); // { numbers: "123", letters: "abc" }
Enter fullscreen mode Exit fullscreen mode

Let me know if you get stuck...😉

Collapse
 
nozibul_islam_113b1d5334f profile image
Nozibul Islam

Great, thanks

Collapse
 
shafayeat profile image
Shafayet Hossain Yashfi

Thank you! Means a lot!🖤

Collapse
 
rodriveiga01 profile image
Rodrigo Veiga

Great article 🙌! Definitely will go back to this when needed

Collapse
 
shafayeat profile image
Shafayet Hossain Yashfi

Thanks! 🙌 Glad it’ll be handy. Reach out if you ever need help!!!🥰
I'll be there always😉

Collapse
 
shihab_malayil profile image
Shihab Malayil

Great article 👍🏻
I haven’t used TypeScript this much deeply. Thanks

Collapse
 
shafayeat profile image
Shafayet Hossain Yashfi

Thanks! There’s a lot to love about TypeScript when you dig in!😅