Last active
July 13, 2018 01:46
-
-
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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How did you make it ".small" without minify?