hayone/moser

By hayone

Updated 8 months ago

Docker image of fega mongo-server aka moser.

Image
API Management
Databases & Storage
Developer Tools
0

20

Mongo Server

This is the docker image for the Mongo Server npm package that exposes a mongo database as an API.

Docker Example Usage

config.js

module.exports= {
    // Port, default 3000
    port: 3000,
    // REST api root, default "/"
    root: "/",
    // hostname
    host: 'http://localhost:3000',
    // mongodb url default: "mongodb://localhost:27088"
    mongo: 'mongodb://user:password@ip:port',
    // database name
    db:'Dcm_sandbox',
    // mongoDb client options
    // http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#.connect
    mongoOptions: {
        connectTimeoutMS: 10000,
        authSource: 'admin',
        authMechanism: 'SCRAM-SHA-1'
    },
  
    // enable cors using the cors module https://www.npmjs.com/package/cors
    cors: {origin:true},
    // enable gzip compression using the compression module https://www.npmjs.com/package/compression
    compress: {},
    // enable helmet module https://www.npmjs.com/package/helmet
    helmet: {},
    // static file server, by default is "public" in the execution dir
    static: 'public',
    // root path for static file serving, by default "/"
    staticRoot: '/',
    // // personalized middleware, executed before REST api
    // middleware: [myFunction],
    // Plugins, executed before REST api
    // plugins are functions that receives 3 arguments and returns express middleware
    // // (config: MoserConfig, db: MongodbInstance, Client: MongodbClient)=> ExpressMiddleware || ExpressMiddleware[] 
    // plugins: [myPluginFunction],
    // default pagination limit
    pagination: 10,
    // set as true to enable trust proxy on express
    trustProxy: false,
    // // custom error handler
    // errorHandler: (req.res,next,err)=>{/* custom error handler */},
  
    // // shutdown function, to gracefully stop the server
    // // notice that this function returns another function
    // shutdown: (config, ExpressServer, mongodbClient)=>()=>{/*custom shutdown function here  */}
  
  
    // extra settings
    settings:{
      // avoid $where queries (To Avoid noSQL attacks), is enabled by default
      restrictWhereQuery: true
    }
  }

Assuming you are using a config.js like the above

docker container run --volume "$(pwd):/work" --rm moser --config /work/config.js
Kubernetes

Coming soon

Docker Pull Command

docker pull hayone/moser