Skip to content

Commit

Permalink
Updated Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SellersEvan committed May 17, 2024
1 parent 31f4556 commit 52a5b68
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
["Server Config", "/build/server-config"],
["Module Config", "/build/module-config"],
["Building a Module - WIP", "/build/building-a-module"],
["Miscellaneous - WIP", "/build/miscellaneous"]
["Miscellaneous", "/build/miscellaneous"]
]
], [
"API Reference",
Expand Down
5 changes: 5 additions & 0 deletions docs/api/components/parameters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ includes numbers and booleans. This class is very similar to the standard
[URLSearchParams class](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
used in web APIs.

When parameters come from the [`Request`](/api/components/request) class, from a
URL they are automatically parsed (booleans and numbers) and seperated by commas.
See [request examples](/api/components/request#basic-get-request), for more
information.


<br/>

Expand Down
61 changes: 60 additions & 1 deletion docs/build/miscellaneous.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
# Miscellaneous
# Miscellaneous


## Environment Variables
Environment variables are a key part of configuring your SherpaJS application.
They allow you to set various configuration options and secrets without
hardcoding them into your application's codebase.


<br/>


### Loading Environment Variables
SherpaJS uses the `.env` file to load environment variables. This file should
be placed at the root of your project. When the system is compiled, the
variables defined in this file are automatically loaded into your server's
environment.

Any environment variables provided by hosting services (such as Vercel or AWS)
are automatically included in your build.

Environment varibles can also be added during build with the
[build command](/api/cli#build-command).


<br/>


### Automatic Parsing
SherpaJS automatically parses environment variables to their appropriate types:
- Strings remain as strings
- Booleans are converted to `true` or `false`
- Numbers are converted to numeric values


<br/>


### Example .env File
Here is an example of a `.env` file:

```shell title=".env"
PORT=3000 # number
DATABASE_URL=mongodb://localhost:27017/mydatabase # string
JWT_SECRET=myverysecretkey # string
ENABLE_FEATURE_X=true # boolean
MAX_CONNECTIONS=100 # number
```

<br/>


### Best Practices
- **Security**: Never commit your `.env` file to version control. Add it
to your `.gitignore` file.
- **Defaults**: Provide sensible default values for environment variables
in your code.
- **Validation**: Validate the presence and format of critical environment
variables at the start of your application to avoid runtime errors.

1 change: 1 addition & 0 deletions docs/structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Top-level files are used to configure SherpaJS and manage the environment.
|---|---|
| [`sherpa.server.ts`](/build/server-config) | SherpaJS server config |
| [`sherpa.module.ts`](/build/module-config) | SherpaJS module config, *optional only if creating a module* |
| [`.env`](/build/miscellaneous#environment-variables) | Environment Varibles File |



Expand Down

0 comments on commit 52a5b68

Please sign in to comment.