Skip to content

JaCaLla/HelloServer

Repository files navigation

Vapor API

This is a simple Vapor-based API that serves a single endpoint to return a greeting message with environment variables. This is the base code used in following posts Customizing Vapor Server Configurations

Features

  • Implements a single endpoint /hello
  • Reads values from environment variables
  • Returns a greeting message including a secret value

Requirements

  • Swift (latest stable version)
  • Vapor 4
  • Docker (optional, for containerized deployment)

Installation & Setup

  1. Clone the repository:
    git clone https://github.com/your-username/your-repo.git
    cd your-repo
  2. Install dependencies:
    swift package resolve
  3. Set up environment variables:
    export CUSTOM_VARIABLE="YourName"
    export SECRET="YourSecretValue"
  4. Run the application:
    swift run

API Endpoints

GET /hello

Description: Returns a greeting message including the secret value.

Response:

"Hello, YourName! secret is YourSecretValue"

Deployment

To deploy using Docker:

  1. Build the Docker image:
    docker build -t vapor-app .
  2. Run the container:
    docker run -p 8080:

About

Hello server Vapor used as a sample for having access to environment variables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published