Skip to content

equeraltowenea/wenea-chargepoints

 
 

Repository files navigation

Webea chargepoint rest-api

Jordi aquí tens el projecte finalitzat.

Per desenvolupar-ho, he assumit les següents presuncions al interpretar el teu full tècnic:

  • Només hi ha una taula chargepoint per al servei com a la db. Ja que name és "unique" només tindrem un registre a la taula per cada chargepoint, si entra un post o update de un chargepoint.name existent farem update del registre existent (state y created_at).

  • El registre d'un chargepoint no es borra si no que s'escriu la data de "delete_at" del registre del chargepoint llavor desapareix de les vistes però no de la db.

Finalment he inclós el desenvolupament per socket server (port 8060 localhost). Per testejar-ho obrir un terminal executar un client (o tants terminals com vulguis):

$ node ws-client.js 

ws-client.js és inclós al projecte.

Description

Nestjs used to setup project and create Typeorm used as ORM. Migrations development avalaible. Package class-validator for validation Added swagger validation. Simple tests added, internal dependancies and general test api running.

Project setup

Steps to execute the application.

Setup environment

Create or copy .env file:

Example: https://github.com/juanrogue/wenea-chargepoints/blob/main/.local.env%20

Load variables on env:

set -a # automatically export all variables
source .env
set +a

Setup database

You will need a Postgre blank database to setup and run this project.

sudo -u postgres psql;
create database wenea;
create user wenea_user with encrypted password '54bgt123';
grant all privileges on database wenea to wenea_user;

Compile and run the project

Once created the .env file and db install, build and run project. Database will be fulfilled with the created tables. Run migrations if necesaire.

$ npm install

Build:

$ npm run build

Run:

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Run tests

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Postman collection

Postman collection for fast testing avalaible at: https://github.com/juanrogue/wenea-chargepoints/blob/main/Webea.postman_collection.json

Automation

This is project is easy scalable. Used nestjs or typeorm for those purposes (migrations pipeline inc).

Create a new endpoint (CRUD endpoint template)

nest g resource entity_name

Migrations

Located at path: src/database/migrations

# To execute pending migrations, use the following command:
$ npm run migration:run

# migration generate
$ npm run migration:generate ./src/database/migrations/update-post-table

About

wenea-chargepoints rest api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.6%
  • JavaScript 7.4%