memserver
in-memory database/ORM and http mock server you can run in-browser and node environments. Built for large frontend teams, fast tests and rapid prototyping
Last updated 3 years ago by izelnakri .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install memserver 
SYNC missed versions from official npm registry.
Build Status

What is MemServer?

MemServer is an in-memory database/ORM and http mock server you can run in-browser and node environments. Extremely useful library for fast frontend tests, rapid prototyping, single-file SPA demo deployments.

Installation

In order to use memserver CLI you need to have typescript set up in your project folder. memserver binary will only work on typescript project directories since it uses ts-node under the hood to for memserver console and memserver g fixtures $modelName generation commands.

npm install -g memserver

memserver

You can use the CLI to create relevant boilerplate files and initial setup

Memserver Model API

// MEMSERVER MODEL API
import Model from 'memserver/model';
// OR:
const Model = require('memserver/model');
// THEN:

class User extends Model {
 // NOTE: you can add here your static methods
 static serializer(modelOrArray) {
   return modelOrArray;
 }
};
// allows User.serializer(user);

User.findAll(); // [];

User.insert({ firstName: 'Izel', lastName: 'Nakri' }); // { id: 1, firstName: 'Izel', lastName: 'Nakri' }

let usersAfterInsert = User.findAll(); // [{ id: 1, firstName: 'Izel', lastName: 'Nakri' }]

let insertedUser = usersAfterInsert[0];

insertedUser.firstName = 'Isaac';

User.findAll(); // [{ id: 1, firstName: 'Izel', lastName: 'Nakri' }]

User.update(insertedUser); // { id: 1, firstName: 'Isaac', lastName: 'Nakri' }

User.findAll(); // [{ id: 1, firstName: 'Isaac', lastName: 'Nakri' }]

let updatedUser = User.find(1); // [{ id: 1, firstName: 'Isaac', lastName: 'Nakri' }]

let anotherUser = User.insert({ firstName: 'Brendan' }); // { id: 2, firstName: 'Brendan', lastName: null }

updatedUser.firstName = 'Izel';

User.findAll(); // [{ id: 1, firstName: 'Isaac', lastName: 'Nakri' }, { id: 2, firstName: 'Brendan', lastName: null }]

User.delete(updatedUser); // { id: 1, firstName: 'Isaac', lastName: 'Nakri' }

User.findAll(); // [{ id: 2, firstName: 'Brendan', lastName: null }]

NOTE: API also works for UUIDs instead of id primary keys

Memserver Server API

Its stable but needs documentation, check tests for now

Current Tags

  • 2.0.12                                ...           latest (2 months ago)

99 Versions

  • 2.0.12                                ...           2 months ago
  • 2.0.11                                ...           3 months ago
  • 2.0.10                                ...           3 months ago
  • 2.0.9                                ...           3 months ago
  • 2.0.8                                ...           3 months ago
  • 2.0.7                                ...           4 months ago
  • 2.0.6                                ...           4 months ago
  • 2.0.5                                ...           4 months ago
  • 2.0.4                                ...           4 months ago
  • 2.0.3                                ...           4 months ago
  • 2.0.2                                ...           4 months ago
  • 2.0.1                                ...           4 months ago
  • 2.0.0                                ...           4 months ago
  • 2.0.0-alpha12                                ...           4 months ago
  • 2.0.0-alpha11                                ...           4 months ago
  • 2.0.0-alpha10                                ...           4 months ago
  • 2.0.0-alpha9                                ...           4 months ago
  • 2.0.0-alpha8                                ...           4 months ago
  • 2.0.0-alpha7                                ...           4 months ago
  • 2.0.0-alpha6                                ...           4 months ago
  • 2.0.0-alpha5                                ...           4 months ago
  • 2.0.0-alpha4                                ...           4 months ago
  • 2.0.0-alpha3                                ...           4 months ago
  • 2.0.0-alpha2                                ...           4 months ago
  • 2.0.0-alpha                                ...           4 months ago
  • 1.2.10                                ...           8 months ago
  • 1.2.9                                ...           10 months ago
  • 1.2.7                                ...           a year ago
  • 1.2.6                                ...           a year ago
  • 1.2.5                                ...           a year ago
  • 1.2.4                                ...           a year ago
  • 1.2.3                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.8                                ...           2 years ago
  • 1.1.7                                ...           2 years ago
  • 1.1.6                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.9.9                                ...           3 years ago
  • 0.9.8                                ...           3 years ago
  • 0.9.7                                ...           3 years ago
  • 0.9.6                                ...           3 years ago
  • 0.9.5                                ...           3 years ago
  • 0.9.4                                ...           3 years ago
  • 0.9.3                                ...           3 years ago
  • 0.9.2                                ...           3 years ago
  • 0.9.1                                ...           3 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.9                                ...           3 years ago
  • 0.8.8                                ...           3 years ago
  • 0.8.7                                ...           3 years ago
  • 0.8.6                                ...           3 years ago
  • 0.8.5                                ...           3 years ago
  • 0.8.4                                ...           3 years ago
  • 0.8.3                                ...           3 years ago
  • 0.8.2                                ...           3 years ago
  • 0.8.1                                ...           3 years ago
  • 0.8.0                                ...           3 years ago
  • 0.7.9                                ...           3 years ago
  • 0.7.8                                ...           3 years ago
  • 0.7.7                                ...           3 years ago
  • 0.7.6                                ...           3 years ago
  • 0.7.5                                ...           3 years ago
  • 0.7.4                                ...           3 years ago
  • 0.7.3                                ...           3 years ago
  • 0.7.2                                ...           3 years ago
  • 0.7.1                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.9                                ...           3 years ago
  • 0.6.8                                ...           3 years ago
  • 0.6.7                                ...           3 years ago
  • 0.6.6                                ...           3 years ago
  • 0.6.5                                ...           3 years ago
  • 0.6.4                                ...           3 years ago
  • 0.6.3                                ...           3 years ago
  • 0.6.2                                ...           3 years ago
  • 0.6.1                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.5.8                                ...           3 years ago
  • 0.5.7                                ...           3 years ago
  • 0.5.6                                ...           3 years ago
  • 0.5.5                                ...           3 years ago
  • 0.5.4                                ...           3 years ago
  • 0.5.3                                ...           3 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 2
Last Month 99
Dependencies (10)
Dev Dependencies (16)

Copyright 2014 - 2016 © taobao.org |