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

Commit 8d41ea8

Browse files
author
loicsaintroch
committed
Create an API generator out of Sails core
0 parents  commit 8d41ea8

File tree

7 files changed

+210
-0
lines changed

7 files changed

+210
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
lib-cov
2+
*.seed
3+
*.log
4+
*.csv
5+
*.dat
6+
*.out
7+
*.pid
8+
*.gz
9+
10+
pids
11+
logs
12+
results
13+
14+
npm-debug.log
15+
node_modules

.jshintrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
3+
// **User** "jshint_options". This issue affects users with tabs for indentation.
4+
// This fix was reverted due to a conflict with using the `"white": true` option.
5+
// "indent": 1,
6+
"evil": true,
7+
"regexdash": true,
8+
"browser": true,
9+
"wsh": true,
10+
"sub": true,
11+
12+
// Suppress warnings about mixed tabs and spaces
13+
"smarttabs": true,
14+
15+
// Suppress warnings about trailing whitespace
16+
"trailing": false,
17+
18+
// Suppress warnings about the use of expressions where fn calls or assignments are expected
19+
"expr": true,
20+
21+
// Suppress warnings about using functions inside loops (useful for inifinityCounters)
22+
"loopfunc": true,
23+
24+
// Suppress warnings about using assignments where conditionals are expected
25+
"boss": true,
26+
27+
// Suppress warnings about "weird constructions"
28+
// i.e. allow code like:
29+
// (new (function OneTimeUsePrototype () { } ))
30+
"supernew": true,
31+
32+
// Allow backwards, node-dependency-style commas
33+
"laxcomma": true
34+
}

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 balderdashy & contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
![[email protected]](http://i.imgur.com/RIvu9.png)
2+
3+
# sails-generate-api
4+
5+
6+
A `api` generator for use with the Sails command-line interface.
7+
8+
9+
### Installing this generator
10+
11+
> 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.
12+
13+
<!--
14+
```sh
15+
$ npm install sails-generate-api
16+
```
17+
-->
18+
19+
20+
##### For a particular app
21+
22+
In your app directory:
23+
24+
```sh
25+
$ npm install sails-generate-api
26+
```
27+
28+
Then edit this project's `./.sailsrc` file (see below for details). If no local `.sailsrc` file exists yet, you can just create one.
29+
30+
31+
##### As the default for your global Sails install
32+
33+
In your $HOME folder (i.e. `~/`):
34+
35+
```sh
36+
$ npm install sails-generate-api
37+
```
38+
39+
Then edit your global `~/.sailsrc` file (see below for details). If no global `.sailsrc` file exists yet, you can just create one.
40+
41+
42+
##### Configuring a `.sailsrc` file to use this generator
43+
44+
Add or replace the module used for generating a "api":
45+
46+
```json
47+
{
48+
"generators": {
49+
"modules": {
50+
"api": "sails-generate-api"
51+
}
52+
}
53+
}
54+
```
55+
56+
57+
58+
### Usage
59+
60+
Now that the generator is installed, you can test it:
61+
62+
```sh
63+
$ sails generate api foobar
64+
```
65+
66+
67+
68+
### More Resources
69+
70+
- [Stackoverflow](http://stackoverflow.com/questions/tagged/sails.js)
71+
- [#sailsjs on Freenode](http://webchat.freenode.net/) (IRC channel)
72+
- [Twitter](https://twitter.com/sailsjs)
73+
- [Professional/enterprise](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#are-there-professional-support-options)
74+
- [Tutorials](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#where-do-i-get-help)
75+
- <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>
76+
77+
78+
### License
79+
80+
**[MIT](./LICENSE)**
81+
&copy; 2014 [balderdashy](http://github.com/balderdashy) & [contributors]
82+
[Mike McNeil](http://michaelmcneil.com), [Balderdash](http://balderdash.co) & contributors
83+
84+
[Sails](http://sailsjs.org) is free and open-source under the [MIT License](http://sails.mit-license.org/).

lib/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* sails-generate-api
3+
*
4+
* Usage:
5+
* `sails generate api`
6+
*
7+
* @type {Object}
8+
*/
9+
10+
module.exports = {
11+
targets: {
12+
'.': ['model', 'controller']
13+
}
14+
};

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "sails-generate-api",
3+
"version": "0.10.0",
4+
"description": "Generate a Sails API.",
5+
"main": "lib/index.js",
6+
"keywords": [
7+
"controller",
8+
"model",
9+
"api",
10+
"generator",
11+
"sails",
12+
"generate",
13+
"plugin"
14+
],
15+
"author": "balderdashy",
16+
"license": "MIT",
17+
"dependencies": {
18+
"lodash": ">=2.4.x",
19+
"merge-defaults": ">=0.1.0",
20+
"async": "~0.2.9"
21+
},
22+
"devDependencies": {
23+
"sails-generate": "*",
24+
"reportback": "*",
25+
"fs-extra": "*",
26+
"sails-generate-controller": "~0.10.7",
27+
"sails-generate-model": "~0.10.9"
28+
},
29+
"sailsGenerator": {
30+
"type": "api",
31+
"behavior": "default implementation of `sails generate api`",
32+
"sailsVersion": "~0.10.0"
33+
}
34+
}

0 commit comments

Comments
 (0)