Skip to content

Commit

Permalink
docs: Add Services reference (medusajs#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Jun 1, 2022
1 parent 6c1a722 commit c87ddd7
Show file tree
Hide file tree
Showing 52 changed files with 14,489 additions and 16 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/generate-reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Generate References
on:
push:
branches:
- 'master'
paths:
- packages/medusa/src/services/**
jobs:
services:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v2.3.5
with:
fetch-depth: 0

- name: Setup Node.js environment
uses: actions/setup-node@v2.4.1
with:
node-version: "14"
cache: "yarn"

- name: Bootstrap packages
uses: ./.github/actions/cache-bootstrap
with:
extension: unit-tests

- name: Build Packages
run: yarn build

- name: Generate Services Reference
run: yarn generate:services

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automatically Generated Services Reference
file_pattern: docs/content/*
skip_dirty_check: false
5 changes: 5 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


yarn-path ".yarn/releases/yarn-1.19.0.cjs"
1 change: 1 addition & 0 deletions docs/content/advanced/backend/services/create-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ constructor({ helloService, eventBusService }) {

## What’s Next 🚀

- Check out the [Services Reference](/references/services/classes/AuthService) to see a list of all services in Medusa.
- [Learn How to Create an Endpoint.](/advanced/backend/endpoints/add-storefront)
1 change: 1 addition & 0 deletions docs/content/references/services/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
136 changes: 136 additions & 0 deletions docs/content/references/services/classes/AuthService.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Class: AuthService

Can authenticate a user based on email password combination

## Hierarchy

- `"medusa-interfaces"`

**`AuthService`**

## Constructors

### constructor

**new AuthService**(`__namedParameters`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | `Object` |

#### Overrides

BaseService.constructor

#### Defined in

[services/auth.ts:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L12)

## Methods

### authenticate

**authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\>

Authenticates a given user based on an email, password combination. Uses
scrypt to match password with hashed value.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `email` | `string` | the email of the user |
| `password` | `string` | the password of the user |

#### Returns

`Promise`<`AuthenticateResult`\>

success: whether authentication succeeded
user: the user document if authentication succeded
error: a string with the error message

#### Defined in

[services/auth.ts:78](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L78)

___

### authenticateAPIToken

**authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\>

Authenticates a given user with an API token

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `token` | `string` | the api_token of the user to authenticate |

#### Returns

`Promise`<`AuthenticateResult`\>

success: whether authentication succeeded
user: the user document if authentication succeded
error: a string with the error message

#### Defined in

[services/auth.ts:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L41)

___

### authenticateCustomer

**authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\>

Authenticates a customer based on an email, password combination. Uses
scrypt to match password with hashed value.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `email` | `string` | the email of the user |
| `password` | `string` | the password of the user |

#### Returns

`Promise`<`AuthenticateResult`\>

success: whether authentication succeeded
user: the user document if authentication succeded
error: a string with the error message

#### Defined in

[services/auth.ts:123](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L123)

___

### comparePassword\_

**comparePassword_**(`password`, `hash`): `Promise`<`boolean`\>

Verifies if a password is valid given the provided password hash

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `password` | `string` | the raw password to check |
| `hash` | `string` | the hash to compare against |

#### Returns

`Promise`<`boolean`\>

the result of the comparison

#### Defined in

[services/auth.ts:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L28)
Loading

0 comments on commit c87ddd7

Please sign in to comment.