Skip to content

Commit

Permalink
Merge pull request #986 from Badgerati/develop
Browse files Browse the repository at this point in the history
v2.7.0
  • Loading branch information
Badgerati authored Jun 22, 2022
2 parents 7e9b053 + da92730 commit eee125e
Show file tree
Hide file tree
Showing 97 changed files with 34,404 additions and 937 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# These are supported funding model platforms

github: [Badgerati]
ko_fi: badgerati
custom: ["https://www.paypal.me/badgerati"]
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ jobs:
shell: pwsh
run: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Build Test
Invoke-Build Test
- name: Test docker builds
shell: pwsh
run: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Build DockerPack -Version '0.0.0'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:7.2.1-ubuntu-20.04
FROM mcr.microsoft.com/powershell:7.2-ubuntu-20.04
LABEL maintainer="Matthew Kelly (Badgerati)"
RUN mkdir -p /usr/local/share/powershell/Modules/Pode
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# <img src="https://github.com/Badgerati/Pode/blob/develop/images/icon-transparent.png?raw=true" width="30" style="margin-bottom:-5px;margin-right:-3px" /> Pode
<p align="center">
<img src="https://github.com/Badgerati/Pode/raw/develop/images/icon-new.svg?raw=true" width="250" />
</p>

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Badgerati/Pode/master/LICENSE.txt)
[![Documentation](https://img.shields.io/github/v/release/badgerati/pode?label=docs)](https://badgerati.github.io/Pode)
[![Documentation](https://img.shields.io/github/v/release/badgerati/pode?label=docs&logo=readthedocs&logoColor=white)](https://badgerati.github.io/Pode)
[![GitHub Actions](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbadgerati%2Fpode%2Fbadge&style=flat&label=GitHub)](https://actions-badge.atrox.dev/badgerati/pode/goto)
[![Code Coverage](https://coveralls.io/repos/github/Badgerati/Pode/badge.svg?branch=develop)](https://coveralls.io/github/Badgerati/Pode?branch=develop)
[![Discord](https://img.shields.io/discord/887398607727255642)](https://discord.gg/fRqeGcbF6h)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/Badgerati?color=%23ff69b4&logo=github&style=flat&label=Sponsers)](https://github.com/sponsors/Badgerati)
[![Discord](https://img.shields.io/discord/887398607727255642?logo=discord&logoColor=white)](https://discord.gg/fRqeGcbF6h)

[![Chocolatey](https://img.shields.io/chocolatey/dt/pode.svg?label=Chocolatey&colorB=a1301c)](https://chocolatey.org/packages/pode)
[![PowerShell](https://img.shields.io/powershellgallery/dt/pode.svg?label=PowerShell&colorB=085298)](https://www.powershellgallery.com/packages/Pode)
[![Docker](https://img.shields.io/docker/pulls/badgerati/pode.svg?label=Docker)](https://hub.docker.com/r/badgerati/pode/)
[![Chocolatey](https://img.shields.io/chocolatey/dt/pode.svg?label=Chocolatey&colorB=a1301c&logo=chocolatey&logoColor=white)](https://chocolatey.org/packages/pode)
[![PowerShell](https://img.shields.io/powershellgallery/dt/pode.svg?label=PowerShell&colorB=085298&logo=powershell&logoColor=white)](https://www.powershellgallery.com/packages/Pode)
[![Docker](https://img.shields.io/docker/pulls/badgerati/pode.svg?label=Docker&logoColor=white&logo=docker)](https://hub.docker.com/r/badgerati/pode/)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/Badgerati?color=%23ff69b4&logo=github&style=flat&label=Sponsers)](https://github.com/sponsors/Badgerati)
[![Ko-fi](https://img.shields.io/static/v1?logo=kofi&label=Ko-fi&logoColor=white&message=Buy+me+a+coffee&color=ff5f5f)](https://ko-fi.com/badgerati)
[![PayPal](https://img.shields.io/static/v1?logo=paypal&label=PayPal&logoColor=white&message=Donate&color=00457C)](https://paypal.me/badgerati)

> 💝 A lot of my free time, evenings, and weekends goes into making Pode happen; please do consider sponsoring as it will really help! 😊
Pode is a Cross-Platform framework for creating web servers to host [REST APIs](https://badgerati.github.io/Pode/Tutorials/Routes/Overview/), [Web Pages](https://badgerati.github.io/Pode/Tutorials/Routes/Examples/WebPages/), and [SMTP/TCP](https://badgerati.github.io/Pode/Hosting/SmtpServer/) Servers. Pode also allows you to render dynamic files using [`.pode`](https://badgerati.github.io/Pode/Tutorials/Views/Pode/) files, which are just embedded PowerShell, or other [Third-Party](https://badgerati.github.io/Pode/Tutorials/Views/ThirdParty/) template engines. Plus many more features, including [Azure Functions](https://badgerati.github.io/Pode/Hosting/AzureFunctions/) and [AWS Lambda](https://badgerati.github.io/Pode/Hosting/AwsLambda/) support!
Pode is a Cross-Platform framework for creating web servers to host [REST APIs](https://badgerati.github.io/Pode/Tutorials/Routes/Overview/), [Web Pages](https://badgerati.github.io/Pode/Tutorials/Routes/Examples/WebPages/), and [SMTP/TCP](https://badgerati.github.io/Pode/Servers/) Servers. Pode also allows you to render dynamic files using [`.pode`](https://badgerati.github.io/Pode/Tutorials/Views/Pode/) files, which are just embedded PowerShell, or other [Third-Party](https://badgerati.github.io/Pode/Tutorials/Views/ThirdParty/) template engines. Plus many more features, including [Azure Functions](https://badgerati.github.io/Pode/Hosting/AzureFunctions/) and [AWS Lambda](https://badgerati.github.io/Pode/Hosting/AwsLambda/) support!

<p align="center">
<img src="https://github.com/Badgerati/Pode/blob/develop/images/example_code_2.png?raw=true" />
Expand All @@ -40,7 +45,7 @@ Then navigate to `http://127.0.0.1:8000` in your browser.
* Azure Functions, AWS Lambda, and IIS support
* OpenAPI, Swagger, and ReDoc support
* Listen on a single or multiple IP address/hostnames
* Cross-platform support for HTTP, HTTPS, TCP and SMTP
* Cross-platform support for HTTP(S), SMTP(S), and TCP(S)
* Cross-platform support for WebSockets, including secure WebSockets
* Host REST APIs, Web Pages, and Static Content (with caching)
* Support for custom error pages
Expand Down
2 changes: 1 addition & 1 deletion alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211209
FROM mcr.microsoft.com/powershell:7.2-alpine-3.14
LABEL maintainer="Matthew Kelly (Badgerati)"
RUN mkdir -p /usr/local/share/powershell/Modules/Pode
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode
2 changes: 1 addition & 1 deletion arm32.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/powershell:7.2.1-arm32v7-ubuntu-18.04-20211209
FROM mcr.microsoft.com/powershell:7.2-arm32v7-ubuntu-18.04
LABEL maintainer="Matthew Kelly (Badgerati)"
RUN mkdir -p /usr/local/share/powershell/Modules/Pode
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode
6 changes: 3 additions & 3 deletions docs/Getting-Started/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Install-Module -Name Pode
[![Docker](https://img.shields.io/docker/stars/badgerati/pode.svg?label=Stars)](https://hub.docker.com/r/badgerati/pode/)
[![Docker](https://img.shields.io/docker/pulls/badgerati/pode.svg?label=Pulls)](https://hub.docker.com/r/badgerati/pode/)

Pode can run on *nix environments, therefore it only makes sense for there to be Docker images for you to use! The images use PowerShell v7.2.1 on either an Ubuntu Focal image (default), an Alpine image, or an ARM32 image (for Raspberry Pis).
Pode can run on *nix environments, therefore it only makes sense for there to be Docker images for you to use! The images use PowerShell v7.2 on either an Ubuntu Focal image (default), an Alpine image, or an ARM32 image (for Raspberry Pis).

* To pull down the latest Pode image you can do:

Expand Down Expand Up @@ -73,7 +73,7 @@ docker pull badgerati/pode:latest-arm32
docker pull badgerati/pode:2.2.2-arm32
```

Once pulled, you can [view here](../Docker) on how to use the image.
Once pulled, you can [view here](../../Hosting/Docker) on how to use the image.

## GitHub Package Registry

Expand Down Expand Up @@ -109,7 +109,7 @@ docker pull docker.pkg.github.com/badgerati/pode/pode:latest-arm32
docker pull docker.pkg.github.com/badgerati/pode/pode:2.2.2-arm32
```

Once pulled, you can [view here](../Docker) on how to use the image.
Once pulled, you can [view here](../../Hosting/Docker) on how to use the image.

## Using the Module

Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-Started/Migrating/0X-to-1X.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The `gui` function use to take a Name with a hashtable of options. This function

## Handlers

([Tutorial](../../../Hosting/SmtpServer))
([Tutorial](../../../Servers/SMTP))

The biggest change the Handlers is that you can now create multiple handlers for each of SMTP, TCP and Service - rather than just one. With this, the new [`Add-PodeHandler`](../../../Functions/Handlers/Add-PodeHandler) requires a `-Name` to be supplied.

Expand Down
2 changes: 1 addition & 1 deletion docs/Hosting/AwsLambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Start-PodeServer -Request $LambdaInput -ServerlessType AwsLambda -RootPath '/tmp

### Static Content

Unlike Azure Functions, static content in AWS Functions can be served up in the normal way - assuming your function can recieve multiple routes.
Unlike Azure Functions, static content in AWS Functions can be served up in the normal way - assuming your function can receive multiple routes.

For example, if you have a CSS stylesheet at `/tmp/www/styles/main.css.pode`, then your `index.pode` view would get this as such:

Expand Down
4 changes: 2 additions & 2 deletions docs/Hosting/Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pode has a Docker image that you can use to host your server, for instructions on pulling these images you can [look here](../../Installation).

The images use PowerShell v7.2.1 on either an Ubuntu Focal (default), Alpine, or ARM32 image.
The images use PowerShell v7.2 on either an Ubuntu Focal (default), Alpine, or ARM32 image.

## Images

Expand All @@ -11,7 +11,7 @@ The images use PowerShell v7.2.1 on either an Ubuntu Focal (default), Alpine, or

### Default

The default Pode image is an Ubuntu Focal image with PowerShell v7.2.1 and Pode installed. An example of using this image in your Dockerfile could be as follows:
The default Pode image is an Ubuntu Focal image with PowerShell v7.2 and Pode installed. An example of using this image in your Dockerfile could be as follows:

```dockerfile
# pull down the pode image
Expand Down
45 changes: 37 additions & 8 deletions docs/Hosting/SmtpServer.md → docs/Servers/SMTP.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# SMTP Server
# SMTP

Pode has an inbuilt SMTP server for receiving Email which automatically creates a TCP listener on port 25 - unless you specify a different port via the [`Add-PodeEndpoint`](../../Functions/Core/Add-PodeEndpoint) function.

Unlike with web servers that use the Route functions, SMTP servers use the Handler functions, which let you specify logic for handling responses from TCP streams.
Pode has an inbuilt SMTP server for receiving emails, with support for non-TLS as well as implicit and explicit TLS. Unlike with web servers that use the Route functions, an SMTP server use the Handler functions, which let you specify logic for handling responses from TCP streams.

!!! tip
You can setup multiple different Handlers to run different logic for one Email.
You can setup multiple different Handlers to run different logic for one email.

## Usage

To create a Handler for the inbuilt SMTP server you can use the following example:
To create a Handler for the SMTP server you can use the following example:

```powershell
Start-PodeServer {
Expand All @@ -23,14 +21,43 @@ Start-PodeServer {
}
```

Starting this server will listen for incoming email on `localhost:25`. The Handler will have access to the `$SmtpEvent` object (see below), which contains information about the Email.
Starting this server will listen for incoming email on `localhost:25`. The Handler will have access to an `$SmtpEvent` object (see below), which contains information about the received email.

An example of sending Email to the above server via `Send-MailMessage`:
An example of sending an email to the above server via `Send-MailMessage`:

```powershell
Send-MailMessage -SmtpServer localhost -To '[email protected]' -From '[email protected]' -Body 'Hello' -Subject 'Hi there' -Port 25
```

## TLS

You can enable TLS for your endpoints by supplying the normal relevant certificates parameters on [`Add-PodeEndpoint`](../../Functions/Core/Add-PodeEndpoint), and setting the `-Protocol` to `Smtps`. You can also toggle between implicit and explicit TLS by using the `-TlsMode` parameter.

By default the TLS mode is implicit, and the default port for implicit TLS is 465; for explicit TLS it's 587. These can of course be customised using `-Port`.

```powershell
Start-PodeServer {
Add-PodeEndpoint -Address * -Protocol Smtps -SelfSigned -TlsMode Explicit
Add-PodeEndpoint -Address * -Protocol Smtps -SelfSigned -TlsMode Implicit
Add-PodeHandler -Type Smtp -Name 'Main' -ScriptBlock {
Write-Host $SmtpEvent.Email.From
Write-Host $SmtpEvent.Email.To
Write-Host $SmtpEvent.Email.Body
}
}
```

.NET only supports explicit TLS, so an example of sending an email to the explicit TLS endpoint, on port 587, is as follows:

```powershell
# if using a self signed cert, make sure to run the below
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }
# send the email
Send-MailMessage -SmtpServer localhost -To '[email protected]' -From '[email protected]' -Body 'Hello' -Subject 'Hi there' -Port 587 -UseSSL
```

## Attachments

The SMTP server also accepts attachments, which are available in a Handler via `$SmtpEvent.Email.Attachments`. This property contains a list of available attachments on the Email, each attachment has a `Name` and `Bytes` properties - the latter being the raw byte content of the attachment.
Expand All @@ -55,6 +82,8 @@ The SMTP Handler will be passed the `$SmtpEvent` object, that contains the Reque
| Response | object | The raw Response object |
| Lockable | hashtable | A synchronized hashtable that can be used with `Lock-PodeObject` |
| Email | hashtable | An object containing data from the email, as seen below |
| Endpoint | hashtable | Contains the Address and Protocol of the endpoint being hit - such as "pode.example.com" or "127.0.0.2", or HTTP or HTTPS for the Protocol |
| Timestamp | datetime | The current date and time of the Request |

### Email

Expand Down
Loading

0 comments on commit eee125e

Please sign in to comment.