Skip to content

Instantly share code, notes, and snippets.

@daffl
Last active July 13, 2018 01:46
Show Gist options
  • Save daffl/14f9f3950d8caa3c9ba93fef3ba74253 to your computer and use it in GitHub Desktop.
Save daffl/14f9f3950d8caa3c9ba93fef3ba74253 to your computer and use it in GitHub Desktop.
Node + MongoDB REST API in a tweet - `npm i @feathersjs/feathers @feathersjs/express mongodb feathers-mongodb`
const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const mongodb = require('mongodb');
const service = require('feathers-mongodb');
mongodb.MongoClient.connect(`mongodb://localhost:27017`).then(client => {
const app = express(feathers())
.configure(express.rest())
.use('/messages', express.json(), service({
Model: client.db('feathers').collection('messages')
}));
app.listen(3030);
});
const r=require,e=r("@feathersjs/express"),d="mongodb",m="messages";r(d).MongoClient.connect(`${d}://localhost:27017`).then(s=>e(r("@feathersjs/feathers")()).configure(e.rest()).use(m,e.json(),r(`feathers-${d}`)({Model:s.db("f").collection(m)})).listen(3030));
const r = require;
const e = r('@feathersjs/express');
const d = 'mongodb';
const m = 'messages';
r(d).MongoClient.connect(`${d}://localhost:27017`)
.then(c => e(r('@feathersjs/feathers')()).configure(e.rest())
.use(m, e.json(), r(`feathers-${d}`)({
Model: c.db('f').collection(m)
}))
.listen(3030)
);
@abhisekp
Copy link

How did you make it ".small" without minify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment