New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

remult

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remult

remult core lib


Version published
Maintainers
2
Created

Remult

GitHub license npm version

Remult is an unopinionated CRUD framework for fullstack TypeScript development.

Define Entity classes

import { Entity, EntityBase, Field } from 'remult';

@Entity('Products', {
    allowApiCrud: true
})
export class Product extends EntityBase {
  @Field()
  name: string = '';

  @Field()
  unitPrice: number = 0;
}

Find and manipulate data in front end code...

static increasePriceOfTofu(priceIncrease: number) {
  const product = await remult.repo(Product).findFirst({ name:'Tofu' });

  product.unitPrice += priceIncrease;
  await product.save();
}

...exactly the same way as in back end code

@BackendMethod({ allowed: Allow.authenticated })
static increasePriceOfTofu(priceIncrease: number, remult?: Remult) {
  const product = await remult.repo(Product).findFirst({ name:'Tofu' });

  product.unitPrice += priceIncrease;
  await product.save();
}

Secure the API with Fine-grained Authorization

@Entity<Article>('Articles', {
    allowApiRead: true,
    allowApiInsert: remult => remult.authenticated(),
    allowApiUpdate: (remult, article) => article.author.id == remult.user.id
})
export class Article extends EntityBase {
    @Field({ allowApiUpdate: false })
    slug: string;
    
    @Field({ allowApiUpdate: false })
    author: Profile;

    @Field()
    content: string;
}

Remult handles the REST:

  • Secured back-end API endpoints for Entities and back-end methods
  • CRUD API requests (front end) / database commands (back end)
  • Object-relational mapping
  • Validations
  • Caching
  • Authorization

Installation

npm i remult

API Setup using Express

import * as express from 'express';
import { remultExpress } from 'remult/remult-express';
import 'entities';

let app = express();
app.use(remultExpress());
app.listen(3002, () => console.log("Server started"));

FAQs

Package last updated on 06 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts