### Install Dependencies Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Install necessary dependencies for the authentication application. ```bash npm install express cors helmet dotenv better-auth better-sqlite3 ``` -------------------------------- ### Install UI Components Package Source: https://devx-op.github.io/effectify/react/getting-started Install the package for pre-built UI components. ```bash npm install @effectify/react-ui ``` -------------------------------- ### Install @effectify/chat-solid Source: https://devx-op.github.io/effectify/solid/installation Install the Effectify real-time chat components package. ```bash npm install @effectify/chat-solid ``` -------------------------------- ### Install @effectify/solid-ui Peer Dependencies Source: https://devx-op.github.io/effectify/solid/installation Install the peer dependencies required for @effectify/solid-ui. ```bash npm install solid-js tailwindcss @kobalte/core ``` -------------------------------- ### Install @effectify/solid-query Peer Dependencies Source: https://devx-op.github.io/effectify/solid/installation Install the necessary peer dependencies for @effectify/solid-query. ```bash npm install @tanstack/solid-query effect solid-js ``` -------------------------------- ### Install Dependencies Source: https://devx-op.github.io/effectify/solid/packages/solid-effect-atom Install the necessary packages for @effectify/solid-effect-atom, @effect-atom/atom, effect, and solid-js. ```bash npm install @effectify/solid-effect-atom @effect-atom/atom effect solid-js ``` -------------------------------- ### Install @effectify/node-auth-app Source: https://devx-op.github.io/effectify/backend/installation Install the complete authentication server application package using npm. ```bash npm install @effectify/node-auth-app ``` -------------------------------- ### Start Development Server Command Source: https://devx-op.github.io/effectify/backend/getting-started Command to start the development server using npm. ```bash npm run dev ``` -------------------------------- ### Install @effectify/solid-ui Source: https://devx-op.github.io/effectify/solid/installation Install the Effectify UI component library, which uses Kobalte and Tailwind CSS. ```bash npm install @effectify/solid-ui ``` -------------------------------- ### Create SolidStart Project and Install Effectify Source: https://devx-op.github.io/effectify/solid/installation Initialize a new SolidStart project and install the necessary Effectify packages. ```bash npm create solid@latest my-app -- --template solid-start cd my-app npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Install Chat Components Package Source: https://devx-op.github.io/effectify/react/getting-started Install the package for real-time chat functionality. ```bash npm install @effectify/chat-react ``` -------------------------------- ### Get Session Response Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON response containing current user and session details. ```json { "user": {/* user object */}, "session": {/* session object */}, } ``` -------------------------------- ### Install @effectify/node-better-auth Source: https://devx-op.github.io/effectify/backend/installation Install the core @effectify/node-better-auth package using npm. ```bash npm install @effectify/node-better-auth ``` -------------------------------- ### Install @effectify/chat-solid Peer Dependencies Source: https://devx-op.github.io/effectify/solid/installation Install the peer dependencies for @effectify/chat-solid. ```bash npm install @effectify/solid-query @effectify/chat-domain solid-js ``` -------------------------------- ### Install Dependencies Source: https://devx-op.github.io/effectify/react/packages/react-query Install the necessary packages for @effectify/react-query, TanStack Query, Effect, and React. ```bash npm install @effectify/react-query @tanstack/react-query effect react ``` -------------------------------- ### Sign Up Response Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON response after a successful user sign-up, including user details and session token. ```json { "user": { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": false, "createdAt": "2024-01-01T00:00:00.000Z" }, "session": { "id": "session-id", "token": "jwt-token", "expiresAt": "2024-01-08T00:00:00.000Z" } } ``` -------------------------------- ### Get User Profile Response Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON response containing the current user's profile details. ```json { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": true, "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z", } ``` -------------------------------- ### Sign Up Request Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON payload for registering a new user with email, password, and name. ```json { "email": "user@example.com", "password": "securepassword123", "name": "John Doe" } ``` -------------------------------- ### Create and Initialize Fastify Project Source: https://devx-op.github.io/effectify/backend/installation Set up a new Fastify project, install core dependencies, and development tools. ```bash mkdir my-fastify-backend && cd my-fastify-backend npm init -y npm install fastify @fastify/cors @fastify/helmet npm install -D @types/node typescript ts-node nodemon ``` -------------------------------- ### Install @effectify/solid-query Source: https://devx-op.github.io/effectify/solid/installation Install the core Effectify integration with TanStack Query for SolidJS. ```bash npm install @effectify/solid-query ``` -------------------------------- ### Install @effectify/react-query Source: https://devx-op.github.io/effectify/react/installation Install the core Effect integration with TanStack Query for React. ```bash npm install @effectify/react-query ``` -------------------------------- ### Next.js Project Installation Source: https://devx-op.github.io/effectify/react/installation Install Effectify packages and set up query client provider for a Next.js application. ```bash npx create-next-app@latest my-app --typescript cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` ```typescript "use client" import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { useState } from "react" export function Providers({ children }: { children: React.ReactNode }) { const [queryClient] = useState(() => new QueryClient()) return {children} } ``` ```typescript import { Providers } from "./providers" export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( {children} ) } ``` -------------------------------- ### Install Prisma and Prisma Client Source: https://devx-op.github.io/effectify/backend/installation Install Prisma for database management and @prisma/client for database access in your Node.js project. ```bash npm install prisma @prisma/client npx prisma init ``` -------------------------------- ### Sign In Response Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON response after a successful user sign-in, including user details and session token. ```json { "user": { /* user object */ }, "session": { /* session object */ } } ``` -------------------------------- ### Install better-sqlite3 Source: https://devx-op.github.io/effectify/backend/installation Install the better-sqlite3 package and its types for SQLite database integration. ```bash npm install better-sqlite3 @types/better-sqlite3 ``` -------------------------------- ### Create and Initialize Express.js Project Source: https://devx-op.github.io/effectify/backend/installation Set up a new Express.js project, install core dependencies, and development tools. ```bash mkdir my-backend && cd my-backend npm init -y npm install express cors helmet dotenv npm install -D @types/express @types/cors @types/node typescript ts-node nodemon ``` -------------------------------- ### Create React App Installation Source: https://devx-op.github.io/effectify/react/installation Install Effectify packages and configure TanStack Query for a Create React App project. ```bash npx create-react-app my-app --template typescript cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` ```typescript import { QueryClient, QueryClientProvider } from "@tanstack/react-query" const queryClient = new QueryClient() root.render( , ) ``` -------------------------------- ### Install @effectify/shared-types Source: https://devx-op.github.io/effectify/universal/packages/shared-types Install the shared types package using npm. ```bash npm install @effectify/shared-types ``` -------------------------------- ### Install Peer Dependencies for @effectify/node-better-auth Source: https://devx-op.github.io/effectify/backend/installation Install the necessary peer dependencies for @effectify/node-better-auth. ```bash npm install better-auth effect @effect/platform @effect/platform-node ``` -------------------------------- ### Install Core Query Package Source: https://devx-op.github.io/effectify/solid/getting-started Install the necessary packages for data fetching with TanStack Query and Effect. ```bash npm install @effectify/solid-query @tanstack/solid-query effect solid-js ``` -------------------------------- ### Install @effectify/chat-domain and Effect Source: https://devx-op.github.io/effectify/universal/packages/chat-domain Install the chat domain package and the Effect library using npm. ```bash npm install @effectify/chat-domain effect ``` -------------------------------- ### Install Node.js Backend Packages Source: https://devx-op.github.io/effectify Install Effectify Node.js packages for authentication with Better Auth and Effect. ```bash npm install @effectify/node-better-auth better-auth effect ``` -------------------------------- ### Environment Configuration Example Source: https://devx-op.github.io/effectify/backend/getting-started An example .env file for configuring environment variables such as port, database URL, and JWT secrets. ```env PORT=3000 NODE_ENV=development DATABASE_URL=postgresql://user:password@localhost:5432/myapp JWT_SECRET=your-super-secret-jwt-key BETTER_AUTH_SECRET=your-better-auth-secret BETTER_AUTH_URL=http://localhost:3000 ``` -------------------------------- ### Install Peer Dependencies for @effectify/react-query Source: https://devx-op.github.io/effectify/react/installation Install the necessary peer dependencies for @effectify/react-query. ```bash npm install @tanstack/react-query effect react ``` -------------------------------- ### Install SolidJS Packages Source: https://devx-op.github.io/effectify Install Effectify Solid Query, TanStack Query, and Effect for SolidJS applications. ```bash npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Install Peer Dependencies for @effectify/chat-react Source: https://devx-op.github.io/effectify/react/installation Install the peer dependencies needed for @effectify/chat-react. ```bash npm install @effectify/react-query @effectify/chat-domain react ``` -------------------------------- ### Sign In Request Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON payload for signing in a user with email and password. ```json { "email": "user@example.com", "password": "securepassword123" } ``` -------------------------------- ### Install Peer Dependencies for @effectify/react-ui Source: https://devx-op.github.io/effectify/react/installation Install the peer dependencies required for @effectify/react-ui. ```bash npm install react react-dom tailwindcss ``` -------------------------------- ### Install React Packages Source: https://devx-op.github.io/effectify Install Effectify React Query, TanStack Query, and Effect for React applications. ```bash npm install @effectify/react-query @tanstack/react-query effect ``` -------------------------------- ### Install PostgreSQL Driver for Node.js Source: https://devx-op.github.io/effectify/backend/installation Install the 'pg' package and its types for PostgreSQL interaction. ```bash npm install pg @types/pg ``` -------------------------------- ### Basic Fastify Setup with Effect Source: https://devx-op.github.io/effectify/backend/installation A basic Fastify server setup demonstrating an Effect-based health check route. ```typescript // src/index.ts import Fastify from "fastify" import { Effect } from "effect" const fastify = Fastify({ logger: true }) // Register plugins fastify.register(require("@fastify/cors")) fastify.register(require("@fastify/helmet")) // Effect-based route fastify.get("/health", async (request, reply) => { const healthCheck = Effect.succeed({ status: "ok", timestamp: new Date().toISOString(), }) const result = await Effect.runPromise(healthCheck) return result }) const start = async () => { try { await fastify.listen({ port: 3000 }) console.log("Server running on port 3000") } catch (err) { fastify.log.error(err) process.exit(1) } } start() ``` -------------------------------- ### Install Peer Dependencies for @effectify/node-auth-app Source: https://devx-op.github.io/effectify/backend/installation Install the required peer dependencies for the @effectify/node-auth-app package. ```bash npm install express cors helmet dotenv better-sqlite3 ``` -------------------------------- ### Project Structure Example Source: https://devx-op.github.io/effectify/backend/getting-started An example of a well-organized project structure for a backend application using Effectify. ```tree my-backend/ ├── src/ │ ├── config/ │ │ └── index.ts │ ├── services/ │ │ ├── auth.ts │ │ └── user.ts │ ├── repositories/ │ │ └── user.ts │ ├── routes/ │ │ └── auth.ts │ ├── middleware/ │ │ └── auth.ts │ ├── types/ │ │ └── index.ts │ └── index.ts ├── package.json ├── tsconfig.json └── .env ``` -------------------------------- ### Install Tailwind CSS Source: https://devx-op.github.io/effectify/react/installation Install Tailwind CSS and its peer dependencies for use with @effectify/react-ui. ```bash npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p ``` -------------------------------- ### Basic Chat Component Setup Source: https://devx-op.github.io/effectify/react/packages/chat-react Set up a simple chat room component using ChatProvider and ChatRoom. ```jsx import { ChatRoom } from "@effectify/chat-react/components/chat-room" import { ChatProvider } from "@effectify/chat-react/components/chat-provider" function App() { return ( ) } ``` -------------------------------- ### Create Vite + SolidJS Project and Install Effectify Source: https://devx-op.github.io/effectify/solid/installation Create a new SolidJS project using Vite and install Effectify packages. ```bash npm create solid@latest my-app cd my-app npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### SolidJS Resource Integration Example Source: https://devx-op.github.io/effectify/solid/reference/api Shows how to integrate SolidJS's createResource with Effect.runPromise for asynchronous data fetching that can be manually refetched or mutated. ```typescript // Using createResource with Effect const [user, { mutate, refetch }] = createResource( () => userId(), (id) => Effect.runPromise(fetchUser(id)), ) ``` -------------------------------- ### Install Winston for Logging Source: https://devx-op.github.io/effectify/backend/installation Installs the Winston library, a popular logging framework for Node.js, to manage application logs. ```bash npm install winston ``` -------------------------------- ### Sign Out Request Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example header for signing out a user by providing the session token. ```http Authorization: Bearer < session - token > ``` -------------------------------- ### Vite Project Installation Source: https://devx-op.github.io/effectify/react/installation Set up Effectify packages and TanStack Query configuration for a Vite project. ```bash npm create vite@latest my-app -- --template react-ts cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` ```typescript import { QueryClient, QueryClientProvider } from "@tanstack/react-query" const queryClient = new QueryClient() ReactDOM.createRoot(document.getElementById("root")!).render( , ) ``` -------------------------------- ### Install better-auth dependencies Source: https://devx-op.github.io/effectify/backend/installation Install the necessary packages for integrating better-auth with your Effectify Node.js project. ```bash npm install @effectify/node-better-auth better-auth ``` -------------------------------- ### PostgreSQL Database Adapter Setup Source: https://devx-op.github.io/effectify/backend/packages/node-better-auth Configures Better Auth to use PostgreSQL as its database. Ensure the DATABASE_URL environment variable is set. ```typescript import { betterAuth } from "better-auth" import { pg } from "better-auth/adapters/pg" export const auth = betterAuth({ database: pg({ connectionString: process.env.DATABASE_URL!, }), // ... other config }) ``` -------------------------------- ### Create NestJS Project and Install Effect Dependencies Source: https://devx-op.github.io/effectify/backend/installation Create a new NestJS project and install Effectify and Effect core packages. ```bash npm i -g @nestjs/cli nest new my-nest-backend cd my-nest-backend npm install @effectify/node-better-auth effect ``` -------------------------------- ### Card Component Example Source: https://devx-op.github.io/effectify/react/packages/react-ui Demonstrates how to use the Card component for displaying user information. Includes CardHeader, CardTitle, CardDescription, CardContent, and CardFooter. ```jsx import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@effectify/react-ui/components/card" import { Button } from "@effectify/react-ui/components/button" function UserCard({ user }) { return ( {user.name} {user.email}

Member since {user.joinDate}

) } ``` -------------------------------- ### Example Usage of createEffectQuery Source: https://devx-op.github.io/effectify/react/reference/api Demonstrates how to use `createEffectQuery` with `useQuery` to fetch user data asynchronously. ```typescript const fetchUser = (id: number) => Effect.succeed({ id, name: "John" }) const queryFn = createEffectQuery(fetchUser(1)) const { data } = useQuery({ queryKey: ["user", 1], queryFn, }) ``` -------------------------------- ### Basic Auth Server Creation Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Create and start a basic authentication server using @effectify/node-auth-app with minimal configuration. ```typescript import { createAuthApp } from "@effectify/node-auth-app" import { Effect } from "effect" // Create and start the auth server const startAuthServer = Effect.gen(function*() { const app = yield* createAuthApp({ port: 3001, corsOrigin: "http://localhost:3000", database: { provider: "sqlite", url: "file:./auth.db", }, }) console.log("Auth server running on port 3001") return app }) Effect.runPromise(startAuthServer) ``` -------------------------------- ### SQLite Database Adapter Setup Source: https://devx-op.github.io/effectify/backend/packages/node-better-auth Configures Better Auth to use SQLite as its database. Defaults to 'auth.db' if DATABASE_URL is not provided. ```typescript import { betterAuth } from "better-auth" import { sqlite } from "better-auth/adapters/sqlite" export const auth = betterAuth({ database: sqlite({ url: process.env.DATABASE_URL || "auth.db", }), // ... other config }) ``` -------------------------------- ### Add SolidJS to Astro Project and Install Effectify Source: https://devx-op.github.io/effectify/solid/installation Integrate SolidJS into an Astro project and install Effectify packages. ```bash npx astro add solid npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Health Check Endpoint and Response Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Illustrates the health check endpoint for monitoring the authentication application. It shows the GET request path and an example of the JSON response, including status, timestamp, uptime, and database connection status. ```http // Health check endpoint GET /health // Response { "status": "ok", "timestamp": "2024-01-01T00:00:00.000Z", "uptime": 12345, "database": "connected" } // Metrics endpoint (if enabled) GET /metrics ``` -------------------------------- ### Sign Out Response Example Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Example JSON response indicating a successful sign-out. ```json { "success": true, } ``` -------------------------------- ### Basic Data Fetching with createQuery Source: https://devx-op.github.io/effectify/solid/packages/solid-query Demonstrates simple data fetching using createQuery from @tanstack/solid-query and Effect for asynchronous operations. Ensure Effect and SolidJS are imported. ```typescript import { createQuery } from "@tanstack/solid-query" import { Effect } from "effect" import { Show } from "solid-js" // Define your Effect const fetchUser = (id: number) => Effect.tryPromise({ try: () => fetch(`/api/users/${id}`).then((res) => res.json()), catch: (error) => new Error(`Failed to fetch user: ${error}`), }) // Use in component function UserProfile(props: { userId: number }) { const userQuery = createQuery(() => ({ queryKey: ["user", props.userId], queryFn: () => Effect.runPromise(fetchUser(props.userId)), })) return ( Loading...}> {(user) => (

{user().name}

Error: {userQuery.error?.message}

)}
) } ``` -------------------------------- ### Basic Express Server Setup with Effect Source: https://devx-op.github.io/effectify/backend/getting-started Sets up a basic Express server with middleware and routes, integrating Effect for asynchronous operations and server startup. ```typescript import express from "express" import cors from "cors" import helmet from "helmet" import { Effect, Layer } from "effect" import { config } from "./config" import { authRoutes } from "./routes/auth" const app = express() // Middleware app.use(helmet()) app.use(cors()) app.use(express.json()) // Routes app.use("/auth", authRoutes) // Health check app.get("/health", (req, res) => { res.json({ status: "ok", timestamp: new Date().toISOString() }) }) // Start server const startServer = Effect.gen(function*() { const { port } = yield* config return yield* Effect.async((resume) => { const server = app.listen(port, () => { console.log(`Server running on port ${port}`) resume(Effect.succeed(void 0)) }) server.on("error", (error) => { resume(Effect.fail(error)) }) }) }) // Run the server Effect.runPromise(startServer).catch(console.error) ``` -------------------------------- ### cn Utility Usage Example Source: https://devx-op.github.io/effectify/solid/reference/api Example demonstrating the usage of the cn class name utility. ```typescript import { cn } from "@effectify/solid-ui/lib/utils" function MyComponent(props: { class?: string }) { return
} ``` -------------------------------- ### Sign Up Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Registers a new user with their email, password, and name. Returns the newly created user object and an active session. ```APIDOC ## POST /api/auth/sign-up ### Description Register a new user with email and password. ### Method POST ### Endpoint /api/auth/sign-up ### Request Body - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. - **name** (string) - Required - The user's full name. ### Request Example ```json { "email": "user@example.com", "password": "securepassword123", "name": "John Doe" } ``` ### Response #### Success Response (200) - **user** (object) - The newly created user object. - **id** (string) - The user's unique identifier. - **email** (string) - The user's email address. - **name** (string) - The user's full name. - **emailVerified** (boolean) - Indicates if the user's email has been verified. - **createdAt** (string) - The timestamp when the user was created. - **session** (object) - The user's active session object. - **id** (string) - The session's unique identifier. - **token** (string) - The authentication token (JWT). - **expiresAt** (string) - The timestamp when the session expires. ### Response Example ```json { "user": { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": false, "createdAt": "2024-01-01T00:00:00.000Z" }, "session": { "id": "session-id", "token": "jwt-token", "expiresAt": "2024-01-08T00:00:00.000Z" } } ``` ``` -------------------------------- ### Create .env file for environment variables Source: https://devx-op.github.io/effectify/backend/installation Example of a .env file for configuring server port, database connection strings (PostgreSQL and SQLite), authentication secrets, and CORS origins. ```dotenv # Server PORT=3000 NODE_ENV=development # Database DATABASE_URL=postgresql://user:password@localhost:5432/myapp # or for SQLite # DATABASE_URL=file:./app.db # Authentication BETTER_AUTH_SECRET=your-super-secret-key-here BETTER_AUTH_URL=http://localhost:3000 JWT_SECRET=your-jwt-secret-here # CORS CORS_ORIGIN=http://localhost:3000 ``` -------------------------------- ### Create and Update SolidJS Store Source: https://devx-op.github.io/effectify/solid/reference/api Demonstrates how to create a store using `createStore` and update its state, specifically integrating with Effect results to set messages. ```typescript import { createStore } from "solid-js/store" const [chatState, setChatState] = createStore({ messages: [], users: [], currentRoom: null, }) // Update store with Effect results Effect.runPromise( fetchMessages(roomId).pipe( Effect.tap((messages) => Effect.sync(() => setChatState("messages", messages))), ), ) ``` -------------------------------- ### Set Up Mock Implementations for Testing Source: https://devx-op.github.io/effectify/universal Create mock implementations of domain interfaces using 'Layer.succeed' for testing. This allows isolating domain logic and testing it without relying on actual infrastructure. ```typescript import { Effect, Layer, TestContext } from 'effect' // Mock implementations for testing const MockMessageRepository = Layer.succeed(MessageRepository, { save: (message) => Effect.succeed(message), findById: (id) => Effect.succeed(null), findByRoom: (roomId) => Effect.succeed([]) }) // Test domain logic const testSendMessage = Effect.gen(function* () { const message = yield* ChatDomain.sendMessage({ content: 'Hello, world!', userId: 'user-1' as UserId, roomId: 'room-1' as RoomId }) expect(message.content).toBe('Hello, world!') expect(message.userId).toBe('user-1') }).pipe( Effect.provide(MockMessageRepository) ) // Run test await Effect.runPromise(testSendMessage) ``` -------------------------------- ### Domain Service Example Source: https://devx-op.github.io/effectify/universal/concepts Illustrates a domain service for managing chat-related business logic, including user engagement calculation and user migration between rooms. Requires repository and aggregate dependencies. ```typescript const ChatDomainService = { // Complex business logic calculateUserEngagement: (userId: UserId, timeframe: TimeFrame) => Effect.gen(function*() { const messages = yield* MessageRepository.findByUserAndTimeframe(userId, timeframe) const reactions = yield* ReactionRepository.findByUserAndTimeframe(userId, timeframe) const sessions = yield* SessionRepository.findByUserAndTimeframe(userId, timeframe) const messageScore = messages.length * 1.0 const reactionScore = reactions.length * 0.5 const sessionScore = sessions.reduce((acc, s) => acc + s.duration, 0) / 1000 / 60 // minutes return { userId, timeframe, messageScore, reactionScore, sessionScore, totalScore: messageScore + reactionScore + sessionScore, } }), // Cross-aggregate operations migrateUserToNewRoom: (userId: UserId, fromRoomId: RoomId, toRoomId: RoomId) => Effect.gen(function*() { const fromRoom = yield* ChatRoomRepository.findById(fromRoomId) const toRoom = yield* ChatRoomRepository.findById(toRoomId) if (!fromRoom || !toRoom) { yield* Effect.fail( new ResourceNotFoundError({ resource: "ChatRoom", id: !fromRoom ? fromRoomId : toRoomId, }), ) } const updatedFromRoom = yield* ChatRoomAggregate.removeParticipant(fromRoom, userId) const updatedToRoom = yield* ChatRoomAggregate.addParticipant(toRoom, userId) yield* ChatRoomRepository.save(updatedFromRoom) yield* ChatRoomRepository.save(updatedToRoom) yield* EventBus.publish(new UserMigratedEvent(userId, fromRoomId, toRoomId)) }), } ``` -------------------------------- ### Install Additional Common Dependencies Source: https://devx-op.github.io/effectify/backend/getting-started Install common dependencies for backend development, including Express, CORS, Helmet, dotenv, and TypeScript tooling. ```bash npm install express cors helmet dotenv npm install -D @types/express @types/cors typescript ts-node nodemon ``` -------------------------------- ### GET /api/auth/google/callback Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Handle the callback from Google after the OAuth flow is completed. ```APIDOC ## GET /api/auth/google/callback ### Description Handle the callback from Google after the OAuth flow is completed. ### Method GET ### Endpoint /api/auth/google/callback ``` -------------------------------- ### GET /api/auth/google Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Initiate the Google OAuth flow for social authentication. ```APIDOC ## GET /api/auth/google ### Description Initiate the Google OAuth flow for social authentication. ### Method GET ### Endpoint /api/auth/google ``` -------------------------------- ### GET /api/auth/github/callback Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Handle the callback from GitHub after the OAuth flow is completed. ```APIDOC ## GET /api/auth/github/callback ### Description Handle the callback from GitHub after the OAuth flow is completed. ### Method GET ### Endpoint /api/auth/github/callback ``` -------------------------------- ### GET /api/auth/github Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Initiate the GitHub OAuth flow for social authentication. ```APIDOC ## GET /api/auth/github ### Description Initiate the GitHub OAuth flow for social authentication. ### Method GET ### Endpoint /api/auth/github ``` -------------------------------- ### Create and Send Message Example Source: https://devx-op.github.io/effectify/universal/packages/chat-domain Demonstrates how to create and send a text message within a chat room, including error handling for missing resources and authorization checks. ```typescript import { ChatRoomDomain, MessageDomain } from "@effectify/chat-domain" const sendMessage = (content: string, roomId: RoomId, userId: UserId) => Effect.gen(function*() { // Get the room const room = yield* ChatRoomRepository.findById(roomId) if (!room) { yield* Effect.fail( new ResourceNotFoundError({ resource: "ChatRoom", id: roomId, }), ) } // Get the user const user = yield* UserRepository.findById(userId) if (!user) { yield* Effect.fail( new ResourceNotFoundError({ resource: "User", id: userId, }), ) } // Check if user can send message yield* UserDomain.canSendMessage(user, room) // Create the message const message = yield* MessageDomain.create({ content, type: "text", userId, roomId, }) // Save the message const savedMessage = yield* MessageRepository.save(message) // Publish event yield* EventBus.publish(new MessageSentEvent(savedMessage.id, savedMessage)) return savedMessage }) ``` -------------------------------- ### Get User Profile Source: https://devx-op.github.io/effectify/backend/packages/node-auth-app Fetches the profile information of the currently authenticated user. ```APIDOC ## GET /api/auth/user ### Description Get current user profile. ### Method GET ### Endpoint /api/auth/user ### Headers - **Authorization** (string) - Required - Bearer token of the session. ### Response #### Success Response (200) - **id** (string) - The user's unique identifier. - **email** (string) - The user's email address. - **name** (string) - The user's full name. - **emailVerified** (boolean) - Indicates if the user's email has been verified. - **createdAt** (string) - The timestamp when the user was created. - **updatedAt** (string) - The timestamp when the user was last updated. ### Response Example ```json { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": true, "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z" } ``` ```