Package Exports
- alepha
- alepha/api/files
- alepha/api/jobs
- alepha/api/notifications
- alepha/api/users
- alepha/api/verifications
- alepha/batch
- alepha/bucket
- alepha/cache
- alepha/cache/redis
- alepha/command
- alepha/core
- alepha/datetime
- alepha/devtools
- alepha/email
- alepha/file
- alepha/lock
- alepha/lock/redis
- alepha/logger
- alepha/postgres
- alepha/queue
- alepha/queue/redis
- alepha/react
- alepha/react/auth
- alepha/react/form
- alepha/react/head
- alepha/react/i18n
- alepha/redis
- alepha/retry
- alepha/router
- alepha/scheduler
- alepha/security
- alepha/server
- alepha/server/cache
- alepha/server/compress
- alepha/server/cookies
- alepha/server/cors
- alepha/server/health
- alepha/server/helmet
- alepha/server/links
- alepha/server/metrics
- alepha/server/multipart
- alepha/server/proxy
- alepha/server/security
- alepha/server/static
- alepha/server/swagger
- alepha/topic
- alepha/topic/redis
- alepha/ui
- alepha/vite
Readme
A convention-driven TypeScript framework for building type-safe full-stack applications.
Quick Start
npx @alepha/cli create my-appOr manually:
npm install alephaWhat is this?
Alepha is an opinionated framework that handles everything from database to frontend.
It uses a descriptor-based architecture ($action, $page, $repository, etc.) and enforces type safety across the entire stack.
For more information, please visit the documentation.
Examples
Type-safe API endpoint
Write type-safe API endpoints with automatic OpenAPI documentation and more.
// app.ts
import { run, t } from "alepha";
import { $action } from "alepha/server";
import { $swagger } from "alepha/server/swagger";
class Api {
docs = $swagger({
info: {
title: "My API",
version: "1.0.0",
}
})
sayHello = $action({
path: "/hello/:name",
schema: {
params: t.object({
name: t.text()
}),
response: t.object({
message: t.text(),
})
},
handler: async ({ params }) => {
return { message: `Hello ${params.name} !` };
}
});
}
run(Api);node app.tsDatabase with Drizzle ORM
Drizzle ORM is a type-safe ORM for TypeScript, bundled inside Alepha.
You need drizzle-kit CLI as dev dependencies:
npm install -D drizzle-kit// app.ts
import { $hook, run, t } from "alepha";
import { $entity, $repository, pg } from "alepha/postgres";
import { $logger } from "alepha/logger";
export const users = $entity({
name: "users",
schema: t.object({
id: pg.primaryKey(),
name: t.text(),
}),
});
class Db {
log = $logger();
users = $repository(users);
ready = $hook({
on: "ready",
handler: async () => {
await this.users.create({
name: "John Doe",
});
this.log.info("Users:", await this.users.find());
}
})
}
run(Db)node app.tsReact Application
Build full-stack React applications, with server-side rendering (SSR) and client-side rendering (CSR).
React is required as a dependency:
npm install react react-dom
npm install -D @types/react// app.tsx
import { run, t } from "alepha";
import { $page } from "alepha/react";
import { useState } from "react";
const Hello = (props: { count: number }) => {
const [ count, setCount ] = useState(props.count);
return <button onClick={() => setCount(count + 1)}>Clicked: {count}</button>
}
class HomePage {
index = $page({
schema: {
query: t.object({
start: t.number({ default: 0 }),
})
},
component: Hello,
resolve: (req) => {
return { count: req.query.start };
},
});
}
run(HomePage);Vite is required as a devDependencies:
npm install -D viteAdd the Alepha Vite plugin to your Vite config:
// vite.config.ts
import { viteAlepha } from "alepha/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
viteAlepha()
]
});Create an index.html file:
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>App</title>
</head>
<body>
<script type="module" src="app.tsx"></script>
</body>
</html>Then run Vite:
npx viteLicense
MIT
Alepha