forked from SummerOfCode2020/week-17-store-manager-api-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
update documentation #18
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,32 +2,45 @@ | |||||
|
|
||||||
| [](https://github.com/pakeku/backend-api/actions/workflows/tests.yml) | ||||||
| [](https://snyk.io/test/github/pakeku/backend-api) | ||||||
|
|
||||||
| ## Requirements | ||||||
|
|
||||||
| Identify your MongoDB URL. Visit MongoDB to sign up and get started. | ||||||
|
|
||||||
| Environmental Variables: | ||||||
|
|
||||||
| 1. MONGO_URL | ||||||
| 2. PORT (optional) | ||||||
| 3. ALLOWED_ORIGINS (optional) | ||||||
| 4. ALLOWED_METHODS (optional) | ||||||
| 5. ALLOWED_HEADERS (optional) | ||||||
| 6. NODE_ENV=test --- When set to "test", a `mongodb-memory-server` test URI is used, and no `MONGO_URL` is required. This allows for out-of-the-box testing without a live database. | ||||||
| 7. JWT_SECRET --- A cryptographically secure secret used to sign and verify JSON Web Tokens (JWTs). This is required for authentication to work correctly. | ||||||
| Use a long, random string—at least 32 characters, ideally generated using a password manager or Node.js: `bash node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"` | ||||||
| 8. | ||||||
| [](https://prettier.io/) | ||||||
| [](https://eslint.org/) | ||||||
| [](https://www.typescriptlang.org/) | ||||||
|
|
||||||
| ## Configuration | ||||||
|
|
||||||
| This backend API is configured using environment variables. You can set these variables in a `.env` file in the root of the project (copy `.env.sample` to `.env` and modify the values). **Important: Ensure your `.env` file is not committed to your version control system.** | ||||||
|
|
||||||
| The following environment variables are used: | ||||||
|
|
||||||
| - `MONGO_URL`: **Required.** The connection string for your MongoDB database. You can obtain this from your MongoDB provider (e.g., MongoDB Atlas). Example: `mongodb+srv://<username>:<password>@<cluster-url>/<database-name>?retryWrites=true&w=majority` | ||||||
| - `PORT`: **Optional.** The port number that the Express server will listen on. If not specified, it defaults to `3000`. Example: `8080` | ||||||
| - `ALLOWED_ORIGINS`: **Optional.** A comma-separated list of allowed origins for Cross-Origin Resource Sharing (CORS). This controls which websites can make requests to your API. Example: `http://localhost:3000,https://your-frontend.com` | ||||||
| - `ALLOWED_METHODS`: **Optional.** A comma-separated list of allowed HTTP methods for CORS. Example: `GET,POST,PUT,DELETE` | ||||||
| - `ALLOWED_HEADERS`: **Optional.** A comma-separated list of allowed request headers for CORS. Example: `Content-Type,Authorization` | ||||||
| - `NODE_ENV`: Specifies the application environment. | ||||||
| - `test`: When set to `test`, the application will use an in-memory MongoDB server provided by `mongodb-memory-server` for testing purposes. In this mode, the `MONGO_URL` variable is not required. | ||||||
| - `development`: Typically used during development. You might have specific development configurations. | ||||||
| - `production`: Used in the production environment. | ||||||
| - `JWT_SECRET`: **Required and Critically Important.** A secret key used to sign and verify JSON Web Tokens (JWTs) for authentication. **This should be a long, random, and secure string. Do not share or expose this secret.** | ||||||
| ```bash | ||||||
| node -e "console.log(require('crypto').randomBytes(64).toString('hex'))" | ||||||
| ``` | ||||||
|
|
||||||
| ## Getting Started | ||||||
|
|
||||||
| 1. Copy this file to .env and fill in the actual values | ||||||
| Copy this file to .env and fill in the actual values | ||||||
|
|
||||||
| ```bash | ||||||
| cp .env.sample .env | ||||||
| ``` | ||||||
|
|
||||||
| 1. Run a script: | ||||||
| Install Dependencies | ||||||
|
||||||
| Install Dependencies | |
| ### Install Dependencies |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The Getting Started steps are no longer numbered or bulleted, which may confuse readers. Consider adding numbering or bullet points for consistency.