# Deploying
---
# Cloud Platforms
---
### What is PaaS?
<font size = '6' color= yellow>
Platform as a Service(PaaS) is one of four types of cloud services, along with:
- Software as a Service (SaaS);
- Infrastructure as a Service (IaaS);
- and Serverless.
PaaS is a complete development and deployment environment in the cloud.
</font>
---
<font size = '6' color= yellow>
- PaaS allows you to avoid the expense and complexity of buying and managing software licences and the underlying application infrastructure, middleware, container orchestrators or development tools and other resources.
</font>
---
### Among the leading PaaS providers are:
<font color= yellow>
* Amazon Web Services (AWS)
* Microsoft
* Google
* IBM
* Salesforce
* Red Hat
* Pivotal
* Heroku
</font>
---
#### They offer cloud-based services that include:
<font color= yellow>
* storage
* databases
* compute
* analytics
* networking
* mobile back-end
* developer tools
* management tools
* security
</font>
---
## AWS Elastic Beanstalk
<font size = '6' color= yellow> Companies can quickly deploy and manage applications in the AWS Cloud without having to learn about the infrastructure that runs the applications.
It automatically handles the details of ***capacity provisioning***, ***load balancing***, ***scaling,*** and ***application health monitoring***. </font>
---
## Google Cloud Functions
<font size = '6' color= yellow> Designed to make it easy for developers to ***run and scale code*** in the cloud and ***build event-driven serverless*** applications.</font>
---
## Salesforce
<font size = '6' color= yellow> A company that sells a complementary suite of enterprise applications focused on ***customer service, marketing automation, analytics*** and ***application development***.</font>
---
# Environment Variables
---
### What is environment variable
<font color= yellow>
Wherever you needs to hide sensitive data in your configuration file, you use environment variables.
They are simply a name mapped to a value that are external to our application which reside in the OS or the container of the app it is running in.
</font>
---
---
### Why might some variables in your code need to change for different environments?
<font color= yellow>
So when pushing the code to GitHub we have to make sure passwords, tokens, or databases don't get pushed where it can get leaked. So it is important to store them in a configuration file and put the file in .gitignore.
</font>
---
### Why is it a bad idea to include those variables in a public repository?
---
#### Example 1

---
#### Example 2

---
### What modules might you use to help manage environment variables?
---
#### env2 Module
<font size = '6' color= yellow>
env2 allows you to store your environment variables in an env.json or a .env file which gets loaded when your app starts.
</font>
---
#### the .env File
filename.env
```
export DB_HOST=127.0.0.1
export DB_PORT=9200
export DB_USER=anon
export DB_PASS=password
```
---
### Code Along
---
#### Go to Node-Intro-Workshop

#### Install

#### Create your file

#### Export it to your server
```
const env = require('env2')(__dirname + "/democonfig.env")
```
#### You can now access your sensitive info
```
console.log(process.env.DB_USERNAME)
```
---
## Deploy a Simple Server to Heroku as a Demo

<font size = '6'>Heroku Documentation
[https://devcenter.heroku.com/articles/deploying-nodejs#overview](https://)</font>
{"metaMigratedAt":"2023-06-15T01:46:52.145Z","metaMigratedFrom":"Content","title":"Deploying","breaks":true,"contributors":"[{\"id\":\"8df6977e-0462-4cc9-98d6-4750e77012fd\",\"add\":691,\"del\":222},{\"id\":\"09c2cb97-7340-43ab-a79b-d087b968c372\",\"add\":3112,\"del\":1657},{\"id\":\"5ae2520e-a235-4412-9708-bef9037d4b47\",\"add\":1551,\"del\":496},{\"id\":\"b4645149-fe35-4695-95c6-3355ab3f4fc8\",\"add\":1233,\"del\":435}]"}