A production-ready (almost) compound (template and libs) built up-on elysiajs #1137
kwaitsing
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Elysia with URN.ts Lite
What is URN.ts Lite?
The original URN.ts was a framework built upon ElysiaJS, designed for large-scale applications with extensive routing.
However, as the Elysia codebase grew, maintaining the URN.ts framework became increasingly difficult.
To address this, URN.ts has been transformed into a library instead of a framework. It now provides a collection of tools and utilities for building robust backends directly on top of ElysiaJS.
Project Initialization
bunx urn-lite-spinup@latest <projectname>
. This command generates a ready-to-use Elysia codebase with URN.ts Lite integrated.Project Structure
Your application's entry point is
src/index.ts
. This is where your code execution begins.In the example aliases below, the
.ts
extension is typically omitted because TypeScript implicitly recognizes.ts
files.src/controller
@controller/user.c
src/misc
@misc/type
src/model
@model/user.m
src/schema
@schema/user.s
type.ts
files in@misc
for strong typing throughout your application.src/index
Component Overview
Dbi
andCDbi
(Classes)Sch2Ts
(Type)Sch2Ts<typeof userSchema.post>
@elysiajs/swagger
,bearer
,cors
,jwt
, andurn-logger
How-To-Use
Basic Usage
Once the template is set up, you'll find numerous comments within the code. Please read these carefully as they provide important guidance.
Recommended Development Workflow
The recommended development workflow follows a specific order:
src/schema
directory. This ensures strong typing and validation from the outset.src/model
directory. This is where you'll handle data manipulation, database interactions, and core application functionality.src/controller
directory. Each controller is an independent Elysia instance, responsible for handling specific routes related to a particular resource. The routes within each controller module are mounted to this instance.src/index.ts
).This approach promotes a clean separation of concerns and makes your codebase more maintainable and scalable.
Logger
URN.ts Lite includes
UrnLogger
, a simple yet powerful logger. It supports:The original readme was written in adoc however github discussions doesn't support asciidoc so i use gemini to transpile it into markdown
URN.ts has been running reliably in our production environment for nearly a year, as of the time of writing. Maybe it's luck or idk
**URN.ts lite has been operating stably in our production environment for 3 months, as of this writing. **
Beta Was this translation helpful? Give feedback.
All reactions