Getting started

Install mongo Server

npm install -g moser

Start Mongo Server

docker run -d -p 27017:27017 mongo # if you have docker but no mongodb
moser --mongo mongodb://localhost:27017

Now if you go to http://localhost:3000/posts/, you'll get

[]

Also when doing requests, it's good to know that:

  • If you make POST, PUT, PATCH or DELETE requests, changes will be stored on mongodb.

  • Your request body JSON should be object enclosed, just like the GET output. (for example {"name": "Foobar"})

  • Id values are not mutable. Any id value in the body of your PUT or PATCH request will be ignored. Only a value set in a POST request will be respected, but only if not already taken.

  • id values are currently saved as plain text, this probably will change in the

CLI usage

Usage: mongodb-server [options]

  Options:                   Description:                Default:

    -V, --version            output the version number
    -c, --config <filePath>  Set a config file           undefined
    -p --port <number>       Server port                 3000
    -m --mongo <uri>         mongodb URI                 mongodb://localhost:27017
    -d --db <string>         database name               mongo-server
    -h, --help               output usage information

Config file

You can also set options in a js or json configuration file.

Last updated

Was this helpful?