Compare commits

...

2 Commits

Author SHA1 Message Date
Jef Roosens 2a4f0654ea
WIP: api testing 2022-06-15 12:21:14 +02:00
Jef Roosens 2fea78a6f8
feat(server): add config option for server port 2022-06-15 12:10:58 +02:00
6 changed files with 22 additions and 3 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
* Moved all API routes under `/v1` namespace * Moved all API routes under `/v1` namespace
* Server port can now be configured
## [0.3.0](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0) ## [0.3.0](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0)

View File

@ -12,7 +12,7 @@ pub fn (c &Client) get_targets(filter TargetFilter) ?[]Target {
return data.data return data.data
} }
// get_all_targets retrieves *all* targs from the API using the default // get_all_targets retrieves *all* targets from the API using the default
// limit. // limit.
pub fn (c &Client) get_all_targets() ?[]Target { pub fn (c &Client) get_all_targets() ?[]Target {
mut targets := []Target{} mut targets := []Target{}

View File

@ -1,4 +1,5 @@
// Bindings for the libarchive library // Bindings for the libarchive library
module package
#flag -larchive #flag -larchive

View File

@ -0,0 +1,17 @@
module server
import io.util
import os
fn test_targets_api() ? {
// Create a database
// Start the server in a temporary directory
tmpdir := util.temp_dir()?
go server.server(
data_dir: tmpdir
pkg_dir: os.join_path_single(tmpdir, 'pkgs')
api_key: 't'
port: 9000
)
}

View File

@ -10,6 +10,7 @@ pub:
data_dir string data_dir string
api_key string api_key string
default_arch string default_arch string
port int = 8000
} }
// cmd returns the cli submodule that handles starting the server // cmd returns the cli submodule that handles starting the server

View File

@ -8,7 +8,6 @@ import util
import db import db
const ( const (
port = 8000
log_file_name = 'vieter.log' log_file_name = 'vieter.log'
repo_dir_name = 'repos' repo_dir_name = 'repos'
db_file_name = 'vieter.sqlite' db_file_name = 'vieter.sqlite'
@ -77,5 +76,5 @@ pub fn server(conf Config) ? {
conf: conf conf: conf
repo: repo repo: repo
db: db db: db
}, server.port) }, conf.port)
} }