Skip to content

Commit

Permalink
Merge 1213fdf into 93de2a7
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulfatai360 committed Jul 25, 2019
2 parents 93de2a7 + 1213fdf commit 45756a3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 24 deletions.
51 changes: 30 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"dependencies": {
"dotenv": "^8.0.0",
"express": "^4.17.1",
"morgan": "^1.9.1"
"morgan": "^1.9.1",
"swagger-ui-express": "^4.0.7",
"yamljs": "^0.3.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
Expand Down
40 changes: 40 additions & 0 deletions server/docs/authors-haven-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
openapi: 3.0.1

info:
title: Authors Haven API Documentation
description: Create a community of like minded authors to foster inspiration and innovation by leveraging the modern web.
version: 1.0.0
contact:
email: teamrambo50@gmail.com

license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html

servers:
- url: /
desription: Localhost server
- url: https://authors-haven-development.herokuapp.com/
desription: Heroku development server

paths:
/:
summary: Represent root of the application
description: Represent root of the application.
get:
summary: Returns a welcome message.
description: Returns a welcome message.
responses:
'200':
description: Success
content:
text/plain:
schema:
type: string
example: Welcome to Authors Haven

components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
13 changes: 11 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import express, { json, urlencoded } from 'express';
import logger from 'morgan';
import { config } from 'dotenv';
import swaggerUi from 'swagger-ui-express';
import YAML from 'yamljs';
import path from 'path';

config();

const { log } = console;

const PORT = process.env.PORT || 9000;

const app = express();
const swaggerDoc = YAML.load(
path.join(__dirname, './docs/authors-haven-api.yml')
);

app.use(logger('dev'));
app.use(json());
app.use(urlencoded({ extended: false, }));
app.use(urlencoded({ extended: false }));
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDoc));

app.get('/', (request, response) => {
response.status(200).send('Welcome to Authors Haven ');
Expand All @@ -20,5 +27,7 @@ app.get('/', (request, response) => {
app.use('*', (request, response) => {
response.status(404).send('Not Found');
});

app.listen(PORT, () => log(`Server started on port ${PORT}`));

export default app;

0 comments on commit 45756a3

Please sign in to comment.