All Projects → Robinfr → morest

Robinfr / morest

Licence: MIT license
Allows developers to quickly create RESTful APIs using MongoDB and Express.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to morest

Vue Node Pastime
😄 基于vue全家桶、nodejs和mongodb的前后端整合项目
Stars: ✭ 200 (+1328.57%)
Mutual labels:  mongoose
Graphql Demo
🎉Koa + GraphQL + Apollo-Server demo
Stars: ✭ 215 (+1435.71%)
Mutual labels:  mongoose
Typescript Express Starter
🚀 TypeScript Express Starter
Stars: ✭ 238 (+1600%)
Mutual labels:  mongoose
Angular2 Express Mongoose Gulp Node Typescript
AngularJS 2 (Updated to 4.2.0) Mean Stack application which uses Angular2, Gulp, Express, Node, MongoDB (Mongoose) with Repository Pattern Business Layer
Stars: ✭ 201 (+1335.71%)
Mutual labels:  mongoose
Nobibi
一款基于Next.js+mongo的轻量级开源社区(open community by Next.js & mongo)
Stars: ✭ 209 (+1392.86%)
Mutual labels:  mongoose
Nestjs Typegoose
Typegoose with NestJS
Stars: ✭ 215 (+1435.71%)
Mutual labels:  mongoose
Tm Crm erp
DEPRECATED
Stars: ✭ 196 (+1300%)
Mutual labels:  mongoose
Nest Mean
NestJS Tutorial Repository
Stars: ✭ 250 (+1685.71%)
Mutual labels:  mongoose
Express Es6 Rest Api
🔋 Starter project for an ES6 RESTful Express API.
Stars: ✭ 2,401 (+17050%)
Mutual labels:  mongoose
Koa2 Mongodb Server
利用koa2+mongodb搭建一套简易的nodejs后台服务,用于为客户端提供数据请求的数据api接口
Stars: ✭ 235 (+1578.57%)
Mutual labels:  mongoose
Saas
Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
Stars: ✭ 2,720 (+19328.57%)
Mutual labels:  mongoose
Mern Ecommerce
🎈 Fullstack MERN Ecommerce Application
Stars: ✭ 205 (+1364.29%)
Mutual labels:  mongoose
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (+1457.14%)
Mutual labels:  mongoose
Vue Mall Mobile
🔥 vue + koa + mongodb 搭建 mobile web 商城 (End。。。)
Stars: ✭ 201 (+1335.71%)
Mutual labels:  mongoose
Generator Api
🚀 Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express
Stars: ✭ 247 (+1664.29%)
Mutual labels:  mongoose
Evmongoose
DEPRECATED. Evmongoose is an asynchronous, event(libev) based multi-protocol embedded networking library with functions including TCP, HTTP, WebSocket, MQTT and much more. It's based on mongoose and libev implementation and it's support Lua API.
Stars: ✭ 199 (+1321.43%)
Mutual labels:  mongoose
Mern Passport
A boilerplate example of using passport.js for authenticating a MERN application
Stars: ✭ 214 (+1428.57%)
Mutual labels:  mongoose
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (+19978.57%)
Mutual labels:  mongoose
Builderbook
Open source web application to learn JS stack: React, Material-UI, Next.js, Node.js, Express.js, Mongoose, MongoDB database.
Stars: ✭ 3,015 (+21435.71%)
Mutual labels:  mongoose
Sinn Server
an node server for sinn,that based on of nodejs,koa2,mongoose,docker,nginx,es6/7,Resful API,阿里云 http://servertest.boyagirl.com/
Stars: ✭ 228 (+1528.57%)
Mutual labels:  mongoose

Morest

Allows developers to quickly create RESTful APIs using a mix of MongoDB, Express and NodeJS.

Using Morest

Morest generator

The quickest way to get started with Morest is by using the Morest generator.

Manually

Install using npm: npm install morest --save

The basic idea behind Morest is to write as little boilerplate code as possible. To get started all you have to do is define the MongoDB schema using Mongoose and add the routes to an Express Router.

app/controllers/bear.js:

var mongoose = require('mongoose'), 
    Schema = mongoose.Schema,
    morest = require('morest'),
    Controller = morest.Controller;

var BearSchema = new Schema({
    name: {type: String, required: true},
    type: String
});

mongoose.model('Bear', BearSchema);

var BearController = new Controller({
    model: 'Bear',
    availableOperations: [
        'GET_ALL',
        'GET'
    ]
});

module.exports = BearController;

Then set up a server to use the controller.

server.js:

var express = require('express'),
    app = express(),
    router = express.Router(),
    mongoose = require('mongoose'),
    bodyParser = require('body-parser'),
    morest = require('morest').Morest;

mongoose.connect('mongodb://127.0.0.1:27017/bears');

var BearController = require('./app/controllers/bear');

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

var port = 8000;

app.use('/api', morest(router, mongoose, {controllers: [BearController]}));
app.listen(port);

Defining a controller

Morest comes with its own controllers that allow Morest to easily generate routes.

Before defining a controller, a Mongoose schema is required.

The following options can be passed into the controller:

model: the name of the Mongoose model

availableOperations: array of operations that can be performed with this controller, e.g.: GET_ALL, GET, POST, UPDATE, DELETE. By default, all operations are enabled.

Generating the routes

Generating CRUD routes is simple.

First create an Express router by doing: var router = express.Router().

Then generate the routes by adding them to your app: app.use('/api', morest(router, mongoose, {controllers: [ControllerObject1, ControllerObject2]})).

The routes are generated based on the Mongoose collection names, e.g. bear is turned into /bears, and cave is turned into /caves.

Filtering routes

There is a basic implementation of filtering available by default in each collection. This allows someone to filter items based on the URL.

For example, searching for just grizzly bears could be done by navigating to the endpoint /bears/?type=grizzly bear.

You can also limit results by using ?limit=10 or skip results by using ?skip=10.

If you want to perform more advanced filtering you can also use Javascript filtering by using $where in the URL, e.g.: /bears/?$where=this.type.indexOf("Grizzly")>-1.

Customizing controllers

The base controller has one function for each operation. In case more advanced features are required for a certain controller they can easily be overwritten.

For example:

var BearController = new Controller({
    model: 'Bear'
});

BearController.GET = function(req, res){
    res.send('We dont have any bears yet!');
};

Contribute

If you are willing to contribute, feel free to open an issue or create a pull request.

Running tests

The tests can be run with npm test. This will start the mocha tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].