Git Product home page Git Product logo

central-system-api's Introduction

Central System Api

NodeJS Express.js TypeScript Postgres Docker

This project consists of a NodeJS RESTful API that serves two domains:
  • Organizations.

  • Chargepoints.

Important Notes

  • If you run Docker-compose use "make up" in wsl, check Makefile for context.

  • The Docker-compose container is slow in build up, bear with it please.

  • There is a Postman collection (if you prefer this) in root directory with the endpoints and a few skeletons on how request bodies should look like.

  • You can also run the application locally with NPM, instruction below.

Structure of the application

Lously coupled API following a domain driven design architecture split into different layers following the "Inversion of Control" principle (Onion Architecture), where implementations (outer layers) depend upon specifications (inner layers).

Image

  • Domain: holds the entities folder with the Domain objects Organization and Chargepoint. It is also the place where the specification of the CRUD operations sits (later implemented in the outer layers).

  • Application: this is the use-case layer of the API where both the bussiness logic layer (services) and the CRUD operations interfaces (previously mentioned) are implementated. The Datasource needed to run operation on the database is also set here.

  • Infrastructure: outer layer where the routing layer sits, here is where the controller endpoint classes are implemented. Input data from the Request object is validated on each route with the correspondant DTO object before accessing the Service layer.

Relevant commands to run the Docker container:
  • npm run docker: transpiles the typescript application into a javascript module in the /dist folder and then runs the application on localhost. Datasource host on this command is set as "pg_container" to properly build the image. This command is run automatically inside the docker-compose container.

  • make up: Make script that builds the docker compose image of the application and runs it in localhost:5000.

  • make down: Make script that shuts down the current running docker compose container.

Make is a Linux CLI tool to run scripts easly. If you don't have it installed just go inside the "Makefile" that is sitting on the root folder and get the docker-compose command to run from there.

How to launch with Docker:
  1. Run --> make up.
Relevant commands to run locally:
  • npm run dev: runs ts-node + nodemon on index.ts for development purposes.

  • npm start: transpiles the typescript application into a javascript module in the /dist folder and then runs the application on localhost.

Application is launched in PORT 5000 (localhost:5000 if you wanna try in local).

How to launch locally:
  1. Run --> npm install.
  2. Make sure a Postgres server is setup.
  3. Run --> npm run dev or npm start.

TODO LIST:

  • Testing.
  • Swagger implementation.

central-system-api's People

Contributors

ayoubhr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.