Code Monkey home page Code Monkey logo

shaw-csv-backend's Introduction

shaw-csv-backend

REST API in Node to load and query CSV

About

This backend project receives CSV files using a RESTful Node API, saves them locally as files and in MongoDB. It also has an endpoint to query the data saved in the database.

Built with

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • Multer
  • CsvtoJSON
  • Nodemon
  • Docker
  • Jest
  • Supertest
  • Dotenv

Setup

*** This backend project should be used with the frontend, located at shaw-csv-frontend, however, it is also a standalone RESTful API, which can be used with Postman/Insomnia or other mean that communicates with HTTP REST endpoints ***

  • Get the link of the repository: [email protected]:arthurborgesdev/shaw-csv-frontend.git
  • Clone it as [email protected]:arthurborgesdev/shaw-csv-frontend.git on a Terminal
  • Change directory to it by cd shaw-csv-frontend
  • Run npm i on a Terminal

This project can be setup with Docker (preferred way if you don't have MongoDB installed or don't want to install it) or with a locally installed Mongo.

Docker instructions

Run docker compose command docker-compose -f docker-compose.yml up

Other useful commands:

docker ps -> Get container ID

docker logs <container id> -> Print app output

docker exec -it <container id> /bin/bash -> Get into the container

docker kill <container id> -> Shutdown the container

Localy MongoDB installed version

  • Install MongoDB according to your OS instructions if you don't have it installed
  • Run it accordingly to your OS instructions
  • Enter in the mongo shell by typing mongosh on a Terminal
  • Create a root user with pass password (Step necessary to match the config for Docker and Nodejs env variable):
  use admin
  db.createUser(
  ... {
  ... user: "root",
  ... pwd:  "pass",
  ... roles: [ { role: "root", db: "admin" }]
  ... }
  ... )

Start the server

npm run dev will run nodemon for local testing

Tests

Unit

npm run test:unit

Integration

npm run test:integration

Full tests

npm run test

Usage endpoints

Load CSV File

POST 127.0.0.1:3000/api/files

multipart/form-data

csv-file: "example.csv"

Return: Loaded CSV as a array of objects

Query the loaded CSV File

GET 127.0.0.1:3000/api/users?q=term1,term2,term3

queries: term1,term2,term3

Return: Filtered CSV related to the provided queries

Author

๐Ÿ‘ค Arthur Borges

shaw-csv-backend's People

Contributors

arthurborgesdev 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.