Worker module that consumes change-request messages from SQS queue and resolves them back into the database
To run a local instance:
npm run dev
Messages can also be injected directly for development without invoking SQS. See Injection
@asl/schema
provides models for interacting with database objects
The service can be configured for local development by setting environment variables in a .env
file.
The following environment variables are required:
DATABASE_NAME
- the name of your postgres databaseKEYCLOAK_REALM
- the keycloak realm used for authenticationKEYCLOAK_URL
- the url of the keycloak serverKEYCLOAK_CLIENT
- the client name used to authenticate with keycloakKEYCLOAK_SECRET
- the secret used to authenticate with the keycloak clientKEYCLOAK_USERNAME
- administrator username to authenticate with the keycloak clientKEYCLOAK_PASSWORD
- administrator password used to authenticate with the keycloak clientSQS_REGION
- the region of the SQS instance to consume fromSQS_ACCESS_KEY
- access key used to consume SQSSQS_SECRET
- secret used to consume SQSSQS_URL
- endpoint for SQSS3_REGION
- the region of the S3 instance to queryS3_ACCESS_KEY
- access key used to query S3S3_SECRET
- secret used to query S3S3_BUCKET
- the S3 bucket nameS3_LOCALSTACK_URL
- the URL for the localstack s3 instance (dev only)JWT_SECRET
- arbitrary string used to sign JWT tokens for invitationsEMAILER_SERVICE
- url ofasl-emailer
instance used to send invitationsREGISTER_SERVICE
- url ofasl-register
instance used to accept invitationsTRANSPORT_KEY
- 32 character encryption key used to encrypt messages in s3TRANSPORT_IV
- 16 character IV used to encrypt messages in s3
The following environment variables can be optionally defined:
DATABASE_HOST
- hostname of the postgres instance - defaultlocalhost
DATABASE_PORT
- port of the postgres instance - default5432
DATABASE_USERNAME
- username of the postgres instance - defaultundefined
DATABASE_PASSWORD
- password of the postgres instance - defaultundefined
JWT_EXPIRY
- expiry time for invitation links - default7 days
LOG_LEVEL
- logging level,POSTGRES_PASSWORD
- defaultundefined
None. Consumes messages from SQS.
The following services must be available in order to run:
postgres
- store of licence and profile dataasl-emailer
- emailer service that sends invitation emails
Scripts for setting up a local database with dev data are available in the asl-schema
project. First clone that repo and install the dependencies. Then run the following commands:
To setup the inital table schemas:
npm run migrate
To seed the database with a development dataset:
npm run seed
Note: these scripts will require the database described by DATABASE_NAME
to be created before they can run.
This project comes with a CLI that allows the direct injection of messages without having to consume them from SQS.
Messages should be defined as js or json files, and passed as arguments to bin/inject
:
// user.js
module.exports = {
model: 'invitation',
action: 'create',
data: {
establishment: '8201',
email: 'test@example.com',
firstName: 'Jane',
lastName: 'Bloggs',
role: 'admin'
}
};
bin/inject user.js
This is equivalent to consuming a message from SQS with the same message body.