8000 GitHub - samely/savefile: An example of API to read data from a .csv file and upload it into a database
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

samely/savefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV uploader API sample

An example of API to read data from a .csv file and upload it into a database.

In this case we have a .csv file that contains vehicles data

👉 Check context for more information.

Getting Started

The following instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Install node
  • Install yarn
  • Download the project on your local machine by running
git clone git@github.com:samely/savefile.git

Installing

  • Go to savefile/ and install all the dependencies
yarn install
  • For development and testing
yarn dev

Build and start

  • Build the project, which will create a dist folder from where the API will run
yarn build
  • Start the API
yarn start

Running the tests

  • Tests are in the test folder, run:
yarn test

Built With

  • Express - a web application framework for Node.js
  • csvtojson - converts csv to json. A JSON approach helps to handle the uncertainty of the csv headers order.
  • morgan - an HTTP request logger middleware, so we are able to see the requests logged in the console.
  • multer - a middleware to upload files.
  • sequelize - a ORM that support many DBMS.
  • sqlite - a SQL database engine.

API

Vehicle

GET /api/vehicles

List vehicles from the database.

Example

http://localhost:4000/api/vehicles

POST /api/vehicles?<file>&<provider>

Upload the file to the server and create an entry for each row in the file.

parameter description
file a .csv file containing the data
provider the name of the file provider in order to get a personalized layout.

Use postman or insommia for testing. You can use the test/feature/vehicle.csv file as a test file

About

An example of API to read data from a .csv file and upload it into a database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0