Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
- Migrate from `x.vweb` to `veb`
- Rename project to `Tiniest Veb Server (tVeb)`
  • Loading branch information
davlgd committed Sep 29, 2024
1 parent 17e6964 commit 1efd99a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release-multiarch.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow build tws binary and calculate SHA256/512 sums when a release is created
# This workflow build tVeb binary and calculate SHA256/512 sums when a release is created
# It then uploads the generated files to the release

name: Build TWS with V
name: Build tVeb with V

on:
release:
Expand Down Expand Up @@ -36,10 +36,10 @@ jobs:
git clone https://github.com/vlang/v
cd v && make || cmd /c make.bat
- name: Build tws & calculate checksums (UNIX)
- name: Build tVeb & calculate checksums (UNIX)
run: scripts/release.sh
if: runner.os != 'Windows'
- name: Build tws & calculate checksums (Windows)
- name: Build tVeb & calculate checksums (Windows)
run: cmd /c scripts\release.bat
if: runner.os == 'Windows'

Expand All @@ -54,9 +54,9 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
bin/tws-${{ env.OS_NAME }}-${{ env.ARCH }}
bin/tws-${{ env.OS_NAME }}-${{ env.ARCH }}.sha256
bin/tws-${{ env.OS_NAME }}-${{ env.ARCH }}.sha512
bin/tVeb-${{ env.OS_NAME }}-${{ env.ARCH }}
bin/tVeb-${{ env.OS_NAME }}-${{ env.ARCH }}.sha256
bin/tVeb-${{ env.OS_NAME }}-${{ env.ARCH }}.sha512
env:
OS_NAME: ${{ runner.os == 'Windows' && 'windows' || env.OS_NAME }}
ARCH: ${{ runner.os == 'Windows' && 'x86_64.exe' || env.ARCH }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Binaries for programs and plugins
main
tws
tVeb
*.exe
*.exe~
*.so
Expand All @@ -19,6 +19,6 @@ bin/
# ENV
.env

# vweb and database
# veb and database
*.db
*.js
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Tiniest vWeb Server
# Tiniest Veb Server

## 0.2.0 (2024-09-29)

- Migrate from `x.vweb` to `veb`
- Rename project to `Tiniest Veb Server (tVeb)`

## 0.1.5 (2024-02-18)

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tiniest vWeb Server
# Tiniest Veb Server

The efficient multiplatform open source solution to host your static stuff, written in [V](https://vlang.io), using the new [x.vweb vlib](https://github.com/vlang/v/tree/master/vlib/x/vweb). It fits in a single binary < 1 MB, without compression! It's a single binary, easy to compile, light and fast.
The efficient multiplatform open source solution to host your static stuff, written in [V](https://vlang.io), using the new [veb vlib](https://github.com/vlang/v/tree/master/vlib/veb). It fits in a single binary < 1 MB, without compression! It's a single binary, easy to compile, light and fast.

I use it to host [my tech blog](https://labs.davlgd.fr).

Expand All @@ -22,14 +22,14 @@ Once you have V installed, clone this repository and build with the following co
v -prod .
```

Binaries for ARM64 Linux, macOS, x86_64 Linux, macOS, Windows are available. You can download them and SHA256/512 sums from the [releases page](https://github.com/davlgd/tws/releases).
Binaries for ARM64 Linux, macOS, x86_64 Linux, macOS, Windows are available. You can download them and SHA256/512 sums from the [releases page](https://github.com/davlgd/tVeb/releases).

## Run the server

Run the with the following command. It will serve files from the `public` folder by default:

```bash
./tws
./tVeb
```

To check if everything is fine, open your browser and go to [`http://localhost:8080`](http://localhost:8080). If you use the content of this repository, you should see content of the `index.html` file from the `public` folder.
Expand All @@ -46,13 +46,13 @@ curl http://localhost:8080
You can specify the folder where your files are located:

```bash
./tws /path/to/your/folder
./tVeb /path/to/your/folder
```

To change the port:
```bash
./tws 4242
./tws /path/to/your/folder 4242
./tVeb 4242
./tVeb /path/to/your/folder 4242
```
## Custom headers

Expand Down
4 changes: 2 additions & 2 deletions scripts/release.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@echo off

Set "FILE_NAME=tws-windows-x86_64.exe"
Set "FILE_NAME=tVeb-windows-x86_64.exe"
Set "BIN_FOLDER=bin"
mkdir %BIN_FOLDER%

echo "Building tws for Windows and x86_64 architecture as %FILE_NAME%..."
echo "Building tVeb for Windows and x86_64 architecture as %FILE_NAME%..."
v\v -prod . -o "%BIN_FOLDER%\%FILE_NAME%"

CertUtil -hashfile "%BIN_FOLDER%\%FILE_NAME%" SHA256 > "%BIN_FOLDER%\%FILE_NAME%.sha256"
Expand Down
4 changes: 2 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
FILE_NAME="tws-$OS_NAME-$ARCH"
FILE_NAME="tVeb-$OS_NAME-$ARCH"
BIN_FOLDER="bin"

echo "Building tws for ${OS_NAME} and ${ARCH} architecture as ${FILE_NAME}..."
echo "Building tVeb for ${OS_NAME} and ${ARCH} architecture as ${FILE_NAME}..."
mkdir -p ${BIN_FOLDER} && v/v -prod . -o "${BIN_FOLDER}/${FILE_NAME}"

(shasum -a 512 "${BIN_FOLDER}/${FILE_NAME}" 2>/dev/null || sha512sum ${FILE_NAME}) > "${BIN_FOLDER}/${FILE_NAME}.sha512"
Expand Down
14 changes: 7 additions & 7 deletions src/tws.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import os
import net
import toml
import time
import x.vweb
import veb
import net.http

pub struct Context {
vweb.Context
veb.Context
}

pub struct App {
vweb.StaticHandler
vweb.Middleware[Context]
veb.StaticHandler
veb.Middleware[Context]
}

fn print_help() {
Expand Down Expand Up @@ -57,7 +57,7 @@ fn get_settings() (string, int, string) {
return folder, port, error
}

pub fn (mut ctx Context) not_found() vweb.Result {
pub fn (mut ctx Context) not_found() veb.Result {
folder, _, _ := get_settings()
mut file_path := '404.html'

Expand All @@ -84,7 +84,7 @@ fn add_headers_to_context(mut ctx Context) {
default_expiration_delay := 3600
headers := toml.parse_file('headers.toml') or { panic(err) }

ctx.set_header(.server, 'Tiniest vWeb Server')
ctx.set_header(.server, 'Tiniest Veb Server')
ctx.res.header.add(http.CommonHeader.cache_control, headers
.value('cache_control')
.default_to(default_cache_control)
Expand Down Expand Up @@ -135,5 +135,5 @@ fn main() {
app.handle_static(folder, true)!
app.use(handler: custom_headers, after: true)
println("Server is started, serving '${folder}' folder")
vweb.run[App, Context](mut app, port)
veb.run[App, Context](mut app, port)
}
6 changes: 3 additions & 3 deletions v.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Module {
name: 'tws'
name: 'tVeb'
author: 'davlgd'
description: 'Tiniest vWeb Server, the efficient multiplatform open source solution to host your static stuff, written in V'
description: 'Tiniest Veb Server, the efficient multiplatform open source solution to host your static stuff, written in V'
version: '0.1.5'
license: 'MIT'
vcs: 'git'
repo_url: 'https://github.com/davlgd/tws'
repo_url: 'https://github.com/davlgd/tVeb'
tags: ['web','networking']
dependencies: []
}

0 comments on commit 1efd99a

Please sign in to comment.