Skip to content

Commit

Permalink
feat(release): update adc5d79
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Mar 13, 2024
1 parent 36a9799 commit cf321c0
Show file tree
Hide file tree
Showing 100 changed files with 10,569 additions and 2,241 deletions.
7 changes: 5 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
NODE_ENV=
NODE_ENV=test
PAYMENT_SERVICE_BASE_URL=
ALLOW_LISTED_ADDRESSES=
PRIVATE_ROUTE_SECRET=
MIGRATE_ON_STARTUP=
MIGRATE_ON_STARTUP=false
DB_PASSWORD=postgres
DB_WRITER_ENDPOINT=localhost
DB_READER_ENDPOINT=locahost
29 changes: 27 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "header"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"no-console": 1,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"argsIgnorePattern": "^_", // Ignore variables starting with an underscore
"ignoreRestSiblings": true
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-use-before-define": [
"error",
{
"functions": false,
"classes": false,
"variables": true,
"allowNamedExports": false
}
],
"header/header": [2, "./resources/license.header.js"]
},
"ignorePatterns": [
Expand All @@ -15,6 +37,9 @@
"bundle-jobs.cjs",
"scripts",
"package.json",
"testWallet.json"
"testWallet.json",
"irys",
"tsconfig.*",
"tests/stubFiles/*"
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# env files
.env
.env*

# Coverage and nyc_output directories used by tools like istanbul
coverage
Expand Down
4 changes: 3 additions & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

process.env.NODE_ENV ??= "test";
process.env.PORT ??= 1234;
process.env.ARWEAVE_GATEWAY ??= "http://arlocal:1984";
process.env.ARWEAVE_GATEWAY ??= "http://localhost:1984";
process.env.BLOCKLISTED_ADDRESSES ??= // cspell:disable
"xnbLpqfiRIInqrxkhV7M-iSr8YUtm9aoezGjSnXnOFo"; // cspell:enable

// Mocha configuration file
// Reference for options: https://github.com/mochajs/mocha/blob/master/example/config/.mocharc.js
Expand Down
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"terminal.integrated.scrollback": 10000,
"typescript.preferences.importModuleSpecifier": "relative",
"cSpell.words": [
"alexsasharegan",
Expand All @@ -11,16 +12,27 @@
"arlocal",
"avsc",
"Backoff",
"bdis",
"bignumber",
"blocklisted",
"bundlr",
"dataitem",
"indep",
"indexdef",
"indexname",
"INJECTEDAPTOS",
"Irys",
"knexfile",
"MULTIAPTOS",
"multistream",
"NOWAIT",
"nvmrc",
"openapi",
"opentelemetry",
"Opticalized",
"oracledb",
"otel",
"otlp",
"outdir",
"Readables",
"schemaname",
Expand All @@ -32,6 +44,7 @@
"throughputs",
"trivago",
"typecheck",
"TYPEDETHEREUM",
"unbundle",
"unbundling",
"Winc",
Expand Down
File renamed without changes.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ Developers can alternatively use `yarn start:watch` to run the app in developmen

### Scripts

- `db:up`: Starts a local docker PostgreSQL container on port 5432
- `db:migrate:latest`: Runs migrations on a local PostgreSQL database
- `db:down`: Tears down local docker PostgreSQL container and deletes the db volume
- `yarn db:up`: Starts a local docker PostgreSQL container on port 5432
- `yarn db:down`: Tears down local docker PostgreSQL container and deletes the db volume
- `yarn db:migrate:list` - lists all the migrations applied to the database
- `yarn db:migrate:up MIGRATION_NAME`: Runs a specific migration on a local PostgreSQL database
- `yarn db:migrate:latest`: Runs migrations on a local PostgreSQL database
- `yarn db:migrate:new MIGRATION_NAME`: Generates a new migration file
- `yarn dotenv -e .env.dev ...`: run any of the above commands against a specific environment file

### Migrations

Expand All @@ -40,22 +44,27 @@ Knex is used to create and run migrations. To make a migration follow these step
1. Add migration function and logic to `schema.ts`
2. Run the yarn command to stage the migration, which generates a new migration script in `migrations/` directory

- `yarn db:make:migration MIGRATION_NAME`
- `yarn db:migrate:new MIGRATION_NAME` (e.g. `yarn db:migrate:new add_id_to_table`)

3. Update the new migration to call the static function created in step 1.
3. Construct the migration queries in [src/db/arch/migrator.ts](src/db/arch/migrator.ts)

4. Run the migration
4. Update the generated migration file to call the proper migration script.

- `yarn db:migration:latest` or `yarn knex migration:up MIGRATION_NAME.TS`
5. Run the migration:

- `yarn db:migration:latest` or `yarn knex migration:up MIGRATION_NAME.TS`

6. Alternatively, run the migration against a specific environment file:

- `yarn dotenv -e .env.dev yarn db:migrate:latest`

### Rollbacks

You can rollback knex migrations using the following command:

- `yarn db:migrate:rollback` - rolls back the most recent migration
- `yarn db:migrate:rollback --all` - rolls back all migrations
- `yarn knex migrate:list` - lists all the migrations applied to the database
- `yarn knex migrate:down MIGRATION_NAME.ts --knexfile src/database/knexfile.ts` - rolls back a specific migration
- `yarn db:migrate:down MIGRATION_NAME` - rolls back a specific migration

Additional `knex` documentation can be found [here](https://knexjs.org/guide/migrations.html).

Expand Down Expand Up @@ -87,6 +96,8 @@ docker compose up upload-service --build

Unit and integration tests can be run locally or via docker. For either, you can set environment variables for the service via a `.env` file:

- `yarn test:local` - runs unit and integration tests locally against postgres and arlocal docker containers

### Unit Tests

- `yarn test:unit` - runs unit tests locally
Expand Down
Loading

0 comments on commit cf321c0

Please sign in to comment.