1.0.24 • Published 4 years ago

at-nestjs-core v1.0.24

Weekly downloads
2
License
UNLICENSED
Repository
-
Last release
4 years ago

Feina Activa

at-nestjs-core

Description

Core module to help you build great microservices.

Built With


General info about the stack used within this microservice:

  1. NestJs framework.
  2. TypeScript language.
  3. TSLint core rules
  4. Nodemon is a utility that will monitor for any changes un your source and automatically restart your server.
  • Check annex section for in depth details about our Stack.

Configuration

These instructions will get you a built version of at-nestj-core library, providing a set of classes and tools to ease your microservice development.

Prerequisites

Make sure you have

  1. npm
  2. node version >= 8.9.x,
  3. mongo version >= 3.4.x,installed on your system.

Environments

Environment variables

There are several configurable variables in .env:

APP_NAME='My Microservice'

JWT_SECRET_KEY='supersecretkey'

COOKIE_NAME='cookie_field'

MONGO_DB_URI=<string, mongodb uri>

PORT='9000'

TRANSLATE_HOST='http://localhost:9001'
      
DEFAULT_LANG='ca'

Npm Tasks

Following, we have some package scripts to perform this actions:

  • Start project for development purposes.
  • Run TSLint.
  • Compile TypeScript.
  • Build project in dist folder.
  • Create a server to work with.
  • Watch for file changes and reloads the server.
  • Prepare code during publish process.

Commands:

npm start

npm run lint

npm run build

npm run prepare

npm run clean

Development

Installing and Running

For installing on a project, you just need to install the dependency and start the project.

  1. npm install at-nestjs-core

  2. npm start

Contributing

For development purposes,

  1. Is not recommended to use npm link to test development versions on your projects. We suggest you to generate a built version with:
tsc

and copy these generated files into your microservice dependencies folder npm_modules/at-nestjs-core, replacing published files. After this, you only need to restart your microservice.

You can also use

npm start

script to generate built files on every code update.

Running the tests

To run the tests, you need to type

npm tests

This will execute all the unit tests and create a coverage report of the code.

Publishing new version

To create a new version of this library, you need to upgrade the version field on package.json (check package-lock too), login on your cli as npm owner and type:

npm publish

ANNEX

Folder structure

Creates a ready-to-run microservice with the following directories structure:

.
├── src          # Contains files and directories. Core classes to build a microservice.
├.editorconfig
├.gitignore
├.npmignore
├README.md
└──

Built with

1. NestJS

What is it?

NestJS aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.

  • Nestjs is a progressive Node.js framework.
  • Is built with TypeScript (preserves compatibility with pure Javascript).
  • Combines elements of OOP ( Object Oriented Programming ), FP ( Functional Programming ) and FRP ( Functional Reactive Programming ).
  • Makes use of Expres.js.

2. TypeScript

What is it?

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

  • In this project, Typescript tools are available via npm (Node.js package manager).
  • Use .ts extension in order to indicate that a file will contain code written in TypeScript.

3. Nodemon

Nodemon is a utility that will monitor for any changes on your source code and automatically restart your server.

What it does?
  • Automatic restarting of application.
  • Detects default extension to monitor.
  • Ignores specific files or directories.
  • Watches specific directories.

Altran - 2017