WIP
test / test (push) Failing after 7s
Details
test / test (push) Failing after 7s
Details
This commit is contained in:
parent
92c985667f
commit
9643ad489e
|
@ -6,7 +6,7 @@ import app/web/root
|
||||||
import wisp.{type Request, type Response}
|
import wisp.{type Request, type Response}
|
||||||
|
|
||||||
pub fn handle_request(req: Request, ctx: Context) -> Response {
|
pub fn handle_request(req: Request, ctx: Context) -> Response {
|
||||||
use req: Request <- web.middleware(req)
|
use req <- web.middleware(req)
|
||||||
|
|
||||||
case wisp.path_segments(req) {
|
case wisp.path_segments(req) {
|
||||||
["f", ..] -> file.handle_request(req, ctx)
|
["f", ..] -> file.handle_request(req, ctx)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import app/config.{type Context, Context}
|
import app/config.{type Context, Context}
|
||||||
import app/router
|
import app/router
|
||||||
|
import app/web/file
|
||||||
|
import app/web/link
|
||||||
import gleam/erlang/process
|
import gleam/erlang/process
|
||||||
import gleam/option.{Some}
|
import gleam/option.{Some}
|
||||||
import gleam/pgo
|
import gleam/pgo
|
||||||
|
@ -8,8 +10,13 @@ import mist
|
||||||
import wisp
|
import wisp
|
||||||
|
|
||||||
fn with_context(continue: fn(Context) -> Nil) -> Nil {
|
fn with_context(continue: fn(Context) -> Nil) -> Nil {
|
||||||
|
wisp.log_info("Reading configuration from environment...")
|
||||||
let config = config.load_config_from_env()
|
let config = config.load_config_from_env()
|
||||||
|
|
||||||
|
wisp.log_info("Starting CUID Generator...")
|
||||||
let assert Ok(cuid) = cuid.start()
|
let assert Ok(cuid) = cuid.start()
|
||||||
|
|
||||||
|
wisp.log_info("Connecting to Postgres...")
|
||||||
let db =
|
let db =
|
||||||
pgo.connect(
|
pgo.connect(
|
||||||
pgo.Config(
|
pgo.Config(
|
||||||
|
@ -25,16 +32,27 @@ fn with_context(continue: fn(Context) -> Nil) -> Nil {
|
||||||
)
|
)
|
||||||
let ctx = Context(db: db, config: config, cuid: cuid)
|
let ctx = Context(db: db, config: config, cuid: cuid)
|
||||||
|
|
||||||
|
wisp.log_info("Initializing database...")
|
||||||
|
initialize_db(ctx)
|
||||||
|
|
||||||
continue(ctx)
|
continue(ctx)
|
||||||
|
|
||||||
ctx.db |> pgo.disconnect
|
ctx.db |> pgo.disconnect
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
fn initialize_db(ctx: Context) -> Nil {
|
||||||
use ctx <- with_context()
|
let assert Ok(_) = file.prepare_database(ctx)
|
||||||
|
let assert Ok(_) = link.prepare_database(ctx)
|
||||||
|
Nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
wisp.configure_logger()
|
wisp.configure_logger()
|
||||||
|
|
||||||
|
wisp.log_info("Welcome to Dumptruck!")
|
||||||
|
|
||||||
|
use ctx <- with_context()
|
||||||
|
|
||||||
let assert Ok(_) =
|
let assert Ok(_) =
|
||||||
router.handle_request(_, ctx)
|
router.handle_request(_, ctx)
|
||||||
|> wisp.mist_handler(ctx.config.secret_key_base)
|
|> wisp.mist_handler(ctx.config.secret_key_base)
|
||||||
|
@ -42,5 +60,7 @@ pub fn main() {
|
||||||
|> mist.port(ctx.config.port)
|
|> mist.port(ctx.config.port)
|
||||||
|> mist.start_http
|
|> mist.start_http
|
||||||
|
|
||||||
|
wisp.log_info("Accepting requests!")
|
||||||
|
|
||||||
process.sleep_forever()
|
process.sleep_forever()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,20 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
frontend:
|
# frontend:
|
||||||
image: dpage/pgadmin4
|
# image: dpage/pgadmin4
|
||||||
environment:
|
# environment:
|
||||||
PGADMIN_DEFAULT_EMAIL: "test@example.com"
|
# PGADMIN_DEFAULT_EMAIL: "test@example.com"
|
||||||
PGADMIN_DEFAULT_PASSWORD: "test"
|
# PGADMIN_DEFAULT_PASSWORD: "test"
|
||||||
PGADMIN_LISTEN_PORT: "80"
|
# PGADMIN_LISTEN_PORT: "80"
|
||||||
PGADMIN_CONFIG_SERVER_MODE: "False"
|
# PGADMIN_CONFIG_SERVER_MODE: "False"
|
||||||
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
|
# PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
|
||||||
depends_on:
|
# depends_on:
|
||||||
- "db"
|
# - "db"
|
||||||
volumes:
|
# volumes:
|
||||||
- read_only: true
|
# - read_only: true
|
||||||
source: "servers.json"
|
# source: "servers.json"
|
||||||
target: "/pgadmin4/servers.json"
|
# target: "/pgadmin4/servers.json"
|
||||||
type: bind
|
# type: bind
|
||||||
ports:
|
# ports:
|
||||||
- "8080:80"
|
# - "8080:80"
|
||||||
|
|
Loading…
Reference in New Issue