leolana / stark_api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AlpePay - Stark 2.0 JS

Alpe API Portal Financeiro developed in Node.js with database Postgres.


About Project

More info about project: Alpe - Project


Tech Stack

❯ Prerequisites

❯ Getting Started

  • Verify node version v10.15.0.
  • Clone and run npm i
git clone https://github.com/ITLAB-BR/alpe-api.git alpe-api
cd alpe-api                  # Change to the project directory
npm i                        # install all dependencies
  • Setup project
    • Env
      • Copy the .env.example file and rename it to .env. In this file you have add your configs informations.
    • Then setup your application environment
npm run setup
  • Serve Api and watch
npm start serve             #serve api with typescript been transpiled in runtime and watches changes in ./src

or

npm start watch             #build the api to javascript and watches changes in ./src

This starts a local server using nodemon, which will watch for any file changes and will restart the sever according to these changes. The server address will be displayed to you as http://localhost:8081.

❯ Scripts and Tasks

All script are defined in the package-scripts.js file, but the most important ones are listed here.

Install

  • Install all dependencies with npm i

Linting

  • Run code quality analysis using npm start lint. This runs tslint.
  • There is also a vscode task for this called lint.

Tests

  • Run the unit tests using npm start test (There is also a vscode task for this called test).
  • Run the integration tests using npm start test.integration.
  • Run the e2e tests using npm start test.e2e.

Seed

  • Create new seed using npm "start db.seed_generate <file-name-seed>".
  • Run the seeds npm start db.seed.

Migrations

  • Create new migrations using npm "start db.migrate_generate <file-name-migrate>".
  • Run the migrations npm start db.migrate.

Running in dev mode

  • Run npm start serve to start nodemon with ts-node, to serve the app.
  • The server address will be displayed to you as http://localhost:8081

Building the project and run it

  • Run npm start build to generated all JavaScript files from the TypeScript sources (There is also a vscode task for this called build).
  • To start the builded app located in dist use npm start.

❯ Debugger in VSCode

To debug your code run npm start build or hit cmd + b to build your app. Then, just set a breakpoint and hit F5 in your Visual Studio Code.

Manual das variáveis de ambiente

❯ Docker

Just run the command:

chmod +x ./start-dev.sh
./start-dev.sh

❯ DDD and Clean Architecture

The application follows the Uncle Bob "Clean Architecture" principles and project structure :

❯ Directory Layout

.
├── /vscode/                            # VSCode tasks, launch configuration and some
├── /commands/                          # Commands specifics to be executed with nps
├── /dist/                              # Compiled source files will be placed here
├── /docs/                              # Docs of project
├── /postman/                           # API documentation (POSTMAN)
├── /scripts/                           # Database scripts  seed/migrations
├── /src/                               # Node.js application source files
│   ├── /constants/                     # Constants of app|   ├── types.ts                    # types to dependency injection
│   ├── /domain/                        # Enterprise core business layer|   ├── /entities/                  # Domain model objects such as Entities, Aggregates, Value Objects, Business Events, etc.|   ├── /services/                  # Domain services|   ├── /usecases/                  # Application business rules
│   ├── /infra/                         # Frameworks, drivers and tools such as Database, the Web Framework and etc|   ├── /api/                       # Api config|   |   ├── /logging/               # Api Logging|   |   ├── /ControllerLoader.ts    # Loader of controllers and routes|   |   ├── /router.ts              # Config router and middlewares|   |   ├── /Server.ts              # Server abstraction|   ├── /auth/                      # Auth config|   ├── /console/                   # Console config|   ├── /database/                  # Database driver config|   |   ├── /migrations/            # Database migration scripts|   |   ├── /models/                # Sequelize Models|   |   ├── /seeds/                 # Seeds to create some data in the database|   |   ├── /index.ts               # index to database|   |   ├── /ModelsLoader.ts        # Loader of Sequelize Models|   |   ├── /validator.ts           # validator db types|   ├── /environment/               # environment abstraction|   ├── /fileStorage/               # FileStorage config|   ├── /internalApis/              # Internal Apis config|   ├── /logging/                   # Logger of app config|   ├── /mailer/                    # Mailer config|   |   ├── /emails/                # Email templates|   |   ├── /emailTemplates.ts      # Constantes to email tempaltes|   ├── /siscof/                    # Siscof adapter config
│   ├── /interfaces/                    # Adapters and formatters for use cases and entities to external agency such as Db or Web|   ├── /rest/                      # Rest adapter|   |   ├── /controllers/           # API Controllers|   |   ├── /errors/                # Custom HttpErrors like 404 NotFound|   |   ├── /middlewares/           # Express Middlewares like authorization features|   |   ├── Controller.ts           # Controller interface
│   ├── /types/                         # Custom type definitions and files that aren't on DefinitelyTyped|   |   ├── express-request.d.ts    # Custom type definition to express|   |   ├── json.d.ts               # Custom type definition to json extension|   |   ├── sequelize-database.d.ts # Custom type definition to sequelize
│   ├── /Application.ts                 # Application services
│   ├── /config.ts                      # Global config app based in envs
│   ├── /container.ts                   # Dependecy Injection Container config with inversify
│   ├── /index.ts                       # bootstrap of app
├── /test                               # Tests
│   ├── /e2e/                           # End-2-End tests (like e2e)
│   ├── /integration/                   # Integration test with postgres
│   ├── /support/                       # Support to tests (like database, logging mocks)
│   ├── /unit/                          # Unit tests
├── .dockerignore                       # Defines Docker ignore folder, files and etc
├── .editorconfig                       # Editorconfig custom configrations
├── .env.example                        # Environment configurations
├── .gitignore                          # Defines git ignore folder, files and etc
├── .prettierignore                     # Defines prettier ignore folder, files and etc
├── .prettierrc                         # Prettier configuration
├── commitlint.config.js                # Commitlint config
├── docker-compose.yml                  # Defines Docker services, networks and volumes
├── docker-compose-dev.yml              # Defines Docker services, networks and volumes to development env
├── Dockerfile                          # Commands for building a Docker image for production
├── package-scripts.js                  # Package Scripts to app
├── package.json                        # List of project dependencies
├── start-dev.sh                        # Script to run  image app with docker
├── tsconfig.json                       # Ttpescript configuration to build
├── tslint.json                         # TSLint configuration

❯ Changelog

More info about releases you find in Changelog

❯ Related Projects


❯ Contributors

Please read CONTRIBUTORS.md for details on our code of conduct, and the process for submitting pull requests to us.


❯ Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.


❯ Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.


Made with ♥ by ITLAB (http://www.itlab.com.br)

About


Languages

Language:TypeScript 84.7%Language:HTML 5.9%Language:JavaScript 4.5%Language:CSS 3.6%Language:Shell 1.2%Language:Dockerfile 0.2%