GithubHelp home page GithubHelp logo

dzinrai / koa-api-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paralect/koa-api-starter

0.0 0.0 0.0 760 KB

A starter kit for building Koa.JS based restful api

License: MIT License

JavaScript 98.44% Shell 1.16% Dockerfile 0.40%

koa-api-starter's Introduction

Koa.JS REST api starter

Stack

All Contributors license PRs Welcome Build Status David Dependancy Status

Watch on GitHub Star on GitHub Follow Tweet

Fully featured Koa.JS restful api starter application. The goal of this project is to solve all routine tasks and keep your focus on the product and business logic of the application, not on the common things, such logging, configuration, dev/production environments

Out of the box support following features:

  1. Config management.
  2. Configured console logger based on common-logger
  3. Automatic application restart when code changes with Nodemon
  4. MongoDB configuration
  5. Docker configuration for development and production environments.
  6. Code linting based on paralect/eslint-config
  7. Simplified request data validation and clean up based on joi and koa-validate
  8. Production ready account API resource (singup, signin, forgot password, reset password functionality)
  9. Access token based authentication.
  10. Tests for endpoints.
  11. WebSocket server (socket.io)
  12. Database migrations
  13. Scheduler

Prerequisites

Google authorization

Fill data from google in src/config/environment/index.js

google: {
  clientId: 'clientId',
  clientSecret: 'clientSecret',
  redirectUri: 'redirectUri',
}

Start

In order to start server in the docker container you can use bash file ./bin/start.sh:

$ ./bin/start.sh

To start the project not in the docker container just run: npm run development. This command will start the application on port 3001 and will automatically restart whenever you change any file in ./src directory.

Explanations of the files structure

We try to keep things as simple as possible, so you can focus on building product instead of learning concepts.

There are three main directories within project:

  1. src/config - consist of configuration for the environment, koa server and API routes.

  2. src/config/routes - consist of public (don't require access token) and authenticated (require access token) routes and middlewares.

    • middlewares - koa middlewares which we use on every request (for example, get current user data from the database)
  3. src/resources - REST api resources and everything related to the resource:

  4. src/services - application services for various purposes. Not this directory contains the following services:

All other files, that does not fit that structure should be placed straight in the src folder. We can always introduce more folders as we need them. Currently root folder consist following:

  1. src/app.constants.js - constant variables that are used in the application
  2. src/app.js - starting point of the node.js application. It combine application configuration and start Koa http listener.
  3. src/db.js - handles connection to the MongoDB.
  4. src/logger.js - application logger.
  5. src/security.util.js - number of methods for generating secure tokens and comparing passwords with password hash.

List of improvements

  1. Implement email service.

License

Koa.JS REST api starter is released under the MIT License.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Join us and share something developers need ๐Ÿ‘Œ.

Contributors

Thanks goes to these wonderful people (emoji key):

Evgeny Zhivitsa
Evgeny Zhivitsa

๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ‘€ โš ๏ธ
Andrew Orsich
Andrew Orsich

๐Ÿ“– ๐Ÿค” ๐Ÿ‘€
Ihar
Ihar

๐Ÿ’ป ๐Ÿค”
KuhArt
KuhArt

๐Ÿ’ป
NesterenkoNikita
NesterenkoNikita

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿค” โš ๏ธ
Nikita Solosnuk
Nikita Solosnuk

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿค”
Mar1nka
Mar1nka

๐Ÿ’ป ๐Ÿค”
Kirill Scherbenok
Kirill Scherbenok

๐Ÿ’ป ๐Ÿค”

This project follows the all-contributors specification. Contributions of any kind welcome!

koa-api-starter's People

Contributors

iharkrasnik avatar ezhivitsa avatar nesterenkonikita avatar allcontributors[bot] avatar mar1nka avatar dzinrai avatar anorsich avatar paralectvkomodey 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.