Coder Social home page Coder Social logo

dw-webboard-service's Introduction

Installation

Install package service

  yarn install

Install and run MongoDB with Docker (No need if start service by docker compose)

  docker pull mongodb/mongodb-community-server:latest

  docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest

URI mongodb will be: mongodb://localhost:27017

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

see example in .env.example file

MONGODB_URI uri mongodb

MONGODB_DB database name

JWT_SECRET secret for generating JWT tokwn (default: 'secretforjwt')

PORT custom service port (default: 3001)

Start Service

  yarn start

Start Service with Docker Compose (Include MongoDB)

  docker-compose up -d

Create User before login

API Reference

Create User

  POST /api/v1/user

JSON body

Key Type Description
username string Required. Username for login
picture string Optional. url picture

Unit Testing

Create and setup environment variable for testing in .env.test.local (same as .env)

Test all service

  yarn test

Test user service

  yarn test:user

Test post service part 1

  yarn test:post1

Test post service part 2

  yarn test:post2

Test comment service

  yarn test:comment

Test auth service

  yarn test:auth

if met some error while testing, try to use describe.only or describe.skip to test specific testcase.

Packages in project

  • class-transformer - transform body request object to class
  • class-validator - validate body request
  • mongodb - database
  • @nestjs/jwt - sign and decode jwt token

Folder Structure

In this project, It is base on haxagonal architecture design

  src
    ├── application               # Service files
    ├── domain
          ├── model               # Model files, type, enum used in services
          ├── ports
                ├── inbound       # Interface files for services
                ├── outbound      # Interface files for repository
    ├── infrastructure            # Repository files for database or third-party api
    ├── interface                 # Controller files
          ├── dto                 # DTO files (request body and validation)
    ├── utils                     # Tools and utilities
    ├── test                      # Unit test files
  ├── .env                        # Main env file
  ├── .env.test.local             # Testing env file
  └── README.md

Acknowledgements

dw-webboard-service's People

Contributors

nattapong-biz avatar

Watchers

Boss Nattapong 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.