npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

monoexpress

v1.0.4

Published

NodeJS Module to create an API with CRUD methods, based on Express and Mongoose

Downloads

8

Readme

Monoexpress API

MOngoNOdeEXPRESS

NodeJS Module to create an API with CRUD methods, based on Express and Mongoose. This module allows you to create an API to whatever you want to do in a few minutes, and it is only needed to have a MongoDB database and NodeJS installed.

Monoexpress builds the Mongoose model and creates the endpoints to fetch, add, update, or delete documents inside a MongoDB Collection without any effort. Intended for small DIY projects or to test anything that needs an API.

Written in Javascript, following the ES5 Airbnb JavaScript Style Guide.

This is an alpha version, so feel free to contribute if you want to make it better. Pull requests are welcome!

Getting started

Check the Getting Started wiki page to see a brief tutorial about the module

How it works

var API = require('monoexpress');

API.setMongoDBURL('YOUR_MONGODB_URL');

// Mongoose Schema Model
// http://mongoosejs.com/docs/guide.html
var usersSchema = {
  name: String,
  address: String
};

// Register Endpoints
API.registerEndpoints('users', usersSchema);

API.listen();

You can check more examples out here

After that, you can make requests to these API methods:

GET /<name>
Retrieves all the documents within the collection

POST /<name>
Creates a new document in the collection using the data included in the POST request

GET /<name>/<document_id>
Returns the desired document

PATCH /<name>/<document_id>
Updates the properties of the selected document with the properties included in the POST request.

DELETE /<name>/<document_id>
Deletes the selected document

The express and mongoose objects are available as well in the API object, with 'express' and 'mongoose' object keys respectively.

API Reference

#####registerEndpoints(String name, Object mongooseSchema [, Function authentication]) Creates the Mongoose model, and registers the new API routes which will be exposed. You can pass an authentication function, like the ones used in Express, as the last parameter to control the access of all the routes included in this endpoint.

#####setMongoDBURL(String mongoDBURL) Sets the MongoDB Database URL property, needed to initialize the API server.

#####listen(Integer port) Makes the API available to handle all the requests, listening in the desired port passed as an argument. Otherwise, it will listen to requests at port 3000.

Latest version added features

  • 1.0.3 Subdocument autopopulation

Developed by

Jesús Botella · [email protected]

Twitter LinkedIn