All Projects → msanvarov → nest-rest-typeorm-boilerplate

msanvarov / nest-rest-typeorm-boilerplate

Licence: MIT license
🍱 backend with nest (typescript), typeorm, and authentication

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to nest-rest-typeorm-boilerplate

nest-boilerplate
Nest.js boilerplate with CircleCI, Commitizen, Commitlint, Docker-Compose, ESLint, GitHub Actions, Husky, Lint-staged, OpenAPI, Prettier, PostGreSQL, Travis CI, TypeORM
Stars: ✭ 16 (-88.73%)
Mutual labels:  openapi, nest, typeorm
node-nestjs-structure
Node.js framework NestJS project structure
Stars: ✭ 258 (+81.69%)
Mutual labels:  nest, typeorm
mom
Proof of concept for Message-Oriented-Middleware based architecture.
Stars: ✭ 39 (-72.54%)
Mutual labels:  nest, typeorm
Notadd
A microservice development architecture based on nest.js. —— 基于 Nest.js 的微服务开发架构。
Stars: ✭ 2,556 (+1700%)
Mutual labels:  nest, fastify
nestjs-rest-cqrs-example
Example for Nest.js, MySQL, Redis, REST api, CQRS, DDD
Stars: ✭ 263 (+85.21%)
Mutual labels:  nest, typeorm
nest-rest-mongo-boilerplate
🍱 backend with nest (typescript), mongoose, and authentication
Stars: ✭ 180 (+26.76%)
Mutual labels:  nest, fastify
Crud
NestJs CRUD for RESTful APIs
Stars: ✭ 2,709 (+1807.75%)
Mutual labels:  nest, typeorm
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (+2.11%)
Mutual labels:  nest, passportjs
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+18603.52%)
Mutual labels:  mariadb, typeorm
nestjs-asyncapi
NestJS AsyncAPI module - generate the documentation of your event-based services using decorators
Stars: ✭ 88 (-38.03%)
Mutual labels:  openapi, nest
mrapi
A framework for rapid development of API or DAL applications.
Stars: ✭ 20 (-85.92%)
Mutual labels:  openapi, fastify
nestjs-starter
🚀 Nest framework starter
Stars: ✭ 30 (-78.87%)
Mutual labels:  nest, typeorm
prime-nestjs
A production-ready NestJS boilerplate using Typescript, Postgres, TypeORM, and Docker.
Stars: ✭ 140 (-1.41%)
Mutual labels:  nest, typeorm
airbnb-clone
Fullstack airbnb clone made with React/Ts/Nest
Stars: ✭ 37 (-73.94%)
Mutual labels:  nest, typeorm
Nestjs-Typeorm-Auth
NestJS + Typeorm codebase containing a full authentification system with roles, sessions and email verification.
Stars: ✭ 37 (-73.94%)
Mutual labels:  typeorm, passportjs
mapet
Muitas pessoas tem bichinhos de estimação, entre eles os mais comuns são gatos e cachorros. Com a correria do dia a dia pode acontecer deles acabarem escapando, e ai aonde divulgar para ajudarem a encontrá-lo o mais rápido possível? Redes Sociais? WhatsApp? Pensando nisso criamos o mapet, um mapa que você indica aonde seu pet foi visto pela últi…
Stars: ✭ 15 (-89.44%)
Mutual labels:  mariadb, typeorm
fastify-openapi-glue
A plugin for Fastify to autogenerate a configuration based on a OpenApi(v2/v3) specification.
Stars: ✭ 94 (-33.8%)
Mutual labels:  openapi, fastify
MyAPI
A template to create awesome APIs easily ⚡️
Stars: ✭ 117 (-17.61%)
Mutual labels:  nest, typeorm
serverless-nestjs-typeorm
Example how to nestjs using the serverless framework with TypeORM
Stars: ✭ 99 (-30.28%)
Mutual labels:  typeorm
flink-client
Java library for managing Apache Flink via the Monitoring REST API
Stars: ✭ 48 (-66.2%)
Mutual labels:  openapi

API Starter

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License Travis

Table of Contents:

  1. Description
  2. Prerequisites
  3. Deployment
  4. Environment Configuration
  5. Choosing a Web Framework
  6. HTTP2
  7. Choosing a Database
  8. Testing
  9. TypeDocs
  10. Logs

🔎 This repo was created with Nx.

📚 Description

This boilerplate is made to quickly prototype backend applications. It comes with authentication/authorization, logging, crud features and database persistence out of the box.


🛠️ Prerequisites

Non Docker

  • Please make sure to have Node.js (16+) locally by downloading the Javascript runtime via brew, choco, or apt-get.

  • Please make sure to have MYSQL locally by deploying a web server stack like XAMPP. The control panel can then trigger MYSQL to start on localhost. MYSQL can be downloaded standalone via brew, choco, or apt-get.

Docker 🐳

  • Please make sure to have Docker Desktop operational to quickly compose the required dependencies. Then follow the docker procedure outlined below.

🚀 Deployment

Manual Deployment without Docker

  • Clone the repo via git clone https://github.com/msanvarov/nest-rest-typeorm-boilerplate.

  • Download dependencies via npm i or yarn.

  • Create a .env file via the cp .env.example .env command and replace the existing environment variable placeholders with valid responses.

  • Start the api in development mode by using npm run start (the app will be exposed on http://localhost:3333; not to conflict with React, Angular, or Vue ports).

Optional deployment of the UI
  • This repo comes with a UI built with Angular - that can be accessed via http://localhost:4200.

  • To start the UI, start a new terminal window and run npm run start --project ui.

Remark: In the docker deployment, the UI is automatically started and served by the API.


Deploying with Docker 🐳

  • Execute the following command in-app directory:
# creates and loads the docker container in detached mode with the required configuration
$ docker-compose up -d
  • The following command will download dependencies and execute the web application on http://localhost:80 (deployed behind a Nginx reverse proxy).

🔒 Environment Configuration

By default, the application comes with a config module that can read in every environment variable from the .env file.

APP_ENV - the application environment to execute as, either in development or production. Determines the type of logging options to utilize. Options: development or production.

WEBTOKEN_ENCRYPTION_KEY - the key to encrypt/decrypt web tokens with. Make sure to generate a random alphanumeric string for this.

WEBTOKEN_EXPIRATION_TIME - the time in seconds when the web token will expire; by default, it's 2400 seconds which is 40 mins.

DB_TYPE - the type of database connection to use.

DB_USERNAME - username for authenticating against the database.

DB_PASSWORD - password for authenticating against the database, can be left empty if a password is not needed (not safe).

DB_HOST - the endpoint where this database sits (default is localhost but can be set explicitly).

DB_PORT - default ports for different types of database connections.

DB_DATABASE - the actual database name to perform operations on.


🏗 Choosing a Web Framework

This boilerplate comes with Fastify out of the box as it offers performance benefits over Express. But the Express adapter is still accessible on a different branch.


💾 Choosing a Database

By default MYSQL/MariaDB are the database of choice but TypeORM supports other database types like SQLite, Postgres, MongoDB, and MSSQL. To use anything other than MYSQL/MariaDB, change the configuration in the .env file, and download the corresponding wrapper library, like SQLite3.

Check https://typeorm.io/ for supported database types.

Remark: For MongoDB, TypeORM is not as feature-rich as Mongoose. Thus, I created a boilerplate for Nest and Mongoose.


🦾 HTTP/2

Luckily, Fastify can enable HTTP2 over either HTTPS (h2) or plaintext (h2c) out of the box. This boilerplate makes use of this on the feat/http2 branch where a self-signed certificate was created for testing this capability. The certificate is located in the certs folder. For production, please use a valid certificate.

The self signed certificate can be generated via OpenSSL:

$ openssl req -x509 -newkey rsa:4096 -keyout api-key.pem -out api-cert.pem -days 365 -nodes

Remark: Express can be ran with HTTP/2 by employing the spdy library.


Testing

Docker 🐳

# Start the docker container if it's not running
$ docker start nest-rest-typeorm-api

# unit tests
$ docker exec -it nest-rest-typeorm-api npm run test

Non-Docker

# execute test
$ npm run test

💡 TypeDocs

The documentation for this boilerplate can be found on Github pages.

The docs can be generated on-demand, by typing npm run typedocs:api:start. This will produce a docs/api folder with the required front-end files and start hosting on localhost.

Remark: The docs for the ui are generated on-demand, by typing npm run typedocs:ui:start. This will produce a docs/ui folder with the required front-end files and start hosting on localhost.

# generate docs for api code
$ npm run typedocs:api:start

📝 Open API

Out of the box, the web app comes with Swagger; an open api specification, that is used to describe RESTful APIs. Nest provides a dedicated module to work with it.

The configuration for Swagger can be found at this location.


TypeORM

TypeORM is an object-relational mapping that acts as an abstraction layer over operations on databases. Please view the documentation for further details.

The configuration for TypeORM can be found in the app module.


🔊 Logs

This boilerplate comes with a Winston module for extensive logging, the configurations for Winston can be found in the app module.


🏗️ Progress

Branches Status
main
feat/* 🚧

👥 Support

PRs are appreciated, I fully rely on the passion ❤️ of the OS developers.


License

This starter API is MIT licensed.

Author

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].