Skip to content

Commit 6b46ee2

Browse files
joshmorelTheHollidayInn
authored andcommitted
Added swagger-jsdoc (#63)
Tags is currently todo
1 parent 9f6bb22 commit 6b46ee2

28 files changed

+1309
-983
lines changed

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ For contributing to this project, please:
77
* clone the repository
88
* make changes
99
* submit a pull request with a unit test on `develop` branch
10+
* document paths, params (in controllers) & definitions (in models) using [swagger-jsdoc](https://github.com/Surnet/swagger-jsdoc/blob/master/docs/GETTING-STARTED.md) which will be served at http{s}://host:port/api/docs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The backend services and API for the Software Engineering Daily [Android](https:
1414
- `npm start` or `yarn start`
1515
- check package.json for other builds
1616
- use curl or Postman to make requests
17-
17+
- view swagger api docs at HOST/api/docs
1818

1919
## Using Docker
2020
- `cp .env.docker_example .env`

config/express.js

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if (config.env === 'development') {
5252
// mount all routes on /api path
5353
app.use('/api', routes);
5454

55+
5556
// if error is not an instanceOf APIError, convert it.
5657
app.use((err, req, res, next) => {
5758
if (err instanceof expressValidation.ValidationError) {

gulpfile.babel.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ import runSequence from 'run-sequence';
77
const plugins = gulpLoadPlugins();
88

99
const paths = {
10-
js: ['./**/*.js', '!dist/**', '!node_modules/**', '!coverage/**'],
11-
nonJs: ['./package.json', './.gitignore', './.env'],
10+
js: ['./**/*.js', '!dist/**', '!node_modules/**', '!coverage/**', '!./server/docs/**'],
11+
nonJs: ['./package.json', './.gitignore', './.env', './server/**/static/**'],
12+
docs: ['./server/docs/**'],
1213
tests: './server/tests/*.js'
1314
};
1415

1516
// Clean up dist and coverage directory
1617
gulp.task('clean', () =>
17-
del.sync(['dist/**', 'dist/.*', 'coverage/**', '!dist', '!coverage'])
18-
);
18+
del.sync(['dist/**', 'dist/.*', 'coverage/**', '!dist', '!coverage']));
1919

2020
// Copy non-js files to dist
2121
gulp.task('copy', () =>
2222
gulp.src(paths.nonJs)
2323
.pipe(plugins.newer('dist'))
24-
.pipe(gulp.dest('dist'))
25-
);
24+
.pipe(gulp.dest('dist')));
25+
26+
// Copy docs to dist
27+
gulp.task('docs', () =>
28+
gulp.src(paths.docs)
29+
.pipe(plugins.newer('dist/server/docs'))
30+
.pipe(gulp.dest('dist/server/docs')));
2631

2732
// Compile ES6 to ES5 and copy to dist
2833
gulp.task('babel', () =>
@@ -36,26 +41,22 @@ gulp.task('babel', () =>
3641
return path.relative(file.path, __dirname);
3742
}
3843
}))
39-
.pipe(gulp.dest('dist'))
40-
);
44+
.pipe(gulp.dest('dist')));
4145

4246
// Start server with restart on file changes
43-
gulp.task('nodemon', ['copy', 'babel'], () =>
47+
gulp.task('nodemon', ['copy', 'docs', 'babel'], () =>
4448
plugins.nodemon({
4549
script: path.join('dist', 'index.js'),
4650
ext: 'js',
4751
ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
48-
tasks: ['copy', 'babel'],
52+
tasks: ['copy', 'docs', 'babel'],
4953
legacyWatch: true
50-
})
51-
);
54+
}));
5255

5356
// gulp serve for development
5457
gulp.task('serve', ['clean'], () => runSequence('nodemon'));
5558

5659
// default task: clean dist, compile js files and copy non-js files.
5760
gulp.task('default', ['clean'], () => {
58-
runSequence(
59-
['copy', 'babel']
60-
);
61+
runSequence(['copy', 'docs', 'babel']);
6162
});

0 commit comments

Comments
 (0)