Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
fix: move binaries to trail-core
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Heymann committed Mar 26, 2020
1 parent 4f9ac36 commit b2643ef
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![travis][travis-badge]][travis-url]

Trail is a audit trail log service. It supports logging all kind of actions with a flexible model scheme.
Trail is an audit trail log service. It supports logging all kind of actions with a flexible model scheme.

For information about the model scheme, see the [trail-core package README][trail-core-readme].
This repository is home to Trail's three main modules:
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
"test": "lerna run test",
"clean": "lerna clean"
},
"bin": {
"migrate": "./packages/trail-core/database/migrate.js"
},
"devDependencies": {
"@hapi/lab": "^22.0.3",
"code": "^5.2.0",
Expand Down Expand Up @@ -72,4 +69,4 @@
"packages/*"
],
"dependencies": {}
}
}
52 changes: 50 additions & 2 deletions packages/trail-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,32 @@ To install via npm:
npm install @nearform/trail-core
```

Trail requires an instance of Postgres (version 9.5+) to function correctly. For simplicity, a preconfigured `docker-compose` file has been provided:

```
docker-compose up
```

The initial tables can be created by executing:

```
npx trail-database-init --dbName=trails_test
```

## Usage

```javascript
const {TrailsManager} = require('@nearform/trail')
const { TrailsManager } = require('@nearform/trail')

const main = async function() {
const manager = new TrailsManager()

const id = await manager.insert({when: '2018-05-01T12:00:00.123', who: 'user:1', what: 'open', subject: 'page:1'})
const id = await manager.insert({
when: '2018-05-01T12:00:00.123',
who: 'user:1',
what: 'open',
subject: 'page:1',
})
const trail = await manager.get(id)
console.log(trail.who)

Expand Down Expand Up @@ -118,6 +135,37 @@ The `desc` can be set to `true` to sort results by descending order.

Returns an array of found id (depending on the `type` attribute), ordered alphabetically.

## CLI

### `trail-database-init`

Command used to create initial tables required by Trail.

```
npx trail-database-init
```

* `--dbHost` (default: 'localhost') - Postgres hostname (or use `TRAIL_DB_HOST` env variable)
* `--dbPort` (default: 5432) - Postgres port (or use `TRAIL_DB_PORT` env variable)
* `--dbUsername` (default: 'postgres') - Postgres username (or use `TRAIL_DB_USERNAME` env variable)
* `--dbPassword` (default: 'postgres') - Postgres password (or use `TRAIL_DB_PASSWORD` env variable)
* `--dbName` (default: 'trails') - Trail database name (or use `TRAIL_DB_NAME` env variable)

### `trail-database-migrate`

Command used to run any database migrations manually.

```
npx trail-database-migrate --version=<version>
```

* `--version` - Migration version (or use `TRAIL_MIGRATE_VERSION` env variable)
* `--dbHost` (default: 'localhost') - Postgres hostname (or use `TRAIL_DB_HOST` env variable)
* `--dbPort` (default: 5432) - Postgres port (or use `TRAIL_DB_PORT` env variable)
* `--dbUsername` (default: 'postgres') - Postgres username (or use `TRAIL_DB_USERNAME` env variable)
* `--dbPassword` (default: 'postgres') - Postgres password (or use `TRAIL_DB_PASSWORD` env variable)
* `--dbName` (default: 'trails') - Trail database name (or use `TRAIL_DB_NAME` env variable)

## License

Copyright nearForm Ltd 2018. Licensed under [MIT][license].
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/trail-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"access": "public"
},
"main": "lib/index.js",
"bin": {
"trail-database-init": "./database/init.js",
"trail-database-migrate": "./database/migrate.js"
},
"scripts": {
"coverage": "lab -c test",
"depcheck": "npx depcheck --ignores=config",
Expand Down

0 comments on commit b2643ef

Please sign in to comment.