Giter VIP home page Giter VIP logo

nest-core's Introduction

logo

Nest Boilerplate Project

Nest Boilerplate Project is powered by Nest

Please use a template from README.sample.md for your real project README.md. An example can be found in README.example.md

πŸ“‹ Introduction

Powered by Nest and Typescript, this boilerplate project will make your life easier when setup a new project without worrying too much about the architecture, routing, validation, middleware, ...etc. This boilerplate project can be fully customized to your needs.

Thanks to VSCode and Typescript, we will have a fully intellisense when coding. No more magic function names appear out of nowhere, or some global functions that we have no idea where it is located.

We want to hear your feedback and your suggestion on this project to make it more powerful, robust and dynamic.

Also Read How to become a back-end developer

🏁️️ Getting Started

Prerequisite

Commands

Check your environment variables

To set your application environment variables create a .env file. There is an .env.example file to follow.

Install dependencies

yarn install

Run in development environment

# running nodemon
yarn dev

Run in production environment

# compile typescript
yarn build

# compile and run with pm2
yarn start

πŸ“¦ Architecture

Project Structure

Structure your solution by self-contained components

β€’
β”œβ”€β”€ πŸ“assets    # Contain any files for your app. ex: email template, static data json
β”œβ”€β”€ πŸ“config    # Contain any configuration from a third party library. ex: firebase config
β”œβ”€β”€ πŸ“public    # Contain access files via public
β”œβ”€β”€ πŸ“src       # Main directory that stores all the business logic
β”‚   β”œβ”€β”€ πŸ“api           # Yes, Api you know it
β”‚   β”œβ”€β”€ πŸ“common        # Contain your custom functions
β”‚   β”œβ”€β”€ πŸ“lib           # Built-In modules
β”‚   β”œβ”€β”€ πŸ“models        # Contain Sequelize models
β”‚   β”œβ”€β”€ πŸ“queries       # Contain raw SQL files
β”‚   β”œβ”€β”€ πŸ“schema        # Contain Mongodb schema
β”‚   β”œβ”€β”€ πŸ“„app.module.ts # Contain in-app modules
β”‚   └── πŸ“„index.ts      # Server configuration and startup

Built-in Modules

How to start the project

This project will not have the feature you need or you don't need any of our features. To simply start to project, you have to take a look into some files.

The main entry point: index.ts

This project is no doubt using express as a default. If you are familiar with express then you are good to go. You can set any configuration, setting, middleware, document within this file.

async function bootstrap() {
  const app = await NestFactory.create(ApplicationModule);

  // =================================
  // configureExpressSettings
  // =================================
  app.set();

  // =================================
  // configureExpressMiddleware
  // =================================
  app.use();

  // =================================
  // configureNestGlobals
  // =================================
  app.useGlobalGuards();
  app.useGlobalFilters();
  app.useGlobalPipes();

  // =================================
  // configureNestSwagger
  // =================================
  const options = new DocumentBuilder()
    .setTitle('Nest Boilerplate Project')
    .setContact('Dominic Preap', 'https://github.com/Dominic-Preap', '[email protected]')
    .setVersion('1.0')
    .addBearerAuth()
    .build();

  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('/docs', app, document);
}

Set your own modules: app.module.ts

This file controls all of your module. The required module for this file is ApiModule and ConfigModule. Un-comment the module that you need.

  • ApiModule stores every route handlers, business logic, and task scheduler as such.
  • ConfigModule stores and validates environment file .env.
import { Module } from '@nestjs/common';

import { ConfigModule } from '@lib/config';
import { ApiModule } from './api/api.module';

@Module({
  imports: [ApiModule, ConfigModule]
})
export class ApplicationModule {}

nest-core's People

Contributors

dependabot[bot] avatar dominic-preap avatar

Stargazers

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

Watchers

 avatar

nest-core'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.