Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Create an API generator out of Sails core
Browse files Browse the repository at this point in the history
  • Loading branch information
loicsaintroch committed Aug 25, 2014
0 parents commit 8d41ea8
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules
34 changes: 34 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
// **User** "jshint_options". This issue affects users with tabs for indentation.
// This fix was reverted due to a conflict with using the `"white": true` option.
// "indent": 1,
"evil": true,
"regexdash": true,
"browser": true,
"wsh": true,
"sub": true,

// Suppress warnings about mixed tabs and spaces
"smarttabs": true,

// Suppress warnings about trailing whitespace
"trailing": false,

// Suppress warnings about the use of expressions where fn calls or assignments are expected
"expr": true,

// Suppress warnings about using functions inside loops (useful for inifinityCounters)
"loopfunc": true,

// Suppress warnings about using assignments where conditionals are expected
"boss": true,

// Suppress warnings about "weird constructions"
// i.e. allow code like:
// (new (function OneTimeUsePrototype () { } ))
"supernew": true,

// Allow backwards, node-dependency-style commas
"laxcomma": true
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2014 balderdashy & contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
![[email protected]](http://i.imgur.com/RIvu9.png)

# sails-generate-api


A `api` generator for use with the Sails command-line interface.


### Installing this generator

> Certain generators are installed by default in Sails, but they can be overridden. Check the [Sails docs](http://sailsjs.org/#!documentation) for information on installing generator overrides / custom generators.
<!--
```sh
$ npm install sails-generate-api
```
-->


##### For a particular app

In your app directory:

```sh
$ npm install sails-generate-api
```

Then edit this project's `./.sailsrc` file (see below for details). If no local `.sailsrc` file exists yet, you can just create one.


##### As the default for your global Sails install

In your $HOME folder (i.e. `~/`):

```sh
$ npm install sails-generate-api
```

Then edit your global `~/.sailsrc` file (see below for details). If no global `.sailsrc` file exists yet, you can just create one.


##### Configuring a `.sailsrc` file to use this generator

Add or replace the module used for generating a "api":

```json
{
"generators": {
"modules": {
"api": "sails-generate-api"
}
}
}
```



### Usage

Now that the generator is installed, you can test it:

```sh
$ sails generate api foobar
```



### More Resources

- [Stackoverflow](http://stackoverflow.com/questions/tagged/sails.js)
- [#sailsjs on Freenode](http://webchat.freenode.net/) (IRC channel)
- [Twitter](https://twitter.com/sailsjs)
- [Professional/enterprise](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#are-there-professional-support-options)
- [Tutorials](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#where-do-i-get-help)
- <a href="http://sailsjs.org" target="_blank" title="Node.js framework for building realtime APIs."><img src="https://github-camo.global.ssl.fastly.net/9e49073459ed4e0e2687b80eaf515d87b0da4a6b/687474703a2f2f62616c64657264617368792e6769746875622e696f2f7361696c732f696d616765732f6c6f676f2e706e67" width=60 alt="Sails.js logo (small)"/></a>


### License

**[MIT](./LICENSE)**
&copy; 2014 [balderdashy](http://github.com/balderdashy) & [contributors]
[Mike McNeil](http://michaelmcneil.com), [Balderdash](http://balderdash.co) & contributors

[Sails](http://sailsjs.org) is free and open-source under the [MIT License](http://sails.mit-license.org/).
14 changes: 14 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* sails-generate-api
*
* Usage:
* `sails generate api`
*
* @type {Object}
*/

module.exports = {
targets: {
'.': ['model', 'controller']
}
};
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "sails-generate-api",
"version": "0.10.0",
"description": "Generate a Sails API.",
"main": "lib/index.js",
"keywords": [
"controller",
"model",
"api",
"generator",
"sails",
"generate",
"plugin"
],
"author": "balderdashy",
"license": "MIT",
"dependencies": {
"lodash": ">=2.4.x",
"merge-defaults": ">=0.1.0",
"async": "~0.2.9"
},
"devDependencies": {
"sails-generate": "*",
"reportback": "*",
"fs-extra": "*",
"sails-generate-controller": "~0.10.7",
"sails-generate-model": "~0.10.9"
},
"sailsGenerator": {
"type": "api",
"behavior": "default implementation of `sails generate api`",
"sailsVersion": "~0.10.0"
}
}

0 comments on commit 8d41ea8

Please sign in to comment.