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.
The following instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
git clone git@github.com:samely/savefile.git
- Go to
savefile/
and install all the dependencies
yarn install
- For development and testing
yarn dev
- Build the project, which will create a
dist
folder from where the API will run
yarn build
- Start the API
yarn start
- Tests are in the
test
folder, run:
yarn test
- 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.
List vehicles from the database.
Example
http://localhost:4000/api/vehicles
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