GithubHelp home page GithubHelp logo

node-boilerplate's Introduction

Boilerplate

A boilerplate for a node web api application. It's designed to work out-of-the-box.

Why?

The JavaScript ecosystem is intimidating. There are numerous options for everything, each of which having a mountain of the write and wrong ways to use said options, and even more reasons why or why not to use said options, and yet even more still opinions on which tools to use with them. I'm all about the "lego" mentality, but at a certain point, I mean... Fuck! I don't want to have to sift through tabs and tabs of dox just to return Hello, world from my API.

So, here's this...

A boilerplate for a Node.js® backend api written in TypeScript. It has Mocha for unit tests. If you follow the instructions, it should work out of the box for anyone... If it doesn't, please, log an issue, and it will be attended to.

TL;DR

git clone https://github.com/revrenlove/node-boilerplate

cd node-boilerplate

npm install

npm start

curl localhost:8080/api/greeter?name=Bill

  • Should return: Hello, Bill!

Building

npm run build

Testing

npm test

Requirements

Recommended

Windows-specific

Includes

Config files

eslintrc.json

Has all the rules/config for ESLint.

mocharc.jsonc

Config settings for mocha when running it from the command line.

  • ts-node/register - for compilation.

  • module-alias/register - for path alias recognition.

package.json

scripts

  • clean - removes dist folder.

  • build - runs clean and builds app.

  • start - cleans, builds, and starts app.

  • test - runs mocha with settings in mocharc.jsonc.

_moduleAliases

Needed for module-alias package. Should match keys in paths of tsconfig.json as such (note the lack of wildcard in package.json):

package.json

{
  // ...
  "_moduleAliases": {
    "@service": "dist/service"
    // ...
  }
  // ...
}

tsconfig.json

{
  "compilerOptions": {
    // ...
    "paths": {
      "@service/*": ["./src/service"]
      // ...
    }
    // ...
  }
}

tsconfig.json

include key is for including any source files that you want VSCode to recognize.

tsconfig-build.json

Used only for build to exclude the test folder in compilation.

Visual Studio Code

After cloning and prior to opening in Visual Studio Code, go ahead and run the install and build commands to prevent it barking at you.

npm install

npm run build

Once you have the folder open in Visual Studio Code, it will prompt you to download some recommended extensions... Do that...

Recommended Extensions

Code linter for TypeScript and JavaScript

Sidebar test runner for Mocha Tests

TODO: List

  • Finish this documentation...

node-boilerplate's People

Contributors

revrenlove avatar

Watchers

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