Giter VIP home page Giter VIP logo

nodeback's Introduction

Scheduler

RESTful api with Domain Driven Design

Quick Start

  1. Clone the repository
  2. Install the dependencies with Yarn
  3. Install global dependencies Application Setup
  4. Create the development and test Databases
  5. Run database migrations and seed with yarn db:refresh
  6. Run the application in development mode with yarn start
  7. Access http://localhost:<PORT>/api/<VERSION> and you're ready to go!

    http://localhost:4000/api/v1

Application Setup (Development)

$ yarn add global standard   # JavaScript Standard Style
$ yarn add global babel-eslint  # required by StandardJs
$ yarn add global snazzy   # Format JavaScript Standard Style as beautiful output
$ yarn add global sequelize-cli  # CLI for Sequelize

Database Setup (Development)

  1. Install MySql and create database

Overview

  • uses Node.js v11.10.0
  • written using ES6
  • uses Yarn for package dependency management
  • uses JavaScript Standard Style
  • uses sequelize and sequelize-cli as ORM and data migration tool

    can change easily to diffrent ORM and migration tool.

  • Filename convention - snake_case needs to be followed

CLI Tools

  • yarn start - start the App locally
  • yarn test - run Unit tests
  • yarn db:refresh - run all migrations and seeds.
  • yarn lint - lint codebase using JavaScript Standard Style
  • yarn lint:fix - fix code according to JS Standard Style
  • sequelize model:create --name newmodel --attributes "id:integer, title:string - create a new model
  • sequelize db:migrate - apply db changes using migration script
  • yarn add <package-name> - add a new package to package.json
  • yarn remove <package-name> - remove package from package.json

Basic commands

$ sequelize  db:migrate             Run pending migrations.
$ sequelize  db:migrate:old_schema  Update legacy migration table
$ sequelize  db:migrate:undo        Revert the last migration run.
$ sequelize  db:migrate:undo:all    Revert all migrations ran.
$ sequelize  db:seed                Run seeders.
$ sequelize  db:seed:undo           Deletes data from the database.
$ sequelize  db:seed:undo:all       Deletes data from the database.
$ sequelize model:create --name modelname --attributes "text:text, url:string"  # create model
$ sequelize seed:create     # create seeder

Sequelize CLI Documentation

For reference, see: https://github.com/sequelize/cli

Serverless setup

  • Install serverless and setup credentials
  • Install Aws-cli and setup credentials

Tech

  • Express - Node Framweork
  • Awilix - dependency resolution support powered by Proxy
  • PM2 - production process manager for Node.js applications with a built-in load balancer
  • Tcomb - s a library for Node.js and the browser which allows you to check the types of JavaScript values at runtime with a simple and concise syntax
  • Express-status-monitor - Simple, self-hosted module based on Socket.io and Chart.js to report realtime server metrics for Express-based node servers.
  • CORS - a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.
  • Body-parser - Node.js body parsing middleware.
  • Compression - Node.js compression middleware.
  • Http-status - Utility to interact with HTTP status code.
  • Winston - A multi-transport async logging library for node.js.
  • Morgan - HTTP request logger middleware for node.js
  • Ramda - A practical functional library for JavaScript programmers.
  • Sequelize - promise-based ORM for Node.js v4 and up. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL and features solid transaction support, relations, read replication and more.
  • Faker - generate massive amounts of fake data in the browser and node.js
  • Bcrypt - Lib to help you hash passwords
  • Passport - is Express-compatible authentication middleware for Node.js.
  • Passport-jwt - A Passport strategy for authenticating with a JSON Web Token.
  • Json Webtoken - An implementation of JSON Web Tokens.
  • Moment - Parse, validate, manipulate, and display dates and times in JavaScript.
  • Moment-timezone - Parse and display dates in any timezone.
  • Swagger-ui - visualize and interact with the API’s resources without having any of the implementation logic in place.
  • Swagger-jsdoc- enables you to integrate Swagger using JSDoc comments in your code. Just add @swagger on top of your DocBlock and declare the meaning of your code in yaml complying to the OpenAPI specification.

Logging

  • winston - a multi-transport async logging library for Node.js. It is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.
  • morgan - HTTP request logger middleware for Node.js. A helper that collects logs from your server, such as your request logs.

Tests

  • mocha - JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun
  • chai - a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
  • supertest - HTTP assertions made easy via superagent.
  • cross-env - makes it so you can have a single command without worrying about setting or using the environment variable properly for the platform
    • We mainly use this so mocha can use the absolute path of files

Pre-commit

Adding pre-commit to your project can be helpful to encourage consistency and quality of your code repository.

  • pre-commit - pre-commit is a pre-commit hook installer for git. It will ensure that your npm test (or other specified scripts) passes before you can commit your changes. This all conveniently configured in your package.json.
  • lint-staged - Linting makes more sense when running before committing your code. By doing that you can ensure no errors are going into repository and enforce code style. But running a lint process on a whole project is slow and linting results can be irrelevant. Ultimately you only want to lint files that will be committed.

JavaScript Standard Style

The Rules

  • 2 spaces – for indentation
  • Single quotes for strings – except to avoid escaping
  • No unused variables – this one catches tons of bugs!
  • No semicolons – [It's][1] [fine.][2] [Really!][3]
  • Never start a line with (, [, or `
    • This is the only gotcha with omitting semicolons – automatically checked for you!
    • [More details][4]
  • Space after keywords if (condition) { ... }
  • Space after function name function name (arg) { ... }
  • Always use === instead of == – but obj == null is allowed to check null || undefined.
  • Always handle the node.js err function parameter
  • Always prefix browser globals with window – except document and navigator are okay
    • Prevents accidental use of poorly-named browser globals like open, length, event, and name.
  • And more goodness

nodeback's People

Contributors

ravikadam avatar

Watchers

 avatar James Cloos avatar  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.