From 4b0e2ea47515788020f1c4a02e4273e23f1f10d1 Mon Sep 17 00:00:00 2001 From: redwheelbarrow Date: Tue, 7 Oct 2025 13:02:41 -0600 Subject: [PATCH] Refactoring to create baseline --- .editorconfig | 8 ++ .gitattributes | 4 + .github/ISSUE_TEMPLATE/bug_report.md | 43 -------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ---- .github/code_of_conduct.md | 21 ---- .github/contributing.md | 8 -- .github/pull_request_template.md | 20 ---- .github/workflows/build.yml | 98 ------------------ .gitignore | 8 ++ .yarn/install-state.gz | Bin 0 -> 722 bytes .yarnrc.yml | 1 + README.md | 25 +++++ cli.js | 39 ------- package.json | 57 +--------- readme.md | 91 ---------------- {actions => src/actions}/batchGetItem.js | 0 {actions => src/actions}/batchWriteItem.js | 0 {actions => src/actions}/createTable.js | 0 {actions => src/actions}/deleteItem.js | 0 {actions => src/actions}/deleteTable.js | 0 {actions => src/actions}/describeTable.js | 0 .../actions}/describeTimeToLive.js | 0 {actions => src/actions}/getItem.js | 0 {actions => src/actions}/listTables.js | 0 .../actions}/listTagsOfResource.js | 0 {actions => src/actions}/putItem.js | 0 {actions => src/actions}/query.js | 0 {actions => src/actions}/scan.js | 0 {actions => src/actions}/tagResource.js | 0 {actions => src/actions}/untagResource.js | 0 {actions => src/actions}/updateItem.js | 0 {actions => src/actions}/updateTable.js | 0 {db => src/db}/conditionParser.js | 0 {db => src/db}/conditionParser.pegjs | 0 {db => src/db}/index.js | 0 {db => src/db}/lifecycle.js | 0 {db => src/db}/projectionParser.js | 0 {db => src/db}/projectionParser.pegjs | 0 {db => src/db}/updateParser.js | 0 {db => src/db}/updateParser.pegjs | 0 index.js => src/index.js | 15 ++- {ssl => src/ssl}/ca-crt.pem | 0 {ssl => src/ssl}/ca-key.pem | 0 {ssl => src/ssl}/server-crt.pem | 0 {ssl => src/ssl}/server-csr.pem | 0 {ssl => src/ssl}/server-key.pem | 0 {test => src/test}/batchGetItem.js | 0 {test => src/test}/batchWriteItem.js | 0 {test => src/test}/bench.js | 0 {test => src/test}/connection.js | 0 {test => src/test}/createTable.js | 0 {test => src/test}/deleteItem.js | 0 {test => src/test}/deleteTable.js | 0 {test => src/test}/describeTable.js | 0 {test => src/test}/describeTimeToLive.js | 0 {test => src/test}/getItem.js | 0 {test => src/test}/helpers.js | 0 {test => src/test}/listTables.js | 0 {test => src/test}/listTagsOfResource.js | 0 {test => src/test}/putItem.js | 0 {test => src/test}/query.js | 0 {test => src/test}/scan.js | 0 {test => src/test}/tagResource.js | 0 {test => src/test}/untagResource.js | 0 {test => src/test}/updateItem.js | 0 {test => src/test}/updateTable.js | 0 .../validations}/batchGetItem.js | 0 .../validations}/batchWriteItem.js | 0 .../validations}/createTable.js | 0 .../validations}/deleteItem.js | 0 .../validations}/deleteTable.js | 0 .../validations}/describeTable.js | 0 .../validations}/describeTimeToLive.js | 0 {validations => src/validations}/getItem.js | 0 {validations => src/validations}/index.js | 0 .../validations}/listTables.js | 0 .../validations}/listTagsOfResource.js | 0 {validations => src/validations}/putItem.js | 0 {validations => src/validations}/query.js | 0 {validations => src/validations}/scan.js | 0 .../validations}/tagResource.js | 0 .../validations}/untagResource.js | 0 .../validations}/updateItem.js | 0 .../validations}/updateTable.js | 0 yarn.lock | 12 +++ 85 files changed, 71 insertions(+), 399 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/code_of_conduct.md delete mode 100644 .github/contributing.md delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/build.yml create mode 100644 .yarn/install-state.gz create mode 100644 .yarnrc.yml create mode 100644 README.md delete mode 100755 cli.js delete mode 100644 readme.md rename {actions => src/actions}/batchGetItem.js (100%) rename {actions => src/actions}/batchWriteItem.js (100%) rename {actions => src/actions}/createTable.js (100%) rename {actions => src/actions}/deleteItem.js (100%) rename {actions => src/actions}/deleteTable.js (100%) rename {actions => src/actions}/describeTable.js (100%) rename {actions => src/actions}/describeTimeToLive.js (100%) rename {actions => src/actions}/getItem.js (100%) rename {actions => src/actions}/listTables.js (100%) rename {actions => src/actions}/listTagsOfResource.js (100%) rename {actions => src/actions}/putItem.js (100%) rename {actions => src/actions}/query.js (100%) rename {actions => src/actions}/scan.js (100%) rename {actions => src/actions}/tagResource.js (100%) rename {actions => src/actions}/untagResource.js (100%) rename {actions => src/actions}/updateItem.js (100%) rename {actions => src/actions}/updateTable.js (100%) rename {db => src/db}/conditionParser.js (100%) rename {db => src/db}/conditionParser.pegjs (100%) rename {db => src/db}/index.js (100%) rename {db => src/db}/lifecycle.js (100%) rename {db => src/db}/projectionParser.js (100%) rename {db => src/db}/projectionParser.pegjs (100%) rename {db => src/db}/updateParser.js (100%) rename {db => src/db}/updateParser.pegjs (100%) rename index.js => src/index.js (97%) rename {ssl => src/ssl}/ca-crt.pem (100%) rename {ssl => src/ssl}/ca-key.pem (100%) rename {ssl => src/ssl}/server-crt.pem (100%) rename {ssl => src/ssl}/server-csr.pem (100%) rename {ssl => src/ssl}/server-key.pem (100%) rename {test => src/test}/batchGetItem.js (100%) rename {test => src/test}/batchWriteItem.js (100%) rename {test => src/test}/bench.js (100%) rename {test => src/test}/connection.js (100%) rename {test => src/test}/createTable.js (100%) rename {test => src/test}/deleteItem.js (100%) rename {test => src/test}/deleteTable.js (100%) rename {test => src/test}/describeTable.js (100%) rename {test => src/test}/describeTimeToLive.js (100%) rename {test => src/test}/getItem.js (100%) rename {test => src/test}/helpers.js (100%) rename {test => src/test}/listTables.js (100%) rename {test => src/test}/listTagsOfResource.js (100%) rename {test => src/test}/putItem.js (100%) rename {test => src/test}/query.js (100%) rename {test => src/test}/scan.js (100%) rename {test => src/test}/tagResource.js (100%) rename {test => src/test}/untagResource.js (100%) rename {test => src/test}/updateItem.js (100%) rename {test => src/test}/updateTable.js (100%) rename {validations => src/validations}/batchGetItem.js (100%) rename {validations => src/validations}/batchWriteItem.js (100%) rename {validations => src/validations}/createTable.js (100%) rename {validations => src/validations}/deleteItem.js (100%) rename {validations => src/validations}/deleteTable.js (100%) rename {validations => src/validations}/describeTable.js (100%) rename {validations => src/validations}/describeTimeToLive.js (100%) rename {validations => src/validations}/getItem.js (100%) rename {validations => src/validations}/index.js (100%) rename {validations => src/validations}/listTables.js (100%) rename {validations => src/validations}/listTagsOfResource.js (100%) rename {validations => src/validations}/putItem.js (100%) rename {validations => src/validations}/query.js (100%) rename {validations => src/validations}/scan.js (100%) rename {validations => src/validations}/tagResource.js (100%) rename {validations => src/validations}/untagResource.js (100%) rename {validations => src/validations}/updateItem.js (100%) rename {validations => src/validations}/updateTable.js (100%) create mode 100644 yarn.lock diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..025dd8c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af3ad12 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/.yarn/** linguist-vendored +/.yarn/releases/* binary +/.yarn/plugins/**/* binary +/.pnp.* binary linguist-generated diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 862f69b..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve this project - ---- - -**Describe the issue** -A clear and concise description of the bug - - -**Steps to reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error that says '....' - - -**Expected behavior** -A clear and concise description of what you expected to happen - - -**Screenshots** -If applicable, add screenshots to help explain your problem - - -**Desktop** -Please complete the following information (if appropriate): - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - - -**Mobile** -Please complete the following information (if appropriate): - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - - -**Additional context** -Add any other context or notes about the problem here diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 42a21cb..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Software is never done! Suggest an idea to make this project even better - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. (Example: I find it frustrating when trying to _____ because _____...) - - -**Describe the solution you'd like** -A clear and concise description of what you'd like to happen. - - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. These are quite helpful! (Example: If it did _____ instead of _____, users would still have problems because _____...) - - -**Additional context or notes** -Add any other context or screenshots about the feature request here. diff --git a/.github/code_of_conduct.md b/.github/code_of_conduct.md deleted file mode 100644 index 1c4a1c4..0000000 --- a/.github/code_of_conduct.md +++ /dev/null @@ -1,21 +0,0 @@ -# Architect Code of Conduct - -We are strongly committed to ensuring the Architect community, and the various online and offline spaces in which its members congregate and collaborate, are safe, positive, inclusive, constructive, and welcoming environments. - -As such, the Architect project adheres to the [OpenJS Foundation Code of Conduct](https://github.com/openjs-foundation/cross-project-council/blob/main/CODE_OF_CONDUCT.md), which itself adheres to the [Contributor Covenant](https://www.contributor-covenant.org). - -Lack of familiarity with this or the OpenJS Foundation Codes of Conduct, or the Contributor covenant, is not an excuse for non-adherence. - - -# Reporting -If you are the subject of any behavior prohibited by this Code of Conduct, or observe someone who is, please contact an Architect team member immediately. - -If you know an Architect team member, you may wish to contact them personally (and you should); but if not, please [contact us via email](mailto:conduct@arc.codes). - -If possible, please attempt to collect any relevant information and evidence, including links, screenshots, or other recordings of any incident. - -Reports will be handled with the utmost care, confidence, and sensitivity towards the individual(s) reporting. - - -# Enforcement -Should incidents arise, upon adjudication those found to be in violation of this Code of Conduct may be immediately expelled from the Architect community, including events, forums, chat workspaces, code repositories, and any other place where Architect community members collaborate. diff --git a/.github/contributing.md b/.github/contributing.md deleted file mode 100644 index 6024d63..0000000 --- a/.github/contributing.md +++ /dev/null @@ -1,8 +0,0 @@ -# Contributing - -## First: go read the [Architect Code of Conduct](/.github/code_of_conduct.md) - -### Agreement to the Architect Code of Conduct -By participating in and contributing to the Architect community — including, but not limited to its open source projects, any related online venues such as GitHub, Slack, and in-person events, etc. — you agree to the [Architect Code of Conduct](/.github/code_of_conduct.md). - -Lack of familiarity with this Code of Conduct is not an excuse for not adhering to it. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 672e779..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,20 +0,0 @@ -## Thank you for helping out! ✨ - -### We really appreciate your commitment to improving Dynalite - -To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following: - -- [ ] Forked the repo and created your branch from `main` -- [ ] Made sure tests pass (run `npm it` from the repo root) -- [ ] Expanded test coverage related to your changes: - - [ ] Added and/or updated unit tests (if appropriate) - - [ ] Added and/or updated integration tests (if appropriate) -- [ ] Updated relevant documentation -- [ ] Summarized your changes in `changelog.md` -- [ ] Linked to any related issues, PRs, etc. below that may relate to, consume, or necessitate these changes - -Please also be sure to completed the CLA (if you haven't already). - -Learn more about [contributing to Architect here](https://arc.codes/intro/community). - -Thanks again! diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 2089d4d..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Node CI - -# Push tests pushes; PR tests merges -on: [ push, pull_request ] - -defaults: - run: - shell: bash - -jobs: - - # Test the build - build: - # Setup - runs-on: ${{ matrix.os }} - strategy: - matrix: - node-version: [ 20.x, 22.x, 24.x ] - os: [ windows-latest, ubuntu-latest, macOS-latest ] - - # Go - steps: - - name: Check out repo - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Env - run: | - echo "Event name: ${{ github.event_name }}" - echo "Git ref: ${{ github.ref }}" - echo "GH actor: ${{ github.actor }}" - echo "SHA: ${{ github.sha }}" - VER=`node --version`; echo "Node ver: $VER" - VER=`npm --version`; echo "npm ver: $VER" - - - name: Install - run: npm install - - - name: Test - run: npm test - env: - CI: true - - - name: Notify - uses: sarisia/actions-status-discord@v1 - # Only fire alert once - if: github.ref == 'refs/heads/main' && failure() && matrix.node-version == '14.x' && matrix.os == 'ubuntu-latest' - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - title: "build and test" - color: 0x222222 - username: GitHub Actions - - # ----- Only git tag testing + package publishing beyond this point ----- # - - # Publish to package registries - publish: - # Setup - needs: build - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - - # Go - steps: - - name: Check out repo - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: lts/* - registry-url: https://registry.npmjs.org/ - - # Publish to npm - - name: Publish @RC to npm - if: contains(github.ref, 'RC') - run: npm publish --tag RC - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Publish @latest to npm - if: contains(github.ref, 'RC') == false #'!contains()'' doesn't work lol - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Notify - uses: sarisia/actions-status-discord@v1 - if: always() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - title: "npm publish" - color: 0x222222 - username: GitHub Actions diff --git a/.gitignore b/.gitignore index bd3f9bb..515e307 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,11 @@ v8.log package-lock.json .nyc_output .kiro + +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions \ No newline at end of file diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz new file mode 100644 index 0000000000000000000000000000000000000000..ee696154c0bd11b9202463c9b305827559bc501a GIT binary patch literal 722 zcmV;@0xkU?iwFP!000001JzYcZyPrdwbd9&>O^tc9C|H*q8G#B*OJ`z%`t)=($;8l zFNU0q6yRJm-Yf06 zFRix3Q3oKffovorypbY+)CN#WGJsZtS4F@=X)cu2-a!N-WC^7&(UFo$6(N*G05CBW zUPlasPzr(CLR8$NPV7YoVF`2EiW;Tf-jKn%oci56Y=ok6UmMgFXNW)r3uV-rVfo%t09Qf4P9uyMK8o>;JT; zNIkXTpC`Z`-^bhuzu*^~J!_zyuVGHVjr}}cx63wtY}u1BH{WkMVvpYa{^mXVcK=>8 zXU`sn%Vl-M&N`z0`fKnZ>sK0J1Ydp4yf1v?>vl|;X*FSIO$y65bwjTg6qb3t8VwCD zqBlh-wUNP_7_2m?t#)Lj4@$^VfxzHVc^66Q!{@&+jwD$yCCqb4mQNmmH=JTL36Bm6ru&UV+b1>OxX(5V0P3${_q6?O;! E0H7pX6951J literal 0 HcmV?d00001 diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..86ac0d8 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: "pnpm" \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3722b24 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# shmynamo + +Gratefully forked from [dynalite](https://github.com/architect/dynalite). This version only provides an in-memory implementation of dynamo for fast and somewhat accurate testing. See the original repository for caveats around accuracy (ala dynamodb local). + +# Goals +1. Modern (typed, esm) +1. Accurate +1. Fast +1. No IO + + +## Example +```js +import { db, httpHandler } from 'shmynamo'; +import mitm from 'mitm'; + +const store = db.create() +const handler = httpHandler.bind(null, store) + +const httpIntercept = mitm(); +httpIntercept.on('request', handler); + +const dynamoClient = DynamoDBClient(); +await dynamoClient.send(new CreateTableCommand({...})) +``` \ No newline at end of file diff --git a/cli.js b/cli.js deleted file mode 100755 index e00d545..0000000 --- a/cli.js +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node - -var argv = require('minimist')(process.argv.slice(2), { alias: { debug: [ 'd' ], verbose: [ 'v' ] } }) - -if (argv.help || argv.h) { - - return console.log([ - '', - 'Usage: dynalite [--port ] [--path ] [options]', - '', - 'A DynamoDB http server, optionally backed by LevelDB', - '', - 'Options:', - '--help, -h Display this help message and exit', - '--host Listen on a specific host address (default: all available)', - '--port The port to listen on (default: 4567)', - '--path The path to use for the LevelDB store (in-memory by default)', - '--ssl Enable SSL for the web server (default: false)', - '--createTableMs Amount of time tables stay in CREATING state (default: 500)', - '--deleteTableMs Amount of time tables stay in DELETING state (default: 500)', - '--updateTableMs Amount of time tables stay in UPDATING state (default: 500)', - '--maxItemSizeKb Maximum item size (default: 400)', - '--verbose, -v Enable verbose logging', - '--debug, -d Enable debug logging', - '', - 'Report bugs at github.com/architect/dynalite/issues', - ].join('\n')) -} - -// If we're PID 1, eg in a docker container, SIGINT won't end the process as usual -if (process.pid == 1) process.on('SIGINT', process.exit) - -var server = require('./index.js')(argv) - .listen(argv.port || 4567, argv.host || undefined, function () { - var address = server.address(), protocol = argv.ssl ? 'https' : 'http' - - var host = argv.host || 'localhost' - console.log('Dynalite listening at: %s://%s:%s', protocol, host, address.port) - }) diff --git a/package.json b/package.json index a92a3a4..119f9c5 100644 --- a/package.json +++ b/package.json @@ -1,57 +1,4 @@ { - "name": "dynalite", - "version": "4.0.0", - "description": "An implementation of Amazon's DynamoDB built on LevelDB", - "homepage": "https://github.com/architect/dynalite", - "repository": { - "type": "git", - "url": "https://github.com/architect/dynalite" - }, - "bugs": "https://github.com/architect/dynalite/issues", - "main": "index.js", - "bin": "cli.js", - "scripts": { - "t": "mocha --require should --timeout 10000 test/listTables.js", - "build": "for file in ./db/*.pegjs; do pegjs \"$file\"; done", - "test": "npm run lint && mocha --require should --reporter spec -t $([ $REMOTE ] && echo 30s || echo 4s)", - "coverage": "npx nyc@latest mocha --require should -t 4s", - "lint": "eslint . --fix" - }, - "engines": { - "node": ">=20" - }, - "author": "Michael Hart ", - "license": "Apache-2.0", - "dependencies": { - "async": "^3.2.4", - "big.js": "^6.2.1", - "buffer-crc32": "^0.2.13", - "lazy": "^1.0.11", - "level": "^10.0.0", - "lock": "^1.1.0", - "memory-level": "^3.0.0", - "minimist": "^1.2.8", - "once": "^1.4.0" - }, - "devDependencies": { - "@architect/eslint-config": "^3.0.0", - "aws4": "^1.12.0", - "eslint": "^9.35.0", - "eslint-plugin-filenames": "^1.3.2", - "mocha": "^11.7.2", - "pegjs": "^0.10.0", - "should": "^13.2.3" - }, - "keywords": [ - "aws", - "amazon", - "cloud", - "dynamo", - "dynamodb", - "fake", - "leveldb", - "mock", - "serverless", - "test" - ] + "name": "shmynamo", + "packageManager": "yarn@4.9.4" } diff --git a/readme.md b/readme.md deleted file mode 100644 index bceb94b..0000000 --- a/readme.md +++ /dev/null @@ -1,91 +0,0 @@ -# dynalite - -[![GitHub CI status](https://github.com/architect/dynalite/workflows/Node%20CI/badge.svg)](https://github.com/architect/dynalite/actions?query=workflow%3A%22Node+CI%22) - -An implementation of Amazon's DynamoDB built on LevelDB -(well, [@rvagg](https://github.com/rvagg)'s awesome [LevelUP](https://github.com/Level/levelup) to be precise) -for fast in-memory or persistent usage. - -This project aims to match the live DynamoDB instances as closely as possible -(and is tested against them in various regions), including all limits and error messages. - -## What about Amazon's DynamoDB Local? - -This project was created before DynamoDB Local existed, and when it did, it differed a lot from the live instances -in ways that caused my company issues. Since then it's had a lot more development and resources thrown at it, -and is probably more up-to-date than dynalite is. I'd recommend using it over dynalite if you don't mind the -overhead of starting the JVM (or docker) each time. If you need a fast in-memory option that you can start up in -milliseconds, then dynalite might be more suitable for you. - -## Example - -```sh -$ dynalite --help - -Usage: dynalite [--port ] [--path ] [options] - -A DynamoDB http server, optionally backed by LevelDB - -Options: ---help, -h Display this help message and exit ---host Listen on a specific host address (default: all available) ---port The port to listen on (default: 4567) ---path The path to use for the LevelDB store (in-memory by default) ---ssl Enable SSL for the web server (default: false) ---createTableMs Amount of time tables stay in CREATING state (default: 500) ---deleteTableMs Amount of time tables stay in DELETING state (default: 500) ---updateTableMs Amount of time tables stay in UPDATING state (default: 500) ---maxItemSizeKb Maximum item size (default: 400) ---verbose, -v Enable verbose logging ---debug, -d Enable debug logging - -Report bugs at github.com/architect/dynalite/issues -``` - -Or programmatically: - -```js -// Returns a standard Node.js HTTP server -var dynalite = require('dynalite') -var dynaliteServer = dynalite({ path: './mydb', createTableMs: 50 }) - -// Listen on port 4567 -dynaliteServer.listen(4567, function(err) { - if (err) throw err - console.log('Dynalite started on port 4567') -}) -``` - -Once running, here's how you use the [AWS SDK](https://github.com/aws/aws-sdk-js) to connect -(after [configuring the SDK](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/configuring-the-jssdk.html)): - -```js -var AWS = require('aws-sdk') - -var dynamo = new AWS.DynamoDB({ endpoint: 'http://localhost:4567' }) - -dynamo.listTables(console.log.bind(console)) -``` - -## Installation - -With [npm](https://www.npmjs.com/), to install the CLI: - -```sh -npm install -g dynalite -``` - -Or to install for development/testing in your project: - -```sh -npm install -D dynalite -``` - -## TODO - -- Implement [Transactions](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis.html) -- Implement DynamoDB Streams -- Implement `ReturnItemCollectionMetrics` on all remaining endpoints -- Implement size info for tables and indexes -- Add ProvisionedThroughput checking -- See [open issues on GitHub](https://github.com/architect/dynalite/issues) for any further TODOs diff --git a/actions/batchGetItem.js b/src/actions/batchGetItem.js similarity index 100% rename from actions/batchGetItem.js rename to src/actions/batchGetItem.js diff --git a/actions/batchWriteItem.js b/src/actions/batchWriteItem.js similarity index 100% rename from actions/batchWriteItem.js rename to src/actions/batchWriteItem.js diff --git a/actions/createTable.js b/src/actions/createTable.js similarity index 100% rename from actions/createTable.js rename to src/actions/createTable.js diff --git a/actions/deleteItem.js b/src/actions/deleteItem.js similarity index 100% rename from actions/deleteItem.js rename to src/actions/deleteItem.js diff --git a/actions/deleteTable.js b/src/actions/deleteTable.js similarity index 100% rename from actions/deleteTable.js rename to src/actions/deleteTable.js diff --git a/actions/describeTable.js b/src/actions/describeTable.js similarity index 100% rename from actions/describeTable.js rename to src/actions/describeTable.js diff --git a/actions/describeTimeToLive.js b/src/actions/describeTimeToLive.js similarity index 100% rename from actions/describeTimeToLive.js rename to src/actions/describeTimeToLive.js diff --git a/actions/getItem.js b/src/actions/getItem.js similarity index 100% rename from actions/getItem.js rename to src/actions/getItem.js diff --git a/actions/listTables.js b/src/actions/listTables.js similarity index 100% rename from actions/listTables.js rename to src/actions/listTables.js diff --git a/actions/listTagsOfResource.js b/src/actions/listTagsOfResource.js similarity index 100% rename from actions/listTagsOfResource.js rename to src/actions/listTagsOfResource.js diff --git a/actions/putItem.js b/src/actions/putItem.js similarity index 100% rename from actions/putItem.js rename to src/actions/putItem.js diff --git a/actions/query.js b/src/actions/query.js similarity index 100% rename from actions/query.js rename to src/actions/query.js diff --git a/actions/scan.js b/src/actions/scan.js similarity index 100% rename from actions/scan.js rename to src/actions/scan.js diff --git a/actions/tagResource.js b/src/actions/tagResource.js similarity index 100% rename from actions/tagResource.js rename to src/actions/tagResource.js diff --git a/actions/untagResource.js b/src/actions/untagResource.js similarity index 100% rename from actions/untagResource.js rename to src/actions/untagResource.js diff --git a/actions/updateItem.js b/src/actions/updateItem.js similarity index 100% rename from actions/updateItem.js rename to src/actions/updateItem.js diff --git a/actions/updateTable.js b/src/actions/updateTable.js similarity index 100% rename from actions/updateTable.js rename to src/actions/updateTable.js diff --git a/db/conditionParser.js b/src/db/conditionParser.js similarity index 100% rename from db/conditionParser.js rename to src/db/conditionParser.js diff --git a/db/conditionParser.pegjs b/src/db/conditionParser.pegjs similarity index 100% rename from db/conditionParser.pegjs rename to src/db/conditionParser.pegjs diff --git a/db/index.js b/src/db/index.js similarity index 100% rename from db/index.js rename to src/db/index.js diff --git a/db/lifecycle.js b/src/db/lifecycle.js similarity index 100% rename from db/lifecycle.js rename to src/db/lifecycle.js diff --git a/db/projectionParser.js b/src/db/projectionParser.js similarity index 100% rename from db/projectionParser.js rename to src/db/projectionParser.js diff --git a/db/projectionParser.pegjs b/src/db/projectionParser.pegjs similarity index 100% rename from db/projectionParser.pegjs rename to src/db/projectionParser.pegjs diff --git a/db/updateParser.js b/src/db/updateParser.js similarity index 100% rename from db/updateParser.js rename to src/db/updateParser.js diff --git a/db/updateParser.pegjs b/src/db/updateParser.pegjs similarity index 100% rename from db/updateParser.pegjs rename to src/db/updateParser.pegjs diff --git a/index.js b/src/index.js similarity index 97% rename from index.js rename to src/index.js index e2408c2..e131645 100644 --- a/index.js +++ b/src/index.js @@ -20,6 +20,8 @@ var validApis = [ 'DynamoDB_20111205', 'DynamoDB_20120810' ], actionValidations = {} module.exports = dynalite +module.exports.db = db +module.exports.httpHandler = httpHandler /** * @param {Object} options - The shape is the same as SpecialType above @@ -29,16 +31,21 @@ module.exports = dynalite * @param {string} [options.key] - SSL private key - if omitted and ssl enabled, self-signed cert will be used * @param {string} [options.cert] - SSL certificate - if omitted and ssl enabled, self-signed cert will be used * @param {string} [options.ca] - SSL certificate authority - if omitted and ssl enabled, self-signed cert will be used - * @param {number} [options.createTableMs=500] - Amount of time tables stay in CREATING state - * @param {number} [options.deleteTableMs=500] - Amount of time tables stay in DELETING state - * @param {number} [options.updateTableMs=500] - Amount of time tables stay in UPDATING state + * @param {number} [options.createTableMs=0] - Amount of time tables stay in CREATING state + * @param {number} [options.deleteTableMs=0] - Amount of time tables stay in DELETING state + * @param {number} [options.updateTableMs=0] - Amount of time tables stay in UPDATING state * @param {number} [options.maxItemSizeKb=400] - Maximum item size * @param {string} [options.path] - The path to use for the LevelDB store (in-memory by default) * * @returns {http.Server | https.Server} - The Dynalite server */ function dynalite (options) { - options = options || {} + options = { + createTableMs: 0, + updateTableMs: 0, + deleteTableMs: 0, + ...(options || {}), + } if (options.verbose) verbose = true if (options.debug) debug = true diff --git a/ssl/ca-crt.pem b/src/ssl/ca-crt.pem similarity index 100% rename from ssl/ca-crt.pem rename to src/ssl/ca-crt.pem diff --git a/ssl/ca-key.pem b/src/ssl/ca-key.pem similarity index 100% rename from ssl/ca-key.pem rename to src/ssl/ca-key.pem diff --git a/ssl/server-crt.pem b/src/ssl/server-crt.pem similarity index 100% rename from ssl/server-crt.pem rename to src/ssl/server-crt.pem diff --git a/ssl/server-csr.pem b/src/ssl/server-csr.pem similarity index 100% rename from ssl/server-csr.pem rename to src/ssl/server-csr.pem diff --git a/ssl/server-key.pem b/src/ssl/server-key.pem similarity index 100% rename from ssl/server-key.pem rename to src/ssl/server-key.pem diff --git a/test/batchGetItem.js b/src/test/batchGetItem.js similarity index 100% rename from test/batchGetItem.js rename to src/test/batchGetItem.js diff --git a/test/batchWriteItem.js b/src/test/batchWriteItem.js similarity index 100% rename from test/batchWriteItem.js rename to src/test/batchWriteItem.js diff --git a/test/bench.js b/src/test/bench.js similarity index 100% rename from test/bench.js rename to src/test/bench.js diff --git a/test/connection.js b/src/test/connection.js similarity index 100% rename from test/connection.js rename to src/test/connection.js diff --git a/test/createTable.js b/src/test/createTable.js similarity index 100% rename from test/createTable.js rename to src/test/createTable.js diff --git a/test/deleteItem.js b/src/test/deleteItem.js similarity index 100% rename from test/deleteItem.js rename to src/test/deleteItem.js diff --git a/test/deleteTable.js b/src/test/deleteTable.js similarity index 100% rename from test/deleteTable.js rename to src/test/deleteTable.js diff --git a/test/describeTable.js b/src/test/describeTable.js similarity index 100% rename from test/describeTable.js rename to src/test/describeTable.js diff --git a/test/describeTimeToLive.js b/src/test/describeTimeToLive.js similarity index 100% rename from test/describeTimeToLive.js rename to src/test/describeTimeToLive.js diff --git a/test/getItem.js b/src/test/getItem.js similarity index 100% rename from test/getItem.js rename to src/test/getItem.js diff --git a/test/helpers.js b/src/test/helpers.js similarity index 100% rename from test/helpers.js rename to src/test/helpers.js diff --git a/test/listTables.js b/src/test/listTables.js similarity index 100% rename from test/listTables.js rename to src/test/listTables.js diff --git a/test/listTagsOfResource.js b/src/test/listTagsOfResource.js similarity index 100% rename from test/listTagsOfResource.js rename to src/test/listTagsOfResource.js diff --git a/test/putItem.js b/src/test/putItem.js similarity index 100% rename from test/putItem.js rename to src/test/putItem.js diff --git a/test/query.js b/src/test/query.js similarity index 100% rename from test/query.js rename to src/test/query.js diff --git a/test/scan.js b/src/test/scan.js similarity index 100% rename from test/scan.js rename to src/test/scan.js diff --git a/test/tagResource.js b/src/test/tagResource.js similarity index 100% rename from test/tagResource.js rename to src/test/tagResource.js diff --git a/test/untagResource.js b/src/test/untagResource.js similarity index 100% rename from test/untagResource.js rename to src/test/untagResource.js diff --git a/test/updateItem.js b/src/test/updateItem.js similarity index 100% rename from test/updateItem.js rename to src/test/updateItem.js diff --git a/test/updateTable.js b/src/test/updateTable.js similarity index 100% rename from test/updateTable.js rename to src/test/updateTable.js diff --git a/validations/batchGetItem.js b/src/validations/batchGetItem.js similarity index 100% rename from validations/batchGetItem.js rename to src/validations/batchGetItem.js diff --git a/validations/batchWriteItem.js b/src/validations/batchWriteItem.js similarity index 100% rename from validations/batchWriteItem.js rename to src/validations/batchWriteItem.js diff --git a/validations/createTable.js b/src/validations/createTable.js similarity index 100% rename from validations/createTable.js rename to src/validations/createTable.js diff --git a/validations/deleteItem.js b/src/validations/deleteItem.js similarity index 100% rename from validations/deleteItem.js rename to src/validations/deleteItem.js diff --git a/validations/deleteTable.js b/src/validations/deleteTable.js similarity index 100% rename from validations/deleteTable.js rename to src/validations/deleteTable.js diff --git a/validations/describeTable.js b/src/validations/describeTable.js similarity index 100% rename from validations/describeTable.js rename to src/validations/describeTable.js diff --git a/validations/describeTimeToLive.js b/src/validations/describeTimeToLive.js similarity index 100% rename from validations/describeTimeToLive.js rename to src/validations/describeTimeToLive.js diff --git a/validations/getItem.js b/src/validations/getItem.js similarity index 100% rename from validations/getItem.js rename to src/validations/getItem.js diff --git a/validations/index.js b/src/validations/index.js similarity index 100% rename from validations/index.js rename to src/validations/index.js diff --git a/validations/listTables.js b/src/validations/listTables.js similarity index 100% rename from validations/listTables.js rename to src/validations/listTables.js diff --git a/validations/listTagsOfResource.js b/src/validations/listTagsOfResource.js similarity index 100% rename from validations/listTagsOfResource.js rename to src/validations/listTagsOfResource.js diff --git a/validations/putItem.js b/src/validations/putItem.js similarity index 100% rename from validations/putItem.js rename to src/validations/putItem.js diff --git a/validations/query.js b/src/validations/query.js similarity index 100% rename from validations/query.js rename to src/validations/query.js diff --git a/validations/scan.js b/src/validations/scan.js similarity index 100% rename from validations/scan.js rename to src/validations/scan.js diff --git a/validations/tagResource.js b/src/validations/tagResource.js similarity index 100% rename from validations/tagResource.js rename to src/validations/tagResource.js diff --git a/validations/untagResource.js b/src/validations/untagResource.js similarity index 100% rename from validations/untagResource.js rename to src/validations/untagResource.js diff --git a/validations/updateItem.js b/src/validations/updateItem.js similarity index 100% rename from validations/updateItem.js rename to src/validations/updateItem.js diff --git a/validations/updateTable.js b/src/validations/updateTable.js similarity index 100% rename from validations/updateTable.js rename to src/validations/updateTable.js diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..9e7b314 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,12 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10c0 + +"shmynamo@workspace:.": + version: 0.0.0-use.local + resolution: "shmynamo@workspace:." + languageName: unknown + linkType: soft