Code Monkey home page Code Monkey logo

nice-backend's Introduction

nice-backend

Node.JS 백엔드 프로젝트의 시작부터 배포까지 필요한 요소를 모두 담은 프로젝트 뼈대입니다.

What's inside

  • Mongodb with mongoose
  • Basic passport.js implementation (passport-local)
  • HTTPS support
  • TSLint with pre-commit hooks
  • Swagger, TSDoc documentations
  • Minimal E2E testing with jest
  • (todo) GraphQL querying

처음 시작하기

  1. config 설정 다음과 같은 형태로 DB 접속정보를 설정하세요. Development, production config는 각각 config/config.dev.json, config/config.prod.json에 저장됩니다.
{
  "mongodb": {
    "url": "mongodb://localhost:27017/dev",
    "user": "admin",
    "pass": "123"
  }
}

세션 키 (sessionSecret)는 설정하지 마십시오! 적절한 키 길이로 런타임에 설정됩니다.

Notes

HTTPS support

  • HTTPS is only active in production mode (edit www.dev.ts to change this).
  • Add your certificate (server.key, server.crt) under ./sslcert

REST structure

REST 구조

이미지 출처

1. 라우터 (/routes)

HTTP 요청을 받아 컨트롤러로 넘기기 전 유효성 확인, 권한 확인 수행

  • 잘못된 요청이 들어올 경우 400, 권한이 없을 경우 403 반환
  • Swagger 문서는 여기에 작성함

2. 컨트롤러 (/controllers)

HTTP 요청을 처리하는 단계

  • req, res를 인자로 받아 적절한 결과 반환
  • 서비스를 이용해 요청을 수행하고, JSON 형태로 결과를 보내는 역할
  • DB 작업은 컨트롤러에서 하지 않으며, 데이터를 다루는 로직은 서비스에서 수행

3. 서비스 (/services)

실제 로직을 수행하는 단계

  • 서비스는 HTTP req, res에 접근할 수 없음: 서버와 무관하게 동작해야 함
  • 데이터베이스 접근은 이 단계에서 이루어짐

주요 라이브러리

프로젝트를 시작하기 전 이용방법을 숙지하시길 바립니다.

관련 문서

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.