Giter Club home page Giter Club logo

nest-starter-project's Introduction

NEST STARTER API PROJECT

Description

a starter API project using NestJs framework.

Installation

# clone this repository
$ git clone https://github.com/programercopas/nest-starter-project.git

# run npm install
$ npm install

Configuration

# copy .env.example
$ cp .env.example env

# input environment config in .env file
# Apps
APP_PORT=3000

# Database Connection
CONN_TYPE=mysql
CONN_HOST=localhost
CONN_PORT=3306
CONN_USERNAME=root
CONN_PASSWORD=secret
CONN_DATABASE=nest_starter
CONN_LOGGING=false

# Redis Config
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

Running the app

# run redis in local
$ redis-server

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Running database on docker

# copy docker-compose.yml.example
$ cp docker-compose.yml.example docker-compose.yml

# run docker-compose
$ docker compose up -d  

# stop docker-compose
$ docker compose down -v 

Database Migration

# create migration file
$ npm run migration:create ./src/migrations/CreateTableExample

# run migrations file
$ npm run migration:migrate

# run migration revert
$ npm run migration:revert

# generate migration from entities
$ npm run migration:generate ./src/migrations/GenerateAllEntities

Structure Project

src
---api
------config
--------config.module.ts
--------config.service.ts
--------migration.typeorm.config.ts
------database
--------entties
--------migrations
--------database.module.ts
---constants
---dto
---helpers
---interface
---services
---main.ts

Example API

# LIST EXAMPLE
GET LIST [GET]    : http://localhost:3000/example?page=1&limit=10&order=firstName:ASC&email=

# FIND BY ID
FIND ONE [GET]    : http://localhost:3000/example/31526f91-f0d3-4a86-b5f5-34b00f7d0ecb

# CREATE EXAMPLE
CREATE   [POST]   : http://localhost:3000/example

# UPDATE EXAMPLE
UPDATE   [PUT]    : http://localhost:3000/example/31526f91-f0d3-4a86-b5f5-34b00f7d0ecb

# DELETE EXAMPLE
DELETE   [DELETE] : http://localhost:3000/example/31526f91-f0d3-4a86-b5f5-34b00f7d0ecb

# see detail in swagger
http://localhost:3000/docs

License

MIT licensed.

nest-starter-project's People

Contributors

hasan-indra avatar indrahasan21 avatar

Watchers

 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.