This project provides a working template for creating NextGen microservices.
This project uses the following environment variables:
Name | Description | Required | Default Value | Accepted Values |
---|---|---|---|---|
NODE_ENV | Environment | Yes | DEV | DEV, TEST, PROD |
PASSWORD | Password for solace | Yes | --- | |
TEST_FILE | File to use when running PUB | No | testFile.json | |
REFRESH_TOKEN | Token for Equinox API call | Yes | ||
SESSION_ID | Session ID for Equinox API call | Yes |
- Node 14 or greater
- Access to the NextGen NPM Artifact Repository
- Configure a helm chart for your application.
- Add application to the Kubernetes environments
Note: We use 'my-project' as the name of your new project
git clone git@code.tls.nuskin.io:ns-am/templates/serverless-lambda.git <my-project>
cd <my-project>
rm -rf .git
Create it in the correct location based on its domain, stack location and technology.
- In the appropriate sub-group select "New project"
- Name your project
- Select a project description (optional)
- Select "Create project"
You can copy and paste the section in the gitlab command line instructions of your new project into the command line of your local project. It will look like the following but will have your project specific details.
cd <your project folder if you are not already there>
git init
git remote add origin <your gitlab project url>
git add .
git commit -m "Initial commit"
git push -u origin master
# use path from above
cd <my-project>
yarn
The application.yaml file is used by the solace-sync cli tool for building out Solace resources needed by your application.
- In ``config/default.json```, update the following:
-
serviceName
- the name of your service in eqService -
solace.userName
- the name of the solace user assigned to this service -
solace.clientName
- the name of the client associated with this service
-
- In
./transformer.js
, build out your custom transformer
This file is used for developing and running your application locally. Do not commit this file to your git repo.
NODE_ENV=dev
PASSWORD=<password>
REFRESH_TOKEN=<token>
SESSION_ID=<sessionid>
- Open .env file, and update variable values
- Build and run the project
yarn start
The folder structure of this app is explained below:
Name | Description |
---|---|
__mocks__ | Contains jest mocks |
__tests__ | Contains jest tests |
config | Application configuration including environment-specific configs |
src | Contains source code |
helpers | Contains code to do a test publish |
src/index.js | Entry point to the application |
Dockerfile | File used by docker to containerize application |
.gitignore | List of files and directories for Git to ignore |
jest.config.js | Configuration options for Jest |
.eslintrc | Configuration options for ES Lint |
.prettierrc | Configuration options for prettier |
package.json | Contains npm dependencies as well as build scripts |
.prettierignore | List of files and directories for prettier to ignore |
cx.config | File needed for common pipeline to pass |
yarn.lock | Yarn state snapshot |
.gitlab-ci.yml | CI pipeline configuration |
node_modules | Contains package dependencies |
All the different build steps are orchestrated via yarn scripts. yarn scripts basically allow us to call (and chain) terminal commands via npm.
yarn Script | Description |
---|---|
start |
Runs node on src/index.js. Can be invoked with yarn start
|
pub |
Sends test message. Can be invoked with yarn pub
|
test |
Runs tests with coverage using jest. Can be invoked with yarn test
|
lint |
Runs ESLint on project files. Can be invoked with yarn lint
|
The tests and assertions use Jest. Testing also utilizes eslint and prettier plugins.
"@jest/globals": "27.3.1",
"eslint": "8.2.0",
"eslint-plugin-jsdoc": "38.0.4",
"eslint-plugin-json": "3.1.0",
"jest": "28.1.0",
"jest-runner-eslint": "1.0.0",
"jest-runner-prettier": "1.0.0",
"jest-sonar-reporter": "2.0.0",
"prettier": "2.4.1"
yarn test
ESLint is a code linter that helps catch minor code quality and style issues.
All rules are configured through .eslintrc
.
To run ESLint you can call the ESLint task.
yarn lint // runs only ES lint