Coder Social home page Coder Social logo

kevquincke / node-api-base Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 1.0 323 KB

API boilerplate project for NodeJS with Typescript

License: MIT License

TypeScript 79.63% HTML 0.56% JavaScript 8.55% API Blueprint 11.26%
javascript typescript nodejs express node-api-base api boilerplate api-boilerplate

node-api-base's Introduction

Node API Base

CircleCI Maintainability

Node Api Base is a boilerplate project for JSON RESTful APIs. It's based on Node v10.3.0 and Typescript v3.0.3.

Features

This template comes with:

  • Schema
    • Users table with roles (Admin and Regular by default)
  • Endpoints
    • Sign up regular user
    • Sign up admin user with authentication and authorization
    • Authentication for both kinds of users
  • Middleware
    • Authentication
    • Authorization (based on roles)
    • Exception handling
  • Tests
    • Unit tests for user
    • Integration tests for API
  • Code quality tools
  • API documentation following https://apiblueprint.org/

How to use

  1. Clone this repo
  2. Rename the folder and change name in package.json to the project name
  3. Create an .env file
  4. In the .env file set the following values:
    JWT_KEY = secret -> a secret value for json web token hashing
    DATABASE_URL = database url with format postgres://user:secret@host:port/database_name
    
    If you want to use another database instead of using postgres you'll need to change the app.ts database connection method and also set the database url to an accordingly format
  5. Run yarn
  6. Run yarn run dev to run on development
  7. You can now try your REST services!

Note: when creating an entity it must be exported in models/index.ts in order to be used. Tests: To run the tests after step 5, run yarn run test (make sure to point to a test database on DATABASE_URL)

Deploying to Heroku

  1. Run heroku create appName on the repo
  2. Add Heroku Postgres add-on (or whatever database you're using)
  3. Set environment values in heroku settings, as shown in the previous section (DATABASE_URL is probably already set)
  4. Run git push heroku branch (whatever branch you want to push)

NPM Packages

  1. body-parser Node.js body parsing middleware
  2. class-validator Validate incoming data
  3. dotenv Loads environment variables from a .env file to process.env
  4. express Fast, unopinionated, minimalist web framework for NodeJS
  5. lodash The Lodash library exported as Node.js modules
  6. pg Non-blocking PostgreSQL client for NodeJS
  7. pug High performance template engine
  8. reflect-metadata Runtime reflection on types
  9. typeorm ORM that can run in NodeJS
  10. ts-node TypeScript execution and REPL for NodeJS
  11. tslint Extensible static analysis tool for TypeScript
  12. typescript Language for application-scale JavaScript
  13. bcrypt Lib to help to hash passwords
  14. express-async-errors Simple ES6 async/await support hack for ExpressJS
  15. winston A logger for just about everything
  16. jsonwebtoken An implementation of JSON Web Tokens
  17. jest Delightful JavaScript Testing
  18. ts-jest TypeScript preprocessor with source map support for Jest
  19. supertest HTTP assertions made easy via superagent
  20. tslint-eslint-rules TypeScript rules available in ESLint

Api Docs

https://nodeapibase.docs.apiary.io

Current version

v1.0.0

node-api-base's People

Contributors

kevquincke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alxzu

node-api-base's Issues

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.