<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Glasshost on Medium]]></title>
        <description><![CDATA[Stories by Glasshost on Medium]]></description>
        <link>https://medium.com/@glasshost?source=rss-e7b6a815cb2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ccaZ7S--q-qXGn_Xz5Mv5w.png</url>
            <title>Stories by Glasshost on Medium</title>
            <link>https://medium.com/@glasshost?source=rss-e7b6a815cb2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:42:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@glasshost/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Download the Code of an AWS Lambda Function]]></title>
            <link>https://medium.com/@glasshost/download-the-code-of-an-aws-lambda-function-e39bf3c0d61a?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e39bf3c0d61a</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:24:23 GMT</pubDate>
            <atom:updated>2023-05-05T04:24:23.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Download the Code of an AWS Lambda Function" src="https://cdn-images-1.medium.com/max/800/0*PZpG-1aI2jP3O_I4.png" /></figure><h3>Guide: Download the Code of an AWS Lambda Function</h3><p>AWS Lambda is a serverless computing platform provided by Amazon as a part of Amazon Web Services (AWS). AWS Lambda allows developers to run their code without the need for managing servers. In this guide, we will learn how to download the code of an AWS Lambda Function.</p><h4>Step 1: Open the AWS Management Console</h4><p>First, we need to log in to the AWS Management Console using valid credentials.</p><h4>Step 2: Select AWS Lambda</h4><p>Once you are logged in, select the ‘Lambda’ service from the list of available AWS services.</p><h4>Step 3: Select the Lambda Function</h4><p>In the AWS Lambda Console, select the Lambda Function of which you want to download the code.</p><h4>Step 4: Go to Function Code</h4><p>After selecting the Lambda Function, go to the ‘Function code’ section.</p><h4>Step 5: Download the Code</h4><p>In the ‘Function code’ section, click on the ‘Download’ button to download the code of the Lambda Function. The code will be downloaded in a ZIP format.</p><h4>Conclusion</h4><p>In this guide, we learned how to download the code of an AWS Lambda Function. By following these simple steps, you can easily download the code and start working on it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e39bf3c0d61a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[List all Files in an S3 Bucket with AWS CLI]]></title>
            <link>https://medium.com/@glasshost/list-all-files-in-an-s3-bucket-with-aws-cli-50265cff4fdf?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/50265cff4fdf</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:23:41 GMT</pubDate>
            <atom:updated>2023-05-05T04:23:41.427Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="List all Files in an S3 Bucket with AWS CLI" src="https://cdn-images-1.medium.com/max/800/0*a8z6JqTkAVWawD_Z.png" /></figure><p>Amazon Web Services Command Line Interface (AWS CLI) is a powerful tool that allows users to interact with various AWS services using a command line interface. With AWS CLI, users can easily manage their S3 buckets and the files stored in them. This guide will show you how to list all files in an S3 bucket using AWS CLI.</p><h4>Step 1: Install AWS CLI</h4><p>Before you can use AWS CLI, you need to install it on your system. You can download the appropriate installation package for your operating system from the <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html">official AWS CLI documentation</a>.</p><h4>Step 2: Configure AWS CLI</h4><p>After installing AWS CLI, you need to configure it with your AWS credentials. You can do this by running the following command in your terminal:</p><pre>aws configure</pre><p>This command will prompt you to enter your AWS access key ID, secret access key, default region name, and default output format. Once you enter these values, AWS CLI will be configured and ready to use.</p><h4>Step 3: List all files in an S3 bucket</h4><p>To list all files in an S3 bucket using AWS CLI, you need to run the following command in your terminal:</p><pre>aws s3 ls s3://{bucket-name}</pre><p>Replace `{bucket-name}` with the name of the S3 bucket that you want to list the files of. This command will display a list of all the files in the specified S3 bucket along with their metadata.</p><h4>Conclusion</h4><p>In this guide, we have shown you how to list all files in an S3 bucket using AWS CLI. AWS CLI is a powerful tool that can help you manage your AWS resources more efficiently. We hope that this guide has been helpful to you and that you can now easily list all files in your S3 buckets using AWS CLI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50265cff4fdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Role with AWS CLI — Complete Guide]]></title>
            <link>https://medium.com/@glasshost/create-a-role-with-aws-cli-complete-guide-4971355502f8?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4971355502f8</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:22:49 GMT</pubDate>
            <atom:updated>2023-05-05T04:22:49.003Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Create a Role with AWS CLI - Complete Guide" src="https://cdn-images-1.medium.com/max/800/0*8TBk1bG6sI9UVRun.png" /></figure><p>Creating an AWS IAM role allows you to delegate permissions to AWS resources. In this guide, we will see how to create a role with AWS CLI.</p><h4>Prerequisites</h4><p>Before we start, make sure you have installed AWS CLI and configured it with your AWS account credentials.</p><h4>Steps to Create a Role with AWS CLI</h4><ol><li>Open the terminal or command prompt on your local machine.</li><li>Use the `aws iam create-role` command to create a new role. Here’s an example command:</li></ol><pre>aws iam create-role --role-name {ROLE-NAME} --assume-role-policy-document file://{TRUST-POLICY-FILE-PATH}</pre><p>Replace `{ROLE-NAME}` with the name of the role you want to create, and `{TRUST-POLICY-FILE-PATH}` with the file path of the trust policy document. The trust policy document specifies which AWS accounts or services can assume the role.</p><ol><li>Once the role is created, you need to attach policies to it. Use the `aws iam attach-role-policy` command to attach a policy to the role. Here’s an example command:</li></ol><pre>aws iam attach-role-policy --role-name {ROLE-NAME} --policy-arn {POLICY-ARN}</pre><p>Replace `{ROLE-NAME}` with the name of the role you created in step 2, and `{POLICY-ARN}` with the Amazon Resource Name (ARN) of the policy you want to attach.</p><ol><li>You can verify that the role is created and the policy is attached by using the `aws iam list-attached-role-policies` command. Here’s an example command:</li></ol><pre>aws iam list-attached-role-policies --role-name {ROLE-NAME}</pre><p>Replace `{ROLE-NAME}` with the name of the role you created in step 2.</p><p>Congratulations! You have successfully created an AWS IAM role with AWS CLI.</p><h4>Conclusion</h4><p>In this guide, we saw how to create an AWS IAM role with AWS CLI. By delegating permissions to AWS resources using IAM roles, you can improve the security of your AWS account.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4971355502f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Tags in AWS CDK — Complete Guide]]></title>
            <link>https://medium.com/@glasshost/how-to-use-tags-in-aws-cdk-complete-guide-94a4ca97ad57?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/94a4ca97ad57</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:21:56 GMT</pubDate>
            <atom:updated>2023-05-05T04:21:56.314Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="How to use Tags in AWS CDK - Complete Guide" src="https://cdn-images-1.medium.com/max/800/0*6bL0aTBDMB_bNiKQ.png" /></figure><p>AWS CDK provides a way to define infrastructure as code using programming languages. It allows you to define and deploy your infrastructure resources in a programmatic way. With AWS CDK, you can define your resources as a stack, which is a collection of related AWS resources.</p><p>Tags are metadata that you can add to AWS resources to help you manage, identify, and search for resources. Tags are key-value pairs that you can add to your resources. AWS CDK provides an easy way to add tags to your resources.</p><h4>Adding Tags to Resources</h4><p>To add tags to your resources in AWS CDK, you can use the `cdk.Tags.of()` method. This method can be used to get the tags of an existing resource or to add tags to a new resource.</p><p>To add tags to a new resource, you can use the `tags` property of the resource constructor. For example, to add tags to an S3 bucket, you can use the following code:</p><pre>const bucket = new s3.Bucket(this, &#39;MyBucket&#39;, {<br>    tags: {<br>        environment: &#39;dev&#39;,<br>        owner: &#39;John Doe&#39;<br>    }<br>});</pre><p>In this example, we are creating a new S3 bucket and adding two tags to it. The `environment` tag has a value of `dev`, and the `owner` tag has a value of `John Doe`.</p><p>If you want to add tags to an existing resource, you can use the `cdk.Tags.of()` method. For example, to add tags to an existing S3 bucket, you can use the following code:</p><pre>const bucket = s3.Bucket.fromBucketName(this, &#39;MyBucket&#39;, &#39;my-bucket-name&#39;);<br>cdk.Tags.of(bucket).add(&#39;environment&#39;, &#39;prod&#39;);</pre><p>In this example, we are getting an existing S3 bucket using its name and adding a new tag to it. The `environment` tag has a value of `prod`.</p><h4>Managing Tags</h4><p>You can manage tags using the AWS Management Console, AWS CLI, or AWS SDKs. You can add, delete, or modify tags using these tools.</p><p>AWS CDK provides an easy way to manage tags for your resources. You can use the `cdk.TagManager` class to manage tags for a stack. For example, to add a tag to a stack, you can use the following code:</p><pre>const tagManager = new cdk.TagManager(cdk.TagType.STACK);<br>tagManager.setTag(&#39;environment&#39;, &#39;dev&#39;);</pre><p>In this example, we are creating a new `TagManager` instance for a stack and adding a new tag to it. The `environment` tag has a value of `dev`.</p><h4>Conclusion</h4><p>Tags are an important part of managing your AWS resources. They can help you identify and manage your resources more easily. With AWS CDK, adding tags to your resources is easy and can be done programmatically. Use the `cdk.Tags.of()` method to add tags to your resources, and the `cdk.TagManager` class to manage tags for your stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94a4ca97ad57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Lambda Functions in a VPC in AWS CDK]]></title>
            <link>https://medium.com/@glasshost/create-lambda-functions-in-a-vpc-in-aws-cdk-a852b07aec89?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a852b07aec89</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:21:11 GMT</pubDate>
            <atom:updated>2023-05-05T04:21:11.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Create Lambda Functions in a VPC in AWS CDK" src="https://cdn-images-1.medium.com/max/800/0*EQ45FwRnY2XDbTgo.png" /></figure><p>AWS CDK is a powerful tool that allows developers to define their cloud infrastructure using familiar programming languages. With this guide, you will learn how to create Lambda functions in a VPC using AWS CDK.</p><h4>Prerequisites</h4><p>Before we begin, make sure you have the following:</p><ul><li>An AWS account</li><li>AWS CLI installed and configured</li><li>Node.js and NPM installed</li><li>Basic knowledge of AWS CDK and Lambda functions</li></ul><h4>Steps</h4><ol><li><strong>Create a new AWS CDK project</strong></li></ol><p>Open your terminal and run the following command to create a new AWS CDK project:</p><p>`cdk init — language typescript`</p><ol><li><strong>Install AWS CDK dependencies</strong></li></ol><p>Navigate to the root directory of your project and run the following command to install AWS CDK dependencies:</p><p>`npm install aws-cdk-lib @aws-cdk/aws-lambda @aws-cdk/aws-ec2`</p><ol><li><strong>Create a VPC</strong></li></ol><p>In your project’s `lib` folder, create a new file called `my-vpc-stack.ts` and add the following code to create a VPC:</p><p>```typescript import * as cdk from ‘aws-cdk-lib’; import * as ec2 from ‘aws-cdk-lib/aws-ec2’;</p><p>export class MyVpcStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props);</p><pre>const vpc = new ec2.Vpc(this, &#39;MyVPC&#39;, {<br>     cidr: &#39;10.0.0.0/16&#39;,<br>     maxAzs: 2<br>   });<br> }</pre><p>} ```</p><ol><li><strong>Create a Lambda function</strong></li></ol><p>In the same `lib` folder, create a new file called `my-lambda-stack.ts` and add the following code to create a Lambda function:</p><p>```typescript import * as cdk from ‘aws-cdk-lib’; import * as lambda from ‘aws-cdk-lib/aws-lambda’; import * as ec2 from ‘aws-cdk-lib/aws-ec2’;</p><p>export class MyLambdaStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, vpc: ec2.Vpc, props?: cdk.StackProps) { super(scope, id, props);</p><pre>const myFn = new lambda.Function(this, &#39;MyFunction&#39;, {<br>     runtime: lambda.Runtime.NODEJS_12_X,<br>     handler: &#39;index.handler&#39;,<br>     code: lambda.Code.fromAsset(&#39;./lambda&#39;),<br>     vpc,<br>     vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE },<br>     securityGroup: new ec2.SecurityGroup(this, &#39;MySecurityGroup&#39;, {<br>       vpc,<br>       allowAllOutbound: true,<br>     }),<br>   });<br> }</pre><p>} ```</p><ol><li><strong>Deploy your stacks</strong></li></ol><p>In your terminal, run the following command to deploy your stacks:</p><p>`cdk deploy`</p><p>This will create a VPC and a Lambda function in your AWS account.</p><ol><li><strong>Test your Lambda function</strong></li></ol><p>Now that your Lambda function is deployed, you can test it by invoking it. You can do this in the AWS Lambda console or using the AWS CLI:</p><p>`aws lambda invoke — function-name MyFunction output.json`</p><p>This will invoke your Lambda function and store the output in a file called `output.json`.</p><p>Congratulations! You have successfully created a Lambda function in a VPC using AWS CDK.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a852b07aec89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KMS Key Example in AWS CDK — Complete Guide]]></title>
            <link>https://medium.com/@glasshost/kms-key-example-in-aws-cdk-complete-guide-f45fe0253ed5?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45fe0253ed5</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:20:11 GMT</pubDate>
            <atom:updated>2023-05-05T04:20:11.407Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="KMS Key Example in AWS CDK - Complete Guide" src="https://cdn-images-1.medium.com/max/800/0*CahIpB4Tsk5r6VHR.png" /></figure><p>AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through AWS CloudFormation. AWS Key Management Service (KMS) is a managed service that makes it easy to create and control the encryption keys used to encrypt data.</p><p>In this guide, we will walk through an example of creating a KMS key using AWS CDK.</p><h4>Prerequisites</h4><p>Before we begin, make sure you have the following: — An AWS account — AWS CLI installed and configured — Node.js and npm installed — AWS CDK installed</p><h4>Step 1: Create a new AWS CDK project</h4><p>First, let’s create a new directory for our project and navigate into it:</p><pre>mkdir kms-cdk-example<br>cd kms-cdk-example</pre><p>Next, let’s initialize a new AWS CDK project:</p><pre>cdk init app --language=typescript</pre><h4>Step 2: Install the required dependencies</h4><p>We need to install the AWS SDK and AWS CDK AWS KMS module:</p><pre>npm install aws-sdk @aws-cdk/aws-kms</pre><h4>Step 3: Create a new KMS key</h4><p>Open the `lib/kms-cdk-example-stack.ts` file and add the following code to create a new KMS key:</p><pre>import * as cdk from &#39;@aws-cdk/core&#39;;<br>import * as kms from &#39;@aws-cdk/aws-kms&#39;;<br><br>export class KmsCdkExampleStack extends cdk.Stack {<br>  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {<br>    super(scope, id, props);<br><br>    new kms.Key(this, &#39;MyKey&#39;, {<br>      enableKeyRotation: true,<br>    });<br>  }<br>}</pre><p>This will create a new KMS key with key rotation enabled.</p><h4>Step 4: Deploy the stack</h4><p>Before we can deploy the stack, we need to bootstrap our AWS environment:</p><pre>cdk bootstrap</pre><p>Once bootstrapped, we can deploy the stack:</p><pre>cdk deploy</pre><h4>Step 5: Test the KMS key</h4><p>After the stack is deployed, we can test the KMS key by encrypting and decrypting some data using the AWS SDK:</p><pre>const AWS = require(&#39;aws-sdk&#39;);<br><br>const kms = new AWS.KMS();<br><br>const plaintext = &#39;my secret data&#39;;<br><br>kms.encrypt({ KeyId: &#39;MyKey&#39;, Plaintext: plaintext }, (err, data) =&gt; {<br>  if (err) console.log(err, err.stack);<br>  else {<br>    const ciphertext = data.CiphertextBlob;<br><br>    kms.decrypt({ CiphertextBlob: ciphertext }, (err, data) =&gt; {<br>      if (err) console.log(err, err.stack);<br>      else console.log(data.Plaintext.toString());<br>    });<br>  }<br>});</pre><p>This will encrypt `plaintext` using our KMS key and then decrypt `ciphertext` to get back `plaintext`.</p><h4>Conclusion</h4><p>In this guide, we walked through an example of creating a KMS key using AWS CDK. We also tested the key by encrypting and decrypting some data. AWS CDK is a powerful tool for defining cloud infrastructure in code and managing it through AWS CloudFormation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45fe0253ed5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Define types for process.env in TypeScript]]></title>
            <link>https://medium.com/@glasshost/define-types-for-process-env-in-typescript-c89b3c8ffbb2?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c89b3c8ffbb2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:19:26 GMT</pubDate>
            <atom:updated>2023-05-05T04:19:26.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Define types for process.env in TypeScript" src="https://cdn-images-1.medium.com/max/800/0*oZuM3xlvCO41Uv6x.png" /></figure><h3>Define Types for process.env in TypeScript</h3><p>TypeScript is a superset of JavaScript and is designed to make development easier and more efficient. One of the ways it does this is by providing type checking, which helps prevent errors and makes code more maintainable. One area where type checking can be particularly useful is when working with environment variables, as it allows you to define types for the values of the variables in process.env. In this guide, we will show you how to define types for process.env in TypeScript.</p><h4>Step 1: Install Dependencies</h4><p>First, you need to install the required dependencies. You will need `@types/node` and `dotenv`. You can install them using npm:</p><pre>npm install @types/node dotenv</pre><h4>Step 2: Create a .env File</h4><p>Create a `.env` file at the root of your project and add your environment variables in the format `VARIABLE_NAME=value`. For example:</p><pre>PORT=3000<br>DATABASE_URL=postgres://user:password@localhost:5432/mydatabase</pre><h4>Step 3: Load the Environment Variables</h4><p>You need to load the environment variables from the .env file into Node.js `process.env` object. You can do this using `dotenv` package. Add the following code to your application entry point (usually `index.ts` or `server.ts`):</p><pre>import dotenv from &#39;dotenv&#39;;<br>dotenv.config();</pre><h4>Step 4: Define Types for process.env</h4><p>Create a new file `process-env.d.ts` in the root of your project and add the following code:</p><pre>declare global {<br>  namespace NodeJS {<br>    interface ProcessEnv {<br>      [key: string]: string | undefined;<br>      PORT: string;<br>      DATABASE_URL: string;<br>      // add more environment variables and their types here<br>    }<br>  }<br>}</pre><p>This code declares a new module `NodeJS` and interface `ProcessEnv` in the global namespace. The `ProcessEnv` interface extends the `NodeJS.ProcessEnv` interface and defines the types for your environment variables. In this example, we defined `PORT` and `DATABASE_URL` variables with string types. You can add more environment variables and their types here.</p><h4>Step 5: Use the Environment Variables</h4><p>Now you can use the environment variables in your code with type checking. For example:</p><pre>import express from &#39;express&#39;;<br><br>const app = express();<br><br>const port = process.env.PORT;<br>const databaseUrl = process.env.DATABASE_URL;<br><br>app.listen(port, () =&gt; {<br>  console.log(`Server is running on port ${port}`);<br>});<br><br>// use databaseUrl to connect to a database</pre><h4>Conclusion</h4><p>Defining types for process.env in TypeScript can help prevent errors and make your code more maintainable. By following the steps outlined in this guide, you can easily define types for your environment variables and use them with type checking in your code. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c89b3c8ffbb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make all properties optional in TypeScript]]></title>
            <link>https://medium.com/@glasshost/make-all-properties-optional-in-typescript-1f5e5e431edc?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f5e5e431edc</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:18:28 GMT</pubDate>
            <atom:updated>2023-05-05T04:18:28.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Make all properties optional in TypeScript" src="https://cdn-images-1.medium.com/max/800/0*iFcp91EFMQ_XCSq7.png" /></figure><p>TypeScript is an open-source programming language that is a strict syntactical superset of JavaScript. It provides additional features such as static typing, interfaces, and classes to JavaScript. One of the most useful features of TypeScript is the ability to make all properties optional.</p><p>Making all properties optional is useful when you have an interface or a class with many properties and you don’t want to specify all of them when creating a new object. This can save time and make your code more flexible.</p><p>To make all properties optional in TypeScript, you can use the “?” symbol after each property name. Here’s an example:</p><pre>interface Person {<br>  name?: string;<br>  age?: number;<br>  address?: string;<br>}</pre><p>In this example, we’ve defined an interface called “Person” with three properties: “name”, “age”, and “address”. Each property has the “?” symbol after it, which makes them all optional.</p><p>Now, when we create a new object using this interface, we can specify only the properties that we want to include:</p><pre>const person1: Person = {<br>  name: &quot;John&quot;,<br>  age: 30<br>};<br><br>const person2: Person = {<br>  name: &quot;Jane&quot;,<br>  address: &quot;123 Main St.&quot;<br>};</pre><p>In the first example, we’ve created a new object called “person1” with only the “name” and “age” properties specified. In the second example, we’ve created a new object called “person2” with only the “name” and “address” properties specified.</p><p>By making all properties optional, we can create new objects with less code and more flexibility. This can be especially useful when working with large interfaces or classes.</p><p>In conclusion, making all properties optional in TypeScript is a powerful feature that can save time and make your code more flexible. By using the “?” symbol after each property name, you can create new objects with only the properties that you need. Give it a try in your next TypeScript project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f5e5e431edc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert a String to a Number in TypeScript]]></title>
            <link>https://medium.com/@glasshost/convert-a-string-to-a-number-in-typescript-649a0e6ec07a?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/649a0e6ec07a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:17:43 GMT</pubDate>
            <atom:updated>2023-05-05T04:17:43.493Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Convert a String to a Number in TypeScript" src="https://cdn-images-1.medium.com/max/800/0*NQQz3jFll4OC8pzP.png" /></figure><p>TypeScript is a superset of JavaScript that adds optional static typing and other features to the language. Sometimes, it becomes necessary to convert a string to a number in TypeScript. This guide will walk you through the steps required to do that.</p><h4>Using parseInt() Function</h4><p>One way to convert a string to a number in TypeScript is to use the parseInt() function. This function takes two arguments: the string to be converted and the base of the number system to be used. Here’s how to use this function:</p><pre>let str = &quot;10&quot;;<br>let num = parseInt(str);</pre><p>In the above code, we first define a string variable named `str` with the value of “10”. We then use the parseInt() function to convert this string to a number and assign it to the variable `num`. The resulting value of `num` is 10.</p><h4>Using parseFloat() Function</h4><p>Another way to convert a string to a number in TypeScript is to use the parseFloat() function. This function is used to convert a string to a floating-point number. Here’s how to use this function:</p><pre>let str = &quot;10.5&quot;;<br>let num = parseFloat(str);</pre><p>In the above code, we first define a string variable named `str` with the value of “10.5”. We then use the parseFloat() function to convert this string to a floating-point number and assign it to the variable `num`. The resulting value of `num` is 10.5.</p><h4>Using the Unary Plus Operator</h4><p>The third way to convert a string to a number in TypeScript is to use the unary plus operator. This operator converts a string to a number by implicitly calling the Number() constructor. Here’s how to use this operator:</p><pre>let str = &quot;10&quot;;<br>let num = +str;</pre><p>In the above code, we first define a string variable named `str` with the value of “10”. We then use the unary plus operator to convert this string to a number and assign it to the variable `num`. The resulting value of `num` is 10.</p><h4>Conclusion</h4><p>In this guide, we learned three ways to convert a string to a number in TypeScript: using the parseInt() function, using the parseFloat() function, and using the unary plus operator. Depending on your specific use case, one of these methods may be more appropriate than the others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=649a0e6ec07a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert a Number to a String in TypeScript]]></title>
            <link>https://medium.com/@glasshost/convert-a-number-to-a-string-in-typescript-5b84df8291f3?source=rss-e7b6a815cb2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b84df8291f3</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Glasshost]]></dc:creator>
            <pubDate>Fri, 05 May 2023 04:16:49 GMT</pubDate>
            <atom:updated>2023-05-05T04:16:49.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Convert a Number to a String in TypeScript" src="https://cdn-images-1.medium.com/max/800/0*YFXus9tvIkz-U702.png" /></figure><p>TypeScript is a superset of JavaScript that adds static typing to the language. It is widely used by developers to write large-scale applications. In this guide, we will learn how to convert a number to a string in TypeScript.</p><h4>Method 1: Using toString() Method</h4><p>The toString() method is used to convert a number to a string in TypeScript. The syntax for using the toString() method is as follows:</p><pre>let num: number = 123;<br>let str: string = num.toString();</pre><p>In the above example, we have defined a variable ‘num’ of type number and initialized it with the value 123. We have used the toString() method to convert the number to a string and assigned it to a variable ‘str’ of type string.</p><h4>Method 2: Using String() Function</h4><p>The String() function is another way to convert a number to a string in TypeScript. The syntax for using the String() function is as follows:</p><pre>let num: number = 123;<br>let str: string = String(num);</pre><p>In the above example, we have defined a variable ‘num’ of type number and initialized it with the value 123. We have used the String() function to convert the number to a string and assigned it to a variable ‘str’ of type string.</p><h4>Conclusion</h4><p>In this guide, we have learned two methods to convert a number to a string in TypeScript. The toString() method and the String() function are both simple and easy to use. You can choose any method according to your preference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b84df8291f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>