Skip to content

Commit

Permalink
feat(docs)/docusaurus (#238)
Browse files Browse the repository at this point in the history
* feat: setup of docusaurus + preshot few pages

* refactor: main page

* feat: add per plugin configuration

* refactor: plugins pages configuration

* feat: add workflow file

* fix: remove shared plugin doc

* fix: move docs to services

* refactor: change button and colors

* fix: update logo main page
  • Loading branch information
nullswan authored Oct 19, 2022
1 parent 6c61187 commit 5db5ee4
Show file tree
Hide file tree
Showing 44 changed files with 7,272 additions and 265 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
paths:
- '.github/workflows/docs.yml'
- 'services/docs/**'

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: |
corepack enable
yarn install --frozen-lockfile
- name: Build website
run: yarn workspace docs build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./services/docs/build
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
build
coverage
dist

services/docs/.docusaurus
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GraphQL Armor is a dead-simple yet highly customizable security middleware for various GraphQL server engines.

![GraphQL-Armor banner](https://raw.githubusercontent.com/Escape-Technologies/graphql-armor/main/packages/docs/banner.png)
![GraphQL-Armor banner](https://raw.githubusercontent.com/Escape-Technologies/graphql-armor/main/packages/docs/static/img/banner.png)

[![CI](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/ci.yaml/badge.svg)](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/ci.yaml) [![release](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/release.yaml/badge.svg)](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/release.yaml) [![e2e](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/e2e.yaml/badge.svg)](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/e2e.yaml) ![npm](https://img.shields.io/npm/v/@escape.tech/graphql-armor) [![codecov](https://codecov.io/gh/Escape-Technologies/graphql-armor/branch/main/graph/badge.svg)](https://codecov.io/gh/Escape-Technologies/graphql-armor)

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"workspaces": [
"examples/*",
"packages/*",
"packages/plugins/*"
"packages/plugins/*",
"services/*"
],
"volta": {
"node": "16.18.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/docs/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/graphql-armor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GraphQL Armor is a dead-simple yet highly customizable security middleware for various GraphQL server engines.

![GraphQL-Armor banner](https://raw.githubusercontent.com/Escape-Technologies/graphql-armor/main/packages/docs/banner.png)
![GraphQL-Armor banner](https://raw.githubusercontent.com/Escape-Technologies/graphql-armor/main/packages/docs/static/img/banner.png)

[![CI](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/ci.yaml/badge.svg)](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/ci.yaml) [![release](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/release.yaml/badge.svg)](https://github.com/Escape-Technologies/graphql-armor/actions/workflows/release.yaml) ![npm](https://img.shields.io/npm/v/@escape.tech/graphql-armor)

Expand Down
20 changes: 20 additions & 0 deletions services/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
41 changes: 41 additions & 0 deletions services/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions services/docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
Empty file.
5 changes: 5 additions & 0 deletions services/docs/docs/_faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 100
---

# FAQ
Empty file.
8 changes: 8 additions & 0 deletions services/docs/docs/api/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "API",
"position": 10,
"link": {
"type": "generated-index",
"description": "Full API documentation"
}
}
19 changes: 19 additions & 0 deletions services/docs/docs/api/types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Types

## Callbacks

### GraphQLArmorAcceptCallback

```ts
import type { ValidationContext } from 'graphql';

export type GraphQLArmorAcceptCallback = (ctx: ValidationContext | null, details: any) => void;
```

### GraphQLArmorRejectCallback

```ts
import type { GraphQLError, ValidationContext } from 'graphql';

export type GraphQLArmorRejectCallback = (ctx: ValidationContext | null, error: GraphQLError) => void;
```
1 change: 1 addition & 0 deletions services/docs/docs/configuration/_apollo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Apollo Configuration
8 changes: 8 additions & 0 deletions services/docs/docs/configuration/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Configuration",
"position": 10,
"link": {
"type": "generated-index",
"description": "In depth documentation on how to configure GraphQL Armor"
}
}
1 change: 1 addition & 0 deletions services/docs/docs/configuration/_envelop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Envelop Configuration
1 change: 1 addition & 0 deletions services/docs/docs/configuration/_graphqljs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# GraphQL JS Configuration
7 changes: 7 additions & 0 deletions services/docs/docs/configuration/values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Determinate plugin thresholds

We recommend [GraphQL Inspector](https://github.com/kamilkisiela/graphql-inspector) to help you determinate the thresholds to use.

This tool is capable of analyzing your schema and generate useful metrics helping you to determinate and monitor your limits.

> View [GraphQL Inspector `audit`](https://the-guild.dev/graphql/inspector/docs/essentials/audit).
128 changes: 128 additions & 0 deletions services/docs/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
sidebar_position: 1
---

# Getting started

This package is dedicated to any **GraphQL developer** who wants to add a security layer to their API, in a simple and efficient way.

GraphQL Armor mainly focused on limiting the impact of malicious **GraphQL operations**.

You can find more information about the upcoming features on our [issues page](https://github.com/Escape-Technologies/graphql-armor/issues).

If you need help or want to discuss about the project, you can hop in [project discussions](https://github.com/Escape-Technologies/graphql-armor/discussions).

## Installation

```bash
# npm
npm install -S @escape.tech/graphql-armor

# yarn
yarn add @escape.tech/graphql-armor
```

## Usage

We provided [some examples](https://github.com/Escape-Technologies/graphql-armor/tree/main/examples) to help you get started with GraphQL Armor.

We will detail the usage of GraphQL Armor in the following sections:

- [Apollo Server](#apollo-server)
- [GraphQL Yoga](#graphql-yoga)
- [Envelop](#envelop)

### Apollo Server

If you do not use plugins and validations rules, we recommend you to proceed with the following example:

```ts
import { ApolloArmor } from '@escape.tech/graphql-armor';

const armor = new ApolloArmor();

const server = new ApolloServer({
typeDefs,
resolvers,
...armor.protect()
});
```

Otherwise, if you already have some plugins or validation rules, we recommend you to proceed this way:

```ts
import { ApolloArmor } from '@escape.tech/graphql-armor';

const armor = new ApolloArmor();
const protection = armor.protect()

const server = new ApolloServer({
typeDefs,
resolvers,
...protection,
plugins: [...protection.plugins, myPlugin1, myPlugin2 ]
validationRules: [, ...protection.validationRules, myRule1, myRule2 ]
});
```

### GraphQL Yoga

If you do not use plugins and validations rules, we recommend you to proceed with the following example:

```ts
import { EnvelopArmor } from '@escape.tech/graphql-armor';

const armor = new EnvelopArmor();
const protection = armor.protect()

async function main() {
const server = createServer({
schema,
plugins: [...protection.plugins],
});
await server.start();
}

main();
```

Otherwise, if you already have some plugins or validation rules, we recommend you to proceed this way:

```ts
import { EnvelopArmorPlugin } from '@escape.tech/graphql-armor';

async function main() {
const server = createServer({
schema,
plugins: [EnvelopArmorPlugin()],
});
await server.start();
}

main();
```

### Envelop

If you do not use plugins and validations rules, we recommend you to proceed with the following example:

```ts
import { EnvelopArmor } from '@escape.tech/graphql-armor';

const armor = new EnvelopArmor();
const protection = armor.protect()

const getEnveloped = envelop({
plugins: [otherPlugins, ...protection.plugins],
});
```

Otherwise, if you already have some plugins or validation rules, we recommend you to proceed this way:

```ts
import { EnvelopArmorPlugin } from '@escape.tech/graphql-armor';

const getEnveloped = envelop({
plugins: [otherPlugins, EnvelopArmorPlugin()],
});
```
8 changes: 8 additions & 0 deletions services/docs/docs/plugins/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Plugins",
"position": 10,
"link": {
"type": "generated-index",
"description": "Detailed information per plugin"
}
}
Loading

0 comments on commit 5db5ee4

Please sign in to comment.