1.0.16-ACQ-3537 • Published 4 years ago
audio-job-service v1.0.16-ACQ-3537
Node Microservices Seed Project
This is a started project for Nodejs based Services. This project is written in TypeScript. It uses @Clarabridge/service-base packaged for http server, logging, error handling and configuration. Example of starting a server:
import { Logger, Server } from '@clarabridge/service-base';
const logger = Logger(__filename);
const server = new Server();
const app = server.app();
// Add routes
app.get('/', (req, res) => {
logger.info('example route');
res.send('test');
});
// Start express server
await server.start();
logger.info('Server started successfully');
Setup
Install
To instal npm dependencies run command npm install
$ nmp install
Building and running
To compile TypeScript to ES5 run and execute the code run following commands:
$ npm run build
$ nom run dev
Tests
Unit tests are ran using Jest test frameworks. To execute full test suite run following command:
$ nmp test
To run tests in watch mode:
$ nmp run test:tdd
Linting
Linting is done using ESLint. Run following command lint:
$ nmp run lint
Create new Microservice from the Seed Project
To create new Nodejs Micro Service (e.g. awesome-service) from the Seed Project by follow these steps:
- Create new Github repository for the new project e.g. awesome-service. Make sure not to check
Initialize this repository with a README
- Checkout the Seed Project to awesome-service directory
git clone https://github.com/ClarabridgeInc/node-microservice-seed.git awesome-service
- Change Git remote to point to new repository's url
git remote set-url origin https://github/ClarabridgeInc/<new_repository_url>
- Make changes to Jenkinsfile to update the name of the new repository
- Update Readme.md
- Push code to new repository
git push -u origin master
1.0.16-ACQ-3537
4 years ago