All Projects → zmts → Supra Api Nodejs

zmts / Supra Api Nodejs

Licence: mit
❤️ Node.js REST API boilerplate

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Supra Api Nodejs

Go Restful Api
An idiomatic Go REST API starter kit (boilerplate) following SOLID principles and Clean Architecture
Stars: ✭ 1,043 (+473.08%)
Mutual labels:  api, starter-kit, jwt, architecture
Snake
🐍 一款小巧的基于Go构建的开发框架,可以快速构建API服务或者Web网站进行业务开发,遵循SOLID设计原则
Stars: ✭ 615 (+237.91%)
Mutual labels:  api, restful, jwt
V8 Archive
Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
Stars: ✭ 486 (+167.03%)
Mutual labels:  api, restful, sql
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+360.44%)
Mutual labels:  api, sql, postgresql
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+1755.49%)
Mutual labels:  api, postgresql, starter-kit
Full Stack
Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Stars: ✭ 451 (+147.8%)
Mutual labels:  api, postgresql, jwt
Go Base
Go RESTful API Boilerplate with JWT Authentication backed by PostgreSQL
Stars: ✭ 928 (+409.89%)
Mutual labels:  api, restful, jwt
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (+104.95%)
Mutual labels:  api, restful, starter-kit
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+878.02%)
Mutual labels:  api, restful, jwt
Subzero Starter Kit
Starter Kit and tooling for authoring GraphQL/REST API backends with subZero
Stars: ✭ 136 (-25.27%)
Mutual labels:  api, postgresql, starter-kit
Postgrest Starter Kit
Starter Kit and tooling for authoring REST API backends with PostgREST
Stars: ✭ 657 (+260.99%)
Mutual labels:  api, postgresql, starter-kit
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (-18.68%)
Mutual labels:  api, restful, postgresql
Python Api Development Fundamentals
Develop a full-stack web application with Python and Flask
Stars: ✭ 44 (-75.82%)
Mutual labels:  api, restful, jwt
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-19.78%)
Mutual labels:  api, restful, jwt
The Rest Architectural Style
An article on the REST architecture style.
Stars: ✭ 168 (-7.69%)
Mutual labels:  api, restful, architecture
Fastapi Crudrouter
A dynamic FastAPI router that automatically creates CRUD routes for your models
Stars: ✭ 159 (-12.64%)
Mutual labels:  api, sql
Biking2
This is the source code of http://biking.michael-simons.eu
Stars: ✭ 162 (-10.99%)
Mutual labels:  sql, architecture
Branca Spec
Authenticated and encrypted API tokens using modern crypto
Stars: ✭ 163 (-10.44%)
Mutual labels:  api, jwt
Neo4j Etl
Data import from relational databases to Neo4j.
Stars: ✭ 165 (-9.34%)
Mutual labels:  sql, postgresql
Dgw
dgw generates Golang struct, and simple Table/Row Data Gateway functions from PostgreSQL table metadata
Stars: ✭ 161 (-11.54%)
Mutual labels:  sql, postgresql

Node.js API boilerplate

Piece of my thoughts about Node.js architecture.

supra-api-nodejs: A little bit about Node.js RESTful APIs Architecture (RU)

Highlights:

  • Modular RESTful API
  • ES6 Classes
  • Action based
  • SQL based (PostgreSQL with objection.js)
  • Migrations(knex.js)
  • Auth (JWT/Access-token/Refresh-token)
  • Cookie support
  • Role based access control
  • Request validation
  • CRUD(users, posts resources)
  • Automated API documentation
  • Full authentication/authorization and user registration flow implemented
  • Tests(e2e)

Key points:

0. Monolith first

Supra-api-nodejs its about monolith first approach. But this does not prevent you from using it in a microservice architecture as well.

1. Controller layer

Each entity have own controller class it slim layer representing resource mapping(routing)

class PostsController extends BaseController {
  static get router () {
    router.get('/', this.actionRunner(actions.ListAction))
    router.get('/:id', this.actionRunner(actions.GetByIdAction))
    router.post('/', this.actionRunner(actions.CreateAction))
    router.patch('/:id', this.actionRunner(actions.UpdateAction))
    router.delete('/:id', this.actionRunner(actions.RemoveAction))

    return router
  }
}

For example PostsController implements post entity routes. Each route fires own action.

2. Action layer

It's a class encapsulated request validation, permission verification and business logic. One file, one class, one REST operation, one use case.

3. DAO layer

Implement data access methods.

4. Model layer

Represent models schemas and validation rules. There is no other logic only model fields and validation rules.

Development:

Install global dependencies:

npm i -g knex nodemon

Setup database:

  1. Install PostgreSQL (https://postgresapp.com/downloads.html (for Mac OS))
  2. Create some DB (https://eggerapps.at/postico/ (for Mac OS))

Go ahead...

cd /supra-api-nodejs
  • cp .env.example .env
  • Set required credential in .env

Run migration to set base SQL schema

knex migrate:latest

Run server

npm run start // prod mode
npm run dev // dev mode

Implemented endpoints:

/auth

Path Method Description
/auth/login POST LoginAction
/auth/logout POST LogoutAction
/auth/refresh-tokens POST RefreshTokensAction

/users

Path Method Description
/users GET ListUsersAction
/users/current GET GetCurrentUserAction
/users/:id GET GetUserByIdAction
/users POST CreateUserAction
/users PATCH UpdateUserAction
/users/:id DELETE RemoveUserAction
/users/change-password POST ChangePasswordAction
/users/send-reset-password-email POST SendResetPasswordEmailAction
/users/reset-password POST ResetPasswordAction
/users/confirm-registration POST ConfirmRegistrationAction
/users/change-email POST ChangeEmailAction
/users/confirm-email POST ConfirmEmailAction
/users/resend-confirm-new-email-token POST ResendConfirmNewEmailTokenAction
/users/cancel-email-changing POST CancelEmailChangingAction

/posts

Path Method Description
/posts GET ListPostsAction
/posts POST CreatePostAction
/posts/:id GET GetPostByIdAction
/posts/:id PATCH UpdatePostAction
/posts/:id DELETE RemovePostAction

!!! Project still in progress !!!

2017 - 2018 - 2019 - 2020 ...

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].