Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Hexo for Documentation | Solves #1 #17

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ env:
# add env variables here

script:
- yarn run docs
- yarn run test

deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep_history: true
local_dir: ./public
on:
branch: master
25 changes: 25 additions & 0 deletions _config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Express JSON:API Controller
author: theParadoxicalWizard
timezone: UTC

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
#root: /

# Writing
relative_link: false

source_dir: docs

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: ../node_modules/hexo-theme-doc

theme_config:
favicon: ../docs/images/favicon.ico
19 changes: 19 additions & 0 deletions docs/_data/navigation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"logo": {
"text": "Express JSON:API Controller",
"type": "link",
"path": "index.html"
},
"main": [

{
"text": "SUPPORT AND FEEDBACK",
"type": "label"
},
{
"text": "Raise an Issue on Github",
"type": "link",
"path": "https://github.com/coding-blocks/express-jsonapi-controller"
}
]
}
Binary file added docs/images/favicon.ico
Binary file not shown.
Binary file added docs/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
title: Express JSON:API Controller Documentation
---
# Express JSON:API Controller
Base controller class for express apps to create JSON:API endpoints for sequelize models

## Installation
```sh
yarn add @coding-blocks/express-jsonapi-controller
```

## Usage
```js
// import your sequelize models
const DB = require('./models')

// import serializer for your model
const UserSerializer = require('./serializers/user')

// Get the controller
const { Controller } = require('express-jsonapi-controller')
const MyController = new Controller(
DB.User, // Model you want to create controller instance for
DB, // Models import for getting related models
UserSerializer
)

// Create your endpoints
router.get('/', MyController.handleQuery)

```

## Creating Serializers
We use jsonapi-serializer for serializing models
```js
/*
export a function with following arguments
@params [included] included models config
@params [type] serialize or deserialize
@params [config] meta config
*/
module.exports = (included, type, config) => {
return {
attributes: ['firstName', 'lastName'],
...config
};
};
```

## Available Methods
- ``` Controller.handleQuery() ```
- ``` Controller.handleQueryById() ```
- ``` Controller.handleUpdateById() ```
- ``` Controller.handleDeleteById() ```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
module.exports = {
Controller: require('./lib/baseController'),
utils: require('./lib/util')
}
}
Loading