Skip to content

Commit

Permalink
Merge pull request #17 from RoryConnolly/feat-6-Swagger-Docs-and-Read-Me
Browse files Browse the repository at this point in the history
Added Swagger Docs, PostMan Collection
  • Loading branch information
RoryConnolly authored Aug 5, 2019
2 parents 06d72a7 + 1001398 commit 887b712
Show file tree
Hide file tree
Showing 9 changed files with 607 additions and 303 deletions.
234 changes: 234 additions & 0 deletions DogCollar.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"info": {
"_postman_id": "e027c553-e7a4-4071-8e83-82579672a2f2",
"name": "DogCollarRequests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get a specific CollarData Response by collarId and collarResp",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/SpecificCollarRespByID?collarId=abc1&collarResp=1",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"SpecificCollarRespByID"
],
"query": [
{
"key": "collarId",
"value": "abc1"
},
{
"key": "collarResp",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "Request all CollarData",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/all",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"all"
]
}
},
"response": []
},
{
"name": "Scan all and filter by Barking Params",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/allByBarking?barking=low",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"allByBarking"
],
"query": [
{
"key": "barking",
"value": "low"
}
]
}
},
"response": []
},
{
"name": "Scan all and filter by Activity params ",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/allByActivity?activity=low",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"allByActivity"
],
"query": [
{
"key": "activity",
"value": "low"
}
]
}
},
"response": []
},
{
"name": "Scan all and filter by Location",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/allByLocation?location=90210",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"allByLocation"
],
"query": [
{
"key": "location",
"value": "90210"
}
]
}
},
"response": []
},
{
"name": "Put collar data into the database",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"activity\": \"low\",\n \"location\": \"37901\",\n \"barking\": \"high\",\n \"dogName\": \"Bouncer\",\n \"collarResp\": \"11\",\n \"collarId\": \"abc3\"\n}"
},
"url": {
"raw": "http://localhost:3000/api/pushCollarData",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"pushCollarData"
]
}
},
"response": []
},
{
"name": "Delete Collar data entry from DB by collarID and collarResp",
"request": {
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:3000/api/remove?collarId=abc3&collarResp=11",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"remove"
],
"query": [
{
"key": "collarId",
"value": "abc3"
},
{
"key": "collarResp",
"value": "11"
}
]
}
},
"response": []
},
{
"name": "Get All results for specific collar",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/fetch/allByCollarId?collarId=abc2",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"fetch",
"allByCollarId"
],
"query": [
{
"key": "collarId",
"value": "abc2"
}
]
}
},
"response": []
}
]
}
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ A NodeJS microservice that reads data from dog collars and saves it down to and

## Running the App
```bash
# run development mode (source maps, etc...)
npm start

# run local build (not minified and not in a honeycomb)
npm start
# installs all the applications dependencies
npm install

# run production mode (minified, obfuscated, cache busted, etc...).
# if deploying to a honeycomb, this will configure the application to run behind an API gateway (Zuul)
# starts the node application
npm start

# run lint
# runs es-lint
npm run lint

# run unit tests
npm test

# runs unit tests
npm run test
```
### Running standalone
TODO.

![Test Coverage](./testCoverage.png)


## Commit Requirements
We are following the conventional commit [spec](https://www.conventionalcommits.org/en/v1.0.0-beta.2/#specification) to allow for easier changelog management. The general format for a commit message should look like:
```bash
Expand Down
15 changes: 8 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ const app = express();

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

// const port = process.env.PORT || 3999;

app.get('/', (req, res) => {
res.send('Welcome to my Nodemon API!');
});
app.use('/swag-docs', swaggerUi.serve, swaggerUi.setup(swaggerDoc));
app.use('/api', router);

module.exports = app;

// app.get('/', (req, res) => {
// res.send('Welcome to my Nodemon API!');
// });


// app.listen(port, () => {
// // eslint-disable-next-line no-console
// console.log(`Running on port ${port}`);
// });

module.exports = app;

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const app = require('./app');

const port = process.env.PORT || 3999;
const port = process.env.PORT || 3000;

app.listen(port, () => {
// eslint-disable-next-line no-console
Expand Down
28 changes: 15 additions & 13 deletions models/dataPacket.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const mongoose = require('mongoose');
// TODO add schema validation to the collar response data objects

const { Schema } = mongoose;
// const mongoose = require('mongoose');

const dataModel = new Schema(
{
collarId: { type: String },
collarResp: { type: String },
dogName: { type: String },
barking: { type: String },
activity: { type: String },
location: { type: String },
}
);
// const { Schema } = mongoose;

module.exports = mongoose.model('dataPacket', dataModel);
// const dataModel = new Schema(
// {
// collarId: { type: String },
// collarResp: { type: String },
// dogName: { type: String },
// barking: { type: String },
// activity: { type: String },
// location: { type: String },
// }
// );

// module.exports = mongoose.model('dataPacket', dataModel);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
],
"delay": "2500",
"env": {
"NODE_ENV": "development",
"PORT": 3999
"NODE_ENV": "production",
"PORT": 3000
}
}
}
Loading

0 comments on commit 887b712

Please sign in to comment.