GithubHelp home page GithubHelp logo

alejo86a / csv-script-bd-creator-denver-crimes Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 25 KB

Node.js backend project created in order to generate a script to fill a data base in postgreSQL based on a csv "Denver Crime Data" downloaded from (https://www.kaggle.com/paultimothymooney/denver-crime-data/downloads/denver-crime-data.zip/20)

License: GNU General Public License v3.0

Batchfile 4.37% JavaScript 95.63%

csv-script-bd-creator-denver-crimes's Introduction

Cokoa

Overview

Node.js backend project created in order to generate a script to fill a data base in postgreSQL based on a csv "Denver Crime Data" downloaded from (https://www.kaggle.com/paultimothymooney/denver-crime-data/downloads/denver-crime-data.zip/20)

Quick Start Guide

Prerequisites

In order to use Cokoa, you must have the following installed:

Installation & Startup

To install Cokoa, simply enter the below in the terminal window:

$ git clone https://[email protected]/iamjinme/rappi-cokoa.git your-project

To install the dependencies, enter the following in your terminal:

$ cd your-project
$ npm install

This will install the Cokoa components into the csv-script-bd-creator-denver-crimes directory.

Local Environment Variables for windows

Exist a file named env.bat in the server directory. This file should contain:

PORT=9001
APP_HOST=csv-script-bd-creator-denver-crimes
GELF_VERSION=1.1
LOGGLY_TOKEN=secret-loggly-token
LOGGLY_SUBDOMAIN=your-loggly-subdomain

Local Environment Variables for linux

Exist a file named .env in the server directory. This file should contain:

PORT=9001
APP_HOST=csv-script-bd-creator-denver-crimes
GELF_VERSION=1.1
LOGGLY_TOKEN=secret-loggly-token
LOGGLY_SUBDOMAIN=your-loggly-subdomain

Starting the App

To start the app, make sure you're in the project directory and type npm start into the terminal. This will start the Node server and connect to MongoDB.

You should the following messages within the terminal window:

> node src/server.js

info: SERVER_LISTENING {"port":your-port,"version":"1.1","host":microservices-name,"timestamp":your-timestamp}

Next, open your browser and enter http://localhost:your-port/. Congrats, you're up and running!

To run test npm run test. To run test coverage npm run coverage.

Enjoy!

Best Practices

Validate incoming request in routes

We use routes to receive request and controllers separated to manage bussiness logic. According to this post looks like a excellent idea validate data in routes, NOT in controllers.

There’s nothing wrong with validating incoming request in the controller but it’s not the best way to do this and your controller looks messy. This is bad practice in my opinion. The controller should do only one thing handle request from the route and return an appropriate response.

Writing validation logic in the controller will break The Single Responsibility Principle.

GELF Payload Specification

Graylog is an open source software to management logging, they have an interesting specification named GELF used to send logs to any server. You can read more about it in this post.

Logging levels

It's project use six levels in logs according to specification RFC5424. We use Winston library to transport logs to console, file or management log service as Loggly. In this post there are logging best practices to work with this library. READ this and remember: Build logs for machines, not humans.

ECMAScript 6 (ES6)

It's 2019! It's time to forget to use Babel or any transpilate utility. This post cover final semantics to create Classes with Javascript, our models use it. Arrow functions, default parameters, templates, const and let instead var, new array functions (map, filter, etc), destructuring, promises with async/await are important in our code, you can read about these here. To use ES6 implied better performance and a code more clean.

Airbnb JavaScript Style Guide

ESLint is good, with Airbnb rules is better. Airbnb startup has been created many rules compiled in a style guide to create a clean and understandable code with Javascript/Node.js, these rules could be customized, but Airbnb experience let us a good base to work in the same way when programming between our squad. Please follow this style guide. FYI Airbnb has rules to React, Ruby and other tools/language.

NOTES

  • This is a (WIP) Work In Progress. Many things can be improved. You can collaborate.
  • It's use a powerful logger named Winston with transport to console, file and loggly (optional).
  • It's use koa-combine-routers to combine any routers in an index.
  • The project use postgresql drivers because is the main database used in the company.
  • It's use CORS implementation. For now didn't use Import/Export.
  • We try run coverage at least 95%, by now using mocha and chai. Testing with Ava?
  • It's project use lightweight and minimal libraries.

Contributing

This could be an open-source project, and contributions are always welcome!

TODO

  • Create documentation with JSdocs.
  • Upload to Bitbucket. Coming soon.
  • Change some CommonJS minimal implementations.
  • Add and check some validations of business logic and possible bugs.
  • Any idea to add quality and performance to application?

Time of development

26 hrs 42 mins and counting...

Author

This project is cloned by the next author who wrote the project boilerplate

License

GPL License. Click here for more information.

csv-script-bd-creator-denver-crimes's People

Contributors

alejo86a avatar dependabot[bot] 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.