Add initial project structure for NexaCore programming language compiler: - Create Cargo workspace with 4 crates (cli, driver, frontend, runtime) - Add lexer with indentation-based tokenization and keyword support - Add parser for modules, functions, structs, and basic expressions - Implement CLI with build command and placeholder subcommands - Add driver crate to orchestrate compilation pipeline - Include .gitignore for Rust build
31 lines
732 B
Plaintext
31 lines
732 B
Plaintext
use core.env
|
|
use db.postgres.Pool
|
|
use web.http.{App, Response}
|
|
|
|
struct AppState:
|
|
pool: Pool
|
|
|
|
async fn health(state: AppState) -> Response:
|
|
let version = env.get("APP_VERSION").or("dev")
|
|
let row = await state.pool.query_one<Map>(
|
|
"select now() as now"
|
|
)?
|
|
|
|
Response.json({
|
|
"status": "ok",
|
|
"version": version,
|
|
"database_time": row["now"]
|
|
})
|
|
|
|
async fn main() -> Result<Void, AppError>:
|
|
let database_url = env.require("DATABASE_URL")?
|
|
let port = env.get("PORT").or("8080").to_int()?
|
|
let pool = Pool.connect(database_url, max: 16)?
|
|
|
|
let app = App.new()
|
|
.state(AppState { pool: pool })
|
|
.get("/health", health)
|
|
|
|
await app.listen("0.0.0.0", port)?
|
|
|