Skip to content

Commit

Permalink
Merge f007e1e into a6c1bf2
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcharlie committed Apr 23, 2020
2 parents a6c1bf2 + f007e1e commit 1df8160
Show file tree
Hide file tree
Showing 17 changed files with 434 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@


### Other:
- [ ] I have read through and followed the Contributing Guidelines
- [ ] I have searched through the GitHub pull requests to ensure this PR has not already been submitted
- [ ] I have updated the Dynamoose documentation (if required) given the changes I made
- [ ] I have added/updated the Dynamoose test cases (if required) given the changes I made
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,31 @@ jobs:
# env:
# TAG: ${{ needs.getinfo.outputs.npmtag }}
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publishsite:
needs: getinfo
runs-on: ubuntu-latest
if: needs.getinfo.outputs.npmtag == 'latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm run site:install
- run: npm run site:build
- uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --follow-symlinks --delete --cache-control 's-maxage=604800, max-age=0'
env:
AWS_S3_BUCKET: ${{ secrets.AWS_SITE_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: 'docs/build'
- name: Purge Cloudflare Cache
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE/purge_cache" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
env:
TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team [here](https://charlie.fish/contact). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Contributing to Dynamoose

:+1::tada: **THANK YOU** for taking the time to contribute! :tada::+1:

The following is a set of guidelines for contributing to Dynamoose and all projects in the [dynamoosejs Organization](https://github.com/dynamoosejs) on GitHub. Although these are strongly encouraged guidelines, nothing about this project is set in stone, if you believe something here should be edited, open a PR to start a discussion about it.

## Code of Conduct

This project and everyone participating in it is governed by the [Dynamoose Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to the contact method in the [Code of Conduct](CODE_OF_CONDUCT.md).

## What should I know before I get started?

### Documentation

All of the documentation for the project is housed within the `docs/docs` folder. The general website is housed within the `docs` folder. It is important while contributing to Dynamoose to ensure that the documentation is complete, up to date, and helpful.

### Resources

It is highly encouraged to read through the following resources before contributing.

- [README](README.md)
- [Website](https://dynamoosejs.com)

## How Can I Contribute?

### Reporting Bugs

When reporting bugs please fill out the issue template with as much detail as possible. If you do not fill out the issue template with enough detail for us to debug your issue, your issue is at risk for being closed.

#### Minimal, Complete and Verifiable Example (MCVE)

One of the most important things when submitting an issue is to provide a *Minimal, Complete and Verifiable Example* (or MCVE for short). If you are reporting a bug it is important for us to be able to test and debug your code as quickly as possible.

- *Minimal* – Use as little code as possible that still produces the same problem
- *Complete* – Provide all parts needed to reproduce your problem
- *Reproducible* – Test the code to make sure it reproduces the problem

Without following these steps when creating code examples it is nearly impossible for us to debug your issue. Help us help you by putting time and care into code examples. Not following this guideline puts your issue at risk for being closed.

### Submitting a PR

It is highly recommended (although not required) to follow the pattern below before submitting a PR. Not every step below will be relevant to all PRs.

#### Before

1. **Identify a need in the project** - This can be a bug, feature request, or other change.
2. **Create a detailed issue to gauge interest** - Although most PRs are merged, we don't want you to waste time creating a PR that doesn't have the support of the community. *Please not this step is highly encouraged for larger contributions, but not required. For smaller contributions (typos, adding tests, updating documentaion, minor code changes, etc.) it is not necessary to create a seperate issue.*
3. **Read through the `package.json`** - The `package.json` file in the root of the repository has a **lot** of useful information about the project. Especially read through the scripts section, as a lot of those scripts can help speed up your development process when working in Dynamoose.

#### During

1. **Create a fork & branch** - Before contributing to Dynamoose you must create a fork of the [main repository](https://github.com/dynamoosejs/dynamoose) and create a branch on your fork. It is highly discouraged from using a primary branch (ex. `master` or `alpha`) to make your changes. This is due to the fact that if you enable `Allow edits from maintainers` option, maintainers might commit directly to your primary branch which could cause problems if others are using your fork in their applications.
2. **Install dependencies** - Run `npm install` to install all the dependencies of the project.
3. **Maintain consistency throughout** - While working in the project, we highly encourage you to maintain the same coding style that the rest of the project uses. This means looking around at similar code and trying to adopt the same style and conventions in your code.
4. **Run tests & linter often** - It is highly encouraged to run `npm test` & `npm run lint` often to ensure you are conforming to the project guidelines. In order for a PR to be merged all tests must pass, the linter must throw no errors, and code coverage must not decrease.
5. **Write tests** - While (or better yet, before) making changes you should write tests in the test suite to ensure things work as expected. While writing tests try to consider edge cases that might occur and write test for those edge cases (ex. what happens if you a user passes in no arguments, or what happens if the type passed in is not the type you expect).
6. **Update documentation** - It is encouraged throughout
7. **Commit small & often** - Please commit changes often and keep commit size to a minimum. It is highly discouraged from creating one massive commit with all of your changes in it. Every commit should also aim to pass the linter and tests. Commit messages should also be detailed enough to give a good explaination of the change made. Commit messages such as `changes` or `did stuff` are considered **poor** commit messages.

#### After

1. **Submit the PR** - When submitting the PR it is important to fill out the complete PR template. This ensures reviewers of your PR can easily understand what is going on and make sure all guidelines and requirements have been met. It is also highly recommended to enable the `Allow edits from maintainers` option (be aware that enabling this option means that maintainers have the right to commit to your branch at any time, *we do use this ability*).
2. **Be prepared for questions and suggestions** - As others review your PR it is important to be available to answer questions and promptly respond to code suggestions. Stale PRs run the risk of being closed, even if it's a large change or a lot of effort was put into it.
3. **Ask others for reviews** - If you know someone who is anticipating your work, ask them to test your branch and leave a detailed review on the PR.

#### Release

Dynamoose does not currently have a release schedule that we conform to. We atttempt to batch work into a release every so often. If you have a need that requires us releasing a version sooner, please notify us, and we will attempt to cut a new release earlier (however this is not guaranteed, and you are still welcome to point to a branch in NPM if we are unable to release on your timeline).
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,33 @@

---

# Dynamoose Version 2.0 is still In Development. Please [contact me](https://charlie.fish/contact) with any feedback or questions.
Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by [Mongoose](https://mongoosejs.com/)).

Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by [Mongoose](https://mongoosejs.com/))
### Getting Started

Take a look at our [website](https://dynamoosejs.com) for information about how to get started.

## Getting Started
### Resources

### Installation
#### General

```sh
$ npm i dynamoose@beta
```
- [Website](https://dynamoosejs.com)
- [Contributing Guide](CONTRIBUTING.md)
- [Code of Conduct](CODE_OF_CONDUCT.md)
- [Changelog](CHANGELOG.md)
- [License](LICENSE)

## Documentation
#### Social

- [v2](https://github.com/dynamoosejs/dynamoose/tree/master/docs)
- [v1](https://dynamoosejs.com)
- [Slack](https://join.slack.com/t/dynamoose/shared_invite/enQtODM4OTI0MTc1NDc3LWI3MmNhMThmNmJmZDk5MmUxOTZmMGEwNGQzNTRkMjhjZGJlNGM5M2JmZjMzMzlkODRhMGY3MTQ5YjQ2Nzg3YTY)
- [Twitter](https://twitter.com/DynamooseJS)

### Branch Strategy

Below you will find the current branch strategy for the project. Work taking place on the branches listed below might be further ahead than the versions on NPM. All documentation links found below will also be reflective of the published version on NPM. If you would like to live dangouragely and run non released versions, you can run `npm install dynamoosejs/dynamoose#BRANCH` (replacing `BRANCH` with the branch listed below). You will also find the most up to date documentation in the `docs` folder of the branch.

| Branch | Version | NPM Tag | Links |
| --- | --- | --- | --- |
| [`v1.11.1`](https://github.com/dynamoosejs/dynamoose/tree/v1.11.1) (tag) | 1.11.1 | latest | - [Documentation](https://v1.dynamoosejs.com) |
| [`master`](https://github.com/dynamoosejs/dynamoose/tree/master) | 2.0.0 | beta | - [Documentation](https://github.com/dynamoosejs/dynamoose/tree/master/docs/docs)<br>- [Issue](https://github.com/dynamoosejs/dynamoose/issues/709) |
| [`alpha`](https://github.com/dynamoosejs/dynamoose/tree/alpha) | 2.1.0 | alpha | - [Documentation](https://github.com/dynamoosejs/dynamoose/tree/alpha/docs/docs)<br>- [Issue](https://github.com/dynamoosejs/dynamoose/issues/788) |
8 changes: 0 additions & 8 deletions docs/docs/api/General.md → docs/docs/api/Dynamoose.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
You can access Dynamoose by requiring the library. For example:

```js
const dynamoose = require("dynamoose");
```

The Dynamoose object is the entry point to everything you will do with this package.

## dynamoose.aws

The `dynamoose.aws` object is used to set AWS level settings for Dynamoose. This includes things like setting a custom DDB instance, setting the AWS region, access keys, and more.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/Transaction.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DynamoDB supports running transactions in your database. These transactions are all or nothing, meaning the entire transaction will succeed, or the entire transaction will fail. In the event the transaction fails, the state of the database will be the exact same as if the transaction didn't take place at all.
DynamoDB supports running transactions in your database(s). These transactions are all or nothing, meaning the entire transaction will succeed, or the entire transaction will fail. In the event the transaction fails, the state of the database will be the exact same as if the transaction didn't take place at all (ex. no documents will have been modified).

## dynamoose.transaction(transactions[, settings][, callback])

Expand Down
67 changes: 67 additions & 0 deletions docs/docs/getting_started/Configure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Dynamoose interacts directly with the [AWS-SDK](https://www.npmjs.com/package/aws-sdk), therefore, it is required that you authenticate and provide valid credentials so Dynamoose can successfully make requests to DynamoDB.

It is recommended that you do this as early in the application life cycle as possible to prevent issues where Dynamoose will try to make requests to DynamoDB that are unauthenticated.

There are a few ways to do this.

## Environment Variables

You can use environment variables to setup your configuration.

```bash
export AWS_ACCESS_KEY_ID = "Your AWS Access Key ID"
export AWS_SECRET_ACCESS_KEY = "Your AWS Secret Access Key"
export AWS_REGION = "us-east-1"
```

## Programatically

### Global

The following code will change the AWS-SDK global settings to use the configuration options.

```js
dynamoose.aws.sdk.config.update({
"accessKeyId": "AKID",
"secretAccessKey": "SECRET",
"region": "us-east-1"
});
```

### Dynamoose Specific

The following code will create a new DynamoDB instance with the specific configuration options and use that in Dynamoose.

```js
// Create new DynamoDB instance
const ddb = new dynamoose.aws.sdk.DynamoDB({
"accessKeyId": "AKID",
"secretAccessKey": "SECRET",
"region": "us-east-1"
});

// Set DynamoDB instance to the Dynamoose DDB instance
dynamoose.aws.ddb.set(ddb);
```

## IAM Role

If you are running Dynamoose in an environment that has an IAM role attached to it (ex. [Lambda](https://aws.amazon.com/lambda/) or [EC2](https://aws.amazon.com/ec2/)), you do not need to do any additional configuration so long as your IAM role has appropriate permissions to access DynamoDB.

## Local

You can also configure Dynamoose to use [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html).

If your DynamoDB Local server is running on `http://localhost:8000` you can use the following command.

```js
dynamoose.aws.ddb.local();
```

Otherwise if your local DynamoDB server is running at a different location you can pass that in as an argument. For example if your server is running at `http://localhost:1234` you can run the following command.

```js
dynamoose.aws.ddb.local("http://localhost:1234");
```

Read more about this method [here](/api/Dynamoose#dynamooseawsddblocalendpoint).
27 changes: 27 additions & 0 deletions docs/docs/getting_started/Import.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

In order to use Dynamoose you must import it or require it in your project. This will make the `dynamoose` namespace accessible so you can use things like models, schemas, and more.

<Tabs
defaultValue="commonjs"
values={[
{"label": "CommonJS", value: "commonjs"},
{"label": "ES Modules", value: "esmodules"},
]
}>
<TabItem value="commonjs">

```js
const dynamoose = require("dynamoose");
```

</TabItem>
<TabItem value="esmodules">

```js
import { dynamoose } from "dynamoose";
```

</TabItem>
</Tabs>
23 changes: 23 additions & 0 deletions docs/docs/getting_started/Install.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Standard

To install Dynamoose you can run the following command.

```bash npm2yarn
npm install --save dynamoose
```

## Prerelease

At times we will also have prerelease versions of Dynamoose that you can install. An example of this would be the following command.

```bash npm2yarn
npm install --save dynamoose@beta
```

## Branch

You can also install Dynamoose from a specific branch.

```bash npm2yarn
npm install --save dynamoosejs/dynamoose#master
```
15 changes: 15 additions & 0 deletions docs/docs/getting_started/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Description

Dynamoose is a modeling tool for Amazon's DynamoDB. Dynamoose is heavily inspired by [Mongoose](https://mongoosejs.com/), which means if you are coming from Mongoose the syntax will be very familar.

## Key Features

- Type safety
- High level API
- Easy to use syntax
- Ability to transform data before saving or retrieving documents
- Strict data modeling (validation, required attributes, and more)
- Support for DynamoDB Transactions
- Powerful Conditional/Filtering Support
- Callback & Promise support
- And <span style={{ "color": "#1b62d4", "fontSize": "18px" }}>**MANY**</span> more
Loading

0 comments on commit 1df8160

Please sign in to comment.