Skip to content

Commit

Permalink
docs: re-organize some pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed May 26, 2024
1 parent 4c5f9fe commit 3407d8a
Show file tree
Hide file tree
Showing 27 changed files with 441 additions and 429 deletions.
1 change: 0 additions & 1 deletion docs/api/server/api/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Plugin API'
order: -1000
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# API
# Plugin API

API allows for plugins to register their own APIs and make them available globally.

Expand Down Expand Up @@ -78,7 +78,7 @@ const api = Rebar.useApi();

async function init() {
// Wait for isReady and Get the API
const authApi = await api.getAsync("auth-api");
const authApi = await api.getAsync('auth-api');

// Hook in your events
authApi.onLogin((player) => {
Expand Down
20 changes: 10 additions & 10 deletions docs/api/server/config.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Config API
# Configuration Usage

This document provides an overview of the configuration management for a Rebar server application.

## Features
- Parsing environment variables.
- Setting a default value if env variable was not defined.
- Basic type validation - number, boolean, string (by default).

- Parsing environment variables.
- Setting a default value if env variable was not defined.
- Basic type validation - number, boolean, string (by default).

## Usage

Expand Down Expand Up @@ -43,7 +44,7 @@ const mongodb = useRebar().useConfig().getField('mongodb');
To be able to extend default Rebar config, you can extend Config interface this way:

```ts /plugins/shared/interfaces.ts
import "@Server/config/index.js";
import '@Server/config/index.js';

// Extend NodeJS.ProcessEnv, so it will show you that it exists on process.env.SOME_ENV_VARIABLE.
declare global {
Expand All @@ -55,19 +56,17 @@ declare global {
}

// Extend Config interface, don't forget to import module first to make TypeScript magic work.
declare module "@Server/config/index.js" {
declare module '@Server/config/index.js' {
interface Config {
// Name of key could be different from env variable, it doesn't matter.
some_variable: number;
}
}

```

After you've extended Config interface, you'll be able to use it's keys to initialize config variable against the env.

```ts /plugins/server/index.ts

/* .env file content:
SOME_ENV_VARIABLE=12
*/
Expand All @@ -83,7 +82,7 @@ config.initFromEnv(
default: 500, // Optional, default: undefined.
required: true, // Optional, default: true.
type: 'number', // Optional, default: undefined (interpreted as string on parse, no type cast).
}
},
);

// If default is not set or set as `undefined`, there is no ENV variable declared and required=true
Expand All @@ -93,6 +92,7 @@ config.initFromEnv(

!!!danger Important
If you will try to parse not a number as number, you will get an uncaught exception:

```ts /plugins/server/index.ts
/* .env file content:
SOME_ENV_VARIABLE=dummy
Expand All @@ -109,7 +109,7 @@ config.initFromEnv(
default: 500, // Optional, default: undefined.
required: true, // Optional, default: true.
type: 'number', // Optional, default: undefined (interpreted as string on parse, no type cast).
}
},
);
```

Expand Down
1 change: 0 additions & 1 deletion docs/api/server/controllers/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Controllers'
order: -1000
1 change: 0 additions & 1 deletion docs/api/server/database/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Database'
order: -1000
1 change: 0 additions & 1 deletion docs/api/server/document/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Document'
order: -1000
2 changes: 1 addition & 1 deletion docs/api/server/events/events.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Events
# Rebar Event Usage

These events are unique to the Rebar framework, and help provide information about when something happens.

Expand Down
1 change: 0 additions & 1 deletion docs/api/server/events/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Events'
order: -1000
1 change: 0 additions & 1 deletion docs/api/server/getters/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Getters'
order: -1000
1 change: 0 additions & 1 deletion docs/api/server/player/index.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
expanded: false
label: 'Player'
order: -1000
30 changes: 0 additions & 30 deletions docs/api/server/player/player-animation.md

This file was deleted.

49 changes: 0 additions & 49 deletions docs/api/server/player/player-appearance.md

This file was deleted.

24 changes: 0 additions & 24 deletions docs/api/server/player/player-audio.md

This file was deleted.

60 changes: 0 additions & 60 deletions docs/api/server/player/player-clothing.md

This file was deleted.

27 changes: 0 additions & 27 deletions docs/api/server/player/player-native.md

This file was deleted.

32 changes: 0 additions & 32 deletions docs/api/server/player/player-notify.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/api/server/player/player-state.md

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api/server/player/player-status.md

This file was deleted.

Loading

0 comments on commit 3407d8a

Please sign in to comment.