Espotz-API
Pre-requisites
- Install Node.js v14.15.3
- Install Typescript v4.0.2
Getting started
- Clone the repository
git clone https://gitlab.com/virtoustack-softwares-pvt-ltd/espotz-api.git
- Install dependencies
cd espotz-API
npm install
- Build and run the project
Windows: npm run serve:win
Linux: npm run serve
-
API Base-Url:
http://localhost:3000
-
API Document endpoints
espotz-API: To be updated in future
TypeScript + Node
The repository consist of APIs written in typescript which are used in Espotz project.
Getting TypeScript
Add Typescript to project npm
.
npm install -g typescript
Project Structure
The folder structure of this app is explained below:
Name | Description |
---|---|
log | Contains logs. |
node_modules | Contains all npm dependencies. |
src | Contains source code that will be compiled to the dist dir. |
src/api | Contains controllers and routes. |
src/appConfig | Application configuration including environment-specific configs. |
src/commons | Common libraries to be used across your app. |
src/modules | Contains service classes ad business logic. |
src/app.ts | Contain all express routes, separated by module/area of application. |
src/logger.ts | Contains log4js configurations. |
src/redis.connection.ts | Redis Connection. |
src/server.ts | Entry point to express app. |
gitlab.ci.yml | Contains CICD pipeline code. |
dockerfile | Contains docker build commands. |
package.json | Contains npm dependencies as well as build scripts. |
tsconfig.json | Config settings for compiling source code only written in TypeScript. |
tslint.json | Config settings for TSLint code style checking. |
Running the build
All the different build steps are orchestrated via npm scripts. Npm scripts basically allow us to call (and chain) terminal commands via npm.
Npm Script | Description |
---|---|
start |
Runs full build and runs node on dist/index.js. Can be invoked with npm run start
|
serve |
Compiles and runs full project on linux OS. Can be invoked with npm run serve
|
serve:win |
Compiles and runs full project on windows OS. Can be invoked with npm run serve:win
|
build |
Full build on linux OS. Can be invoked with npm run build
|
build:win |
Full build on Windows OS. Can be invoked with npm run build:win
|
lint |
|
test |
|
watch-test |
TSLint
TSLint is a code linter that helps catch minor code quality and style issues.
TSLint rules
All rules are configured through tslint.json
.