Skip to content

Commit

Permalink
Merge pull request #209 from ageddesi/dev
Browse files Browse the repository at this point in the history
v.0.14.0 candidate
  • Loading branch information
ageddesi authored Oct 13, 2022
2 parents cd3d838 + b36c739 commit 0ffa984
Show file tree
Hide file tree
Showing 71 changed files with 4,507 additions and 2,832 deletions.
95 changes: 95 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,101 @@
"contributions": [
"test"
]
},
{
"login": "devvspaces",
"name": "Ayanwola Ayomide",
"avatar_url": "https://avatars.githubusercontent.com/u/77179231?v=4",
"profile": "https://devvspace.webflow.io/",
"contributions": [
"code",
"test",
"doc"
]
},
{
"login": "zaibugemi",
"name": "Zuhaib Shah",
"avatar_url": "https://avatars.githubusercontent.com/u/34958019?v=4",
"profile": "https://preciouslife837753359.wordpress.com/",
"contributions": [
"code"
]
},
{
"login": "GuilhermeFernandes01",
"name": "Guilherme Fernandes",
"avatar_url": "https://avatars.githubusercontent.com/u/26780625?v=4",
"profile": "https://github.com/GuilhermeFernandes01",
"contributions": [
"code"
]
},
{
"login": "benhalverson",
"name": "Ben Halverson",
"avatar_url": "https://avatars.githubusercontent.com/u/7907232?v=4",
"profile": "https://github.com/benhalverson",
"contributions": [
"code",
"test"
]
},
{
"login": "darkl1ght",
"name": "Ayush Chauhan",
"avatar_url": "https://avatars.githubusercontent.com/u/19537472?v=4",
"profile": "https://github.com/darkl1ght",
"contributions": [
"test",
"code"
]
},
{
"login": "edwardsmoses",
"name": "Edwards Moses",
"avatar_url": "https://avatars.githubusercontent.com/u/19548998?v=4",
"profile": "https://edwardsmoses.com/",
"contributions": [
"doc",
"test"
]
},
{
"login": "RizkyRajitha",
"name": "Rajitha Gunathilake",
"avatar_url": "https://avatars.githubusercontent.com/u/38534289?v=4",
"profile": "https://rizkyrajitha.github.io/",
"contributions": [
"code"
]
},
{
"login": "bmusuko",
"name": "Bram Musuko Panjaitan",
"avatar_url": "https://avatars.githubusercontent.com/u/32943475?v=4",
"profile": "https://bmusuko.tech/",
"contributions": [
"test"
]
},
{
"login": "filipkujawa",
"name": "filip",
"avatar_url": "https://avatars.githubusercontent.com/u/44206832?v=4",
"profile": "https://github.com/filipkujawa",
"contributions": [
"code"
]
},
{
"login": "mdfarhaan",
"name": "Farhaan",
"avatar_url": "https://avatars.githubusercontent.com/u/60516398?v=4",
"profile": "https://github.com/mdfarhaan",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/codesee-arch-diagram.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# This workflow was added by CodeSee. Learn more at https://codesee.io/
on:
push:
branches:
- dev
pull_request_target:
types: [opened, synchronize, reopened]

name: CodeSee Map

permissions: read-all

jobs:
test_map_action:
runs-on: ubuntu-latest
continue-on-error: true
name: Run CodeSee Map Analysis
steps:
- name: checkout
id: checkout
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

# codesee-detect-languages has an output with id languages.
- name: Detect Languages
id: detect-languages
uses: Codesee-io/codesee-detect-languages-action@latest

- name: Configure JDK 16
uses: actions/setup-java@v3
if: ${{ fromJSON(steps.detect-languages.outputs.languages).java }}
with:
java-version: '16'
distribution: 'zulu'

# CodeSee Maps Go support uses a static binary so there's no setup step required.

- name: Configure Node.js 14
uses: actions/setup-node@v3
if: ${{ fromJSON(steps.detect-languages.outputs.languages).javascript }}
with:
node-version: '14'

- name: Configure Python 3.x
uses: actions/setup-python@v4
if: ${{ fromJSON(steps.detect-languages.outputs.languages).python }}
with:
python-version: '3.10'
architecture: 'x64'

- name: Configure Ruby '3.x'
uses: ruby/setup-ruby@v1
if: ${{ fromJSON(steps.detect-languages.outputs.languages).ruby }}
with:
ruby-version: '3.0'

# We need the rust toolchain because it uses rustc and cargo to inspect the package
- name: Configure Rust 1.x stable
uses: actions-rs/toolchain@v1
if: ${{ fromJSON(steps.detect-languages.outputs.languages).rust }}
with:
toolchain: stable

- name: Generate Map
id: generate-map
uses: Codesee-io/codesee-map-action@latest
with:
step: map
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
github_ref: ${{ github.ref }}
languages: ${{ steps.detect-languages.outputs.languages }}

- name: Upload Map
id: upload-map
uses: Codesee-io/codesee-map-action@latest
with:
step: mapUpload
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
github_ref: ${{ github.ref }}

- name: Insights
id: insights
uses: Codesee-io/codesee-map-action@latest
with:
step: insights
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
github_ref: ${{ github.ref }}
17 changes: 17 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pull-request

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
.env
.DS_Store
.idea
coverage
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"eslint.alwaysShowStatus": true,
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.useESLintClass": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript"]
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/agedde
include Setup of env, IDE and typical getting started instructions?
-->
1. When adding new API endpoints, please add OpenAPI comments
2. All code must have corrosponding unit tests.
2. All code must have corresponding unit tests.
3. All API endpoints must have unit tests for all return codes.

### Improving The Documentation
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine
FROM node:18-alpine
WORKDIR /src
COPY package.json package-lock.json /src/
RUN npm install
Expand Down
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-27-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-37-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<p align="center" style="margin-bottom: 20px">
Expand All @@ -19,10 +19,10 @@ Welcome to Mocked-API, this is a live API that can be accessed by anyone who nee

## Hacktoberfest Contributors

If you would like to contribute during Hacktoberfest please following our contribution guidelines (Which we are still working on) but here is a quick summary of what we expect in a PR.
If you would like to contribute during Hacktoberfest please following our contribution guidelines (Which we are still working on) but here is a quick summary of what we expect in the process of dev to raising your PR.

1. Find a ticket and ask to be assigned, once assigned start work. :) This is so we don't get multiple PR's for the same issue.
1. Please branch from our active next release *v.0.13.0*
1. Please branch from our active next release *dev*
2. Please make sure your new endpoints all have OpenAPI Comments as they will be used to generate our swagger documentation.
3. Please make sure you have added unit tests for end points and util functions.
4. MOST importantly, have fun.
Expand Down Expand Up @@ -85,14 +85,13 @@ For each module you create you will also need to create a tests folder, Inside t
The utils tests are fairly simple jests tests, the `api` routes tests are slightly different where you will need to add
```javascript
import request from 'supertest';
const baseURL = 'http://localhost:3000';
import app from 'path/to/app';
```
to your tests and make a request in your test instead of calling a normal function.

### How to run tests
1. Run the mocked api server locally
2. run `npm run test`

run `npm test`
run `npm run test:watch` to run the tests in watch mode.

## FAQ

Expand Down Expand Up @@ -169,6 +168,20 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://www.krishnasingh.co.in/"><img src="https://avatars.githubusercontent.com/u/3418713?v=4?s=100" width="100px;" alt="krishna"/><br /><sub><b>krishna</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=kk5190" title="Code">💻</a></td>
<td align="center"><a href="https://vadimdez.github.io/"><img src="https://avatars.githubusercontent.com/u/3748453?v=4?s=100" width="100px;" alt="Vadym Yatsyuk"/><br /><sub><b>Vadym Yatsyuk</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=VadimDez" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/nibih"><img src="https://avatars.githubusercontent.com/u/42928462?v=4?s=100" width="100px;" alt="Nicholas Robert Beckham"/><br /><sub><b>Nicholas Robert Beckham</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=nibih" title="Tests">⚠️</a></td>
<td align="center"><a href="https://devvspace.webflow.io/"><img src="https://avatars.githubusercontent.com/u/77179231?v=4?s=100" width="100px;" alt="Ayanwola Ayomide"/><br /><sub><b>Ayanwola Ayomide</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=devvspaces" title="Code">💻</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=devvspaces" title="Tests">⚠️</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=devvspaces" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://preciouslife837753359.wordpress.com/"><img src="https://avatars.githubusercontent.com/u/34958019?v=4?s=100" width="100px;" alt="Zuhaib Shah"/><br /><sub><b>Zuhaib Shah</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=zaibugemi" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/GuilhermeFernandes01"><img src="https://avatars.githubusercontent.com/u/26780625?v=4?s=100" width="100px;" alt="Guilherme Fernandes"/><br /><sub><b>Guilherme Fernandes</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=GuilhermeFernandes01" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/benhalverson"><img src="https://avatars.githubusercontent.com/u/7907232?v=4?s=100" width="100px;" alt="Ben Halverson"/><br /><sub><b>Ben Halverson</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=benhalverson" title="Code">💻</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=benhalverson" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/darkl1ght"><img src="https://avatars.githubusercontent.com/u/19537472?v=4?s=100" width="100px;" alt="Ayush Chauhan"/><br /><sub><b>Ayush Chauhan</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=darkl1ght" title="Tests">⚠️</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=darkl1ght" title="Code">💻</a></td>
<td align="center"><a href="https://edwardsmoses.com/"><img src="https://avatars.githubusercontent.com/u/19548998?v=4?s=100" width="100px;" alt="Edwards Moses"/><br /><sub><b>Edwards Moses</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=edwardsmoses" title="Documentation">📖</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=edwardsmoses" title="Tests">⚠️</a></td>
<td align="center"><a href="https://rizkyrajitha.github.io/"><img src="https://avatars.githubusercontent.com/u/38534289?v=4?s=100" width="100px;" alt="Rajitha Gunathilake"/><br /><sub><b>Rajitha Gunathilake</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=RizkyRajitha" title="Code">💻</a></td>
<td align="center"><a href="https://bmusuko.tech/"><img src="https://avatars.githubusercontent.com/u/32943475?v=4?s=100" width="100px;" alt="Bram Musuko Panjaitan"/><br /><sub><b>Bram Musuko Panjaitan</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=bmusuko" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/filipkujawa"><img src="https://avatars.githubusercontent.com/u/44206832?v=4?s=100" width="100px;" alt="filip"/><br /><sub><b>filip</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=filipkujawa" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/mdfarhaan"><img src="https://avatars.githubusercontent.com/u/60516398?v=4?s=100" width="100px;" alt="Farhaan"/><br /><sub><b>Farhaan</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=mdfarhaan" title="Code">💻</a></td>
</tr>
</tbody>
<tfoot>
Expand Down
14 changes: 9 additions & 5 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require('dotenv').config();
import express, { Request, Response } from 'express';
import { swaggerSpec } from './utils/swagger';
import swag from "./swagger.json";

const morgan = require('morgan');
const cors = require('cors');

const app = express();
const port = 3000;

// Load Mock Modules
require('./modules/animal/api/animal-routes')(app); // Animals
Expand All @@ -30,13 +30,20 @@ require('./modules/phone-numbers/api/phone-numbers-routes')(app); // Phone numbe
require('./modules/quotes/api/quotes-routes')(app); // Quotes
require('./modules/ip/api/ip-routes')(app); // ip and mac address
require('./modules/vehicles/api/vehicles-routes')(app); // Vehicles
require('./modules/address/api/address-routes')(app); // Addresses
require('./modules/bankfeed/api/bankfeed-routes')(app); // Bank Feed
require('./modules/location/api/location-routes')(app); // Bank Feed


// Add an healthcheck endpoint
// Shows amount of API Categories and their endpoints
app.get('/status', (req, res) => {
const data = {
uptime: process.uptime(),
message: 'Ok',
date: new Date(),
totalCategories: swag.tags.length,
totalEndpoints: Object.keys(swag.paths).length,
};
res.status(200).send(data);
});
Expand All @@ -51,10 +58,7 @@ app.get('/docs.json', (req: Request, res: Response) => {
const swaggerUi = require('swagger-ui-express');
app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerSpec));


app.use(cors()); // enabling CORS for all requests
app.use(morgan('combined')); // adding morgan to log HTTP requests

app.listen(port, () => {
console.log(`Mock API is running on port ${port}.`);
});
export default app;
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
testEnvironment: 'node',
collectCoverage: true,
coverageReporters: ['json', 'html', 'text', 'text-summary']
}
Loading

0 comments on commit 0ffa984

Please sign in to comment.