Skip to content

Commit b7745b0

Browse files
committed
added sql as a model functionality
1 parent 8ce3ea7 commit b7745b0

File tree

8 files changed

+1481
-7
lines changed

8 files changed

+1481
-7
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,20 @@ Then generate your first API endpoint
5151
$ gulp service --name yourFirstEndpoint // This command will create a CRUD endpoint for yourFirstEndpoint.
5252
```
5353

54-
With the `gulp service` command, you have the option of using either Mongo DB for your database model or using an API generated by this Express Generator as a database model. To use an API as a database you can pass the `baseurl` and the `endpoint` for the API to the `gulp service `. See an example below
54+
With the `gulp service` command, you have the option of using either Mongo DB, an SQL compartible DB or using an API generated by this Express Generator as a database model. To use an API as a database you can pass the `baseurl` and the `endpoint` option for the API to the `gulp service `; for an SQL compartible db, pass the `sql` option. See an example below
55+
56+
### Using an API as a DB
5557

5658
```
5759
$ gulp service --name yourEndpointWithAPIAsDB --baseurl http://localhost:8080 --endpoint users
5860
```
5961

62+
### Using an SQL compartible database
63+
64+
```
65+
$ gulp service --name yourEndpointWITHSQL --sql
66+
```
67+
6068
> Note: You can use -n instead of --name, -b instead of --baseurl, -e instead of --endpoint
6169
6270
Try out your new endpoint.

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
|:------|:------:|:------
44
| app.js | 62 | Write a complete Documentation for this project
55
| config/index.js | 12 | Test for production and development senarios
6-
| models/Tests.js | 95 | Test transactions
76
| models/index.js | 14 | Automatically generate tests with the schema structure
87
| routes/index.js | 298 | Test API versioning
98
| routes/index.js | 299 | Test rate limiting

gulpfile.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ gulp.task('service', function(){
6262
var name;
6363
var baseurl;
6464
var endpoint;
65+
var isSQL;
6566
baseurl = args.baseurl;
6667
endpoint = args.endpoint;
6768
if(!baseurl){
@@ -71,7 +72,11 @@ gulp.task('service', function(){
7172
if(!endpoint){
7273
endpoint = args.e;
7374
}
75+
76+
isSQL = args.sql;
77+
7478
name = args.name;
79+
7580
if(!name){
7681
name = args.n;
7782
}
@@ -102,7 +107,7 @@ gulp.task('service', function(){
102107
});
103108

104109
// Create the Route Unit Test
105-
fs.readFile('./template/route_test.tmpl', function(err, data){
110+
fs.readFile(isSQL ? './template/route_sql_test.tmpl' : './template/route_test.tmpl', function(err, data){
106111
if (err){
107112
throw err;
108113
}
@@ -134,7 +139,7 @@ gulp.task('service', function(){
134139
});
135140
});
136141
}else{
137-
fs.readFile('./template/model.tmpl', function(err, data){
142+
fs.readFile(isSQL ? './template/model_sql.tmpl' : './template/model.tmpl', function(err, data){
138143
if (err){
139144
throw err;
140145
}
@@ -151,7 +156,7 @@ gulp.task('service', function(){
151156
}
152157

153158
// Create the Model Unit Test
154-
fs.readFile('./template/model_test.tmpl', function(err, data){
159+
fs.readFile(isSQL ? './template/model_sql_test.tmpl' : './template/model_test.tmpl', function(err, data){
155160
if (err){
156161
throw err;
157162
}
@@ -167,7 +172,7 @@ gulp.task('service', function(){
167172
});
168173

169174
// Create the controller
170-
fs.readFile('./template/controller.tmpl', function(err, data){
175+
fs.readFile(isSQL ? './template/controller_sql.tmpl' : './template/controller.tmpl', function(err, data){
171176
if (err){
172177
throw err;
173178
}
@@ -183,7 +188,7 @@ gulp.task('service', function(){
183188
});
184189

185190
// Create the controller Unit test
186-
fs.readFile('./template/controller_test.tmpl', function(err, data){
191+
fs.readFile(isSQL ? './template/controller_sql_test.tmpl' : './template/controller_test.tmpl', function(err, data){
187192
if (err){
188193
throw err;
189194
}

0 commit comments

Comments
 (0)