Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umayr/magenta
Generate flexible REST endpoints and controllers from Mongoose models in your Restify app
https://github.com/umayr/magenta
Last synced: about 15 hours ago
JSON representation
Generate flexible REST endpoints and controllers from Mongoose models in your Restify app
- Host: GitHub
- URL: https://github.com/umayr/magenta
- Owner: umayr
- License: mit
- Created: 2015-11-29T16:29:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-29T21:36:32.000Z (almost 9 years ago)
- Last Synced: 2024-03-10T01:42:22.149Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Magenta
### Usage:
```javascript
'use strict';// Require restify and mongoose
const restify = require('restify');
const mongoose = require('mongoose');
// Require package.json
const pkg = require('./package.json');
// Require Magenta
const Magenta = require('magenta');// Set up server details
let server = restify.createServer({
name: pkg.name,
version: pkg.version
});
server.use(restify.acceptParser(server.acceptable));
server.use(restify.authorizationParser());
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(restify.CORS());// Create a schema
let schema = new mongoose.Schema({name: 'string', size: 'string'});
let Tank = mongoose.model('Tank', schema);// Instantiate Mongoose connection
mongoose.connect('mongodb://localhost/test');// Instantiate Magenta
new Magenta(server, mongoose);// Start server
server.listen(3000, function () {
console.log('%s listening at %s', server.name, server.url);
});
```
### Example:
```bash
$ curl --data="name=foo&size=0" localhost:3000/tank
# { success: true}$ curl -s localhost:3000/tank
# { "name": "foo", "size": 0}
```### Note:
This is a work in progress, so almost everything is messy as well as API is going to change a lot. Feature requests and bug reports are pretty much appreciated at this time.
### License:
[MIT](https://github.com/umayr/magenta/blob/master/LICENSE)