الكامل الكامل ، مبسط ، مع كيانات SSOT TypeScript
يستخدم Remult كيانات TypeScript كمصدر واحد للحقيقة: ✅ Crud + API في الوقت الفعلي ، عميل واجهة برمجة التطبيقات الآمنة من نوع الواجهة الأمامية ، و ✅ Backend ORM.
تدعم Remult جميع قواعد البيانات الرئيسية ، بما في ذلك: postgresql ، mysql ، sqlite ، mongoDB ، MSSQL و Oracle.
REMULT هي الواجهة الأمامية وإطار الواجهة الخلفية ، وتأتي مع محولات لـ Express و Fastify و Next.js و Nuxt و Sveltekit و SolidStart و Nest و Koa و Hapi و Hono.
تريد تجربة الإكراه مباشرة؟ جرب البرنامج التعليمي التفاعلي عبر الإنترنت.
تعزز Remult بناء جملة لاستعلام ثابت لكل من الرمز الأمامي ورمز الخلفية :
// Frontend - GET: /api/products?_limit=10&unitPrice.gt=5,_sort=name
// Backend - 'select name, unitPrice from products where unitPrice > 5 order by name limit 10'
await repo ( Product ) . find ( {
limit : 10 ,
orderBy : {
name : 'asc' ,
} ,
where : {
unitPrice : { $gt : 5 } ,
} ,
} )
// Frontend - PUT: '/api/products/product7' (body: { "unitPrice" : 7 })
// Backend - 'update products set unitPrice = 7 where id = product7'
await repo ( Product ) . update ( 'product7' , { unitPrice : 7 } ) // shared/product.ts
import { Entity , Fields } from 'remult'
@ Entity ( 'products' , {
allowApiCrud : true ,
} )
export class Product {
@ Fields . cuid ( )
id = ''
@ Fields . string ( )
name = ''
@ Fields . number ( )
unitPrice = 0
}لا تحب الديكورات؟ لدينا دعم كامل للعمل بدون ديكور
مثال:
// backend/index.ts
import express from 'express'
import { remultExpress } from 'remult/remult-express' // adapters for: Fastify,Next.js, Nuxt, SvelteKit, SolidStart, Nest, more...
import { createPostgresDataProvider } from 'remult/postgres' // supported: PostgreSQL, MySQL, SQLite, MongoDB, MSSQL and Oracle
import { Product } from '../shared/product'
const app = express ( )
app . use (
remultExpress ( {
entities : [ Product ] ,
dataProvider : createPostgresDataProvider ( {
connectionString : 'postgres://user:password@host:5432/database"' ,
} ) ,
} ) ,
)
app . listen ( )يضيف Remult معالجات الطريق لواجهة برمجة تطبيقات REST بشكل كامل ونقاط النهاية في الوقت الفعلي ، اختياريًا بما في ذلك مواصفات API مفتوحة ونقطة نهاية GraphQL
const [ products , setProducts ] = useState < Product [ ] > ( [ ] )
useEffect ( ( ) => {
repo ( Product )
. find ( {
limit : 10 ,
orderBy : {
name : 'asc' ,
} ,
where : {
unitPrice : { $gt : 5 } ,
} ,
} )
. then ( setProducts )
} , [ ] ) useEffect ( ( ) => {
return repo ( Product )
. liveQuery ( {
limit : 10 ,
orderBy : {
name : 'asc' ,
} ,
where : {
unitPrice : { $gt : 5 } ,
} ,
} )
. subscribe ( ( info ) => {
setProducts ( info . applyChanges )
} )
} , [ ] ) import { Entity , Fields , Validators } from 'remult'
@ Entity ( 'products' , {
allowApiCrud : true ,
} )
export class Product {
@ Fields . cuid ( )
id = ''
@ Fields . string ( {
validate : Validators . required ,
} )
name = ''
@ Fields . number < Product > ( {
validate : ( product ) => product . unitPrice > 0 || 'must be greater than 0' ,
} )
unitPrice = 0
} try {
await repo ( Product ) . insert ( { name : '' , unitPrice : - 1 } )
} catch ( e : any ) {
console . error ( e )
/* Detailed error object ->
{
"modelState": {
"name": "Should not be empty",
"unitPrice": "must be greater than 0"
},
"message": "Name: Should not be empty"
}
*/
} // POST '/api/products' BODY: { "name":"", "unitPrice":-1 }
// Response: status 400, body:
{
"modelState" : {
"name" : "Should not be empty" ,
"unitPrice" : "must be greater than 0"
} ,
"message" : "Name: Should not be empty"
}@ Entity < Article > ( 'Articles' , {
allowApiRead : true ,
allowApiInsert : Allow . authenticated ,
allowApiUpdate : ( article ) => article . author == remult . user . id ,
apiPrefilter : ( ) => {
if ( remult . isAllowed ( 'admin' ) ) return { }
return {
author : remult . user . id ,
}
} ,
} )
export class Article {
@ Fields . string ( { allowApiUpdate : false } )
slug = ''
@ Fields . string ( { allowApiUpdate : false } )
authorId = remult . user ! . id
@ Fields . string ( )
content = ''
} await repo ( Categories ) . find ( {
orderBy : {
name : 'asc ' ,
} ,
include : {
products : {
where : {
unitPrice : { $gt : 5 } ,
} ,
} ,
} ,
} )
// Entity Definitions
export class Product {
//...
@ Relations . toOne ( Category )
category ?: Category
}
export class Category {
//...
@ Relations . toMany < Category , Product > ( ( ) => Product , `category` )
products ?: Product [ ]
}
على الرغم من أن CRUD البسيط يجب ألا يتطلب أي ترميز خلفي ، إلا أن استخدام الإحباط يعني وجود القدرة على التعامل مع أي سيناريو معقد عن طريق التحكم في الواجهة الخلفية بطرق عديدة:
حزمة الإحباط واحدة ونفس الشيء لكل من حزمة الواجهة الأمامية والواجهة الخلفية. قم بتثبيته مرة واحدة لمشروع Monolith أو per-repo في monorepo.
npm i remultأفضل طريقة لتعلم الإحباط هي باتباع برنامج تعليمي لتطبيق ويب بسيط مع Node.js Express الخلفية.

شاهد رمز العرض التوضيحي على YouTube هنا (14 دقيقة)
تغطي الوثائق الميزات الرئيسية للإقامة. ومع ذلك ، فهي لا تزال تعمل في مجال التقدم.
مثال FullStack TODOMVC مع React و Express. (رمز المصدر | codesandbox)
CRM Demo مع قاعدة بيانات REACT + MUI الواجهة الأمامية و postgres.
Remult جاهزة للإنتاج ، وفي الواقع ، تستخدم في تطبيقات الإنتاج منذ عام 2018. ومع ذلك ، فإننا نحتفظ بالإصدار الرئيسي في الصفر حتى نتمكن من استخدام ملاحظات المجتمع لوضع اللمسات الأخيرة على واجهة برمجة تطبيقات V1.
تطوير الويب الكامل (لا يزال) معقد للغاية. يجب أن يكون Crud البسيط ، وهو متطلب شائع لأي تطبيق تجاري ، بسيطًا في إنشاء وصيانة وتمديد عندما تنشأ الحاجة.
تجريدات الإحباط بعيدا عن الكود المتكرر ، والمرهيل ، والمعرضة للخطأ ، والرمز المصمم بشكل سيئ من ناحية ، وتمكين المرونة الكاملة والتحكم في الآخر. تساعد Remult في إنشاء تطبيقات Fullstack باستخدام رمز TypeScript فقط الذي يمكنك متابعته بسهولة وإعادة تشكيله بأمان ، وتناسب بشكل جيد في أي مشروع موجود أو جديد من خلال كونه أضيق الحدود وغير المألوف تمامًا فيما يتعلق باختيار المطور للأطر والأدوات الأخرى.
تميل الأطر الأخرى إلى الوقوع في الكثير من التجريد (عدم الكود ، أو الرموز المنخفضة ، أو BAAs) أو التجريد الجزئي (أطر MVC ، أو GraphQL ، و ORMS ، ومولدات واجهة برمجة التطبيقات ، ومولدات الرموز) ، وتميل إلى الرأي فيما يتعلق بسلسلة أدوات التطوير ، بيئة النشر ، التكوين/الاتفاقيات أو DSL. المحاولات المحاولات لتحقيق توازن أفضل.
المساهمات موضع ترحيب. انظر المساهمة.
الإحباط مرخص معهد ماساتشوستس للتكنولوجيا.