Skip to content

benson00077/tlog-back

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

👉 Description

Try to fix bugs:

  • ✔️ client side fetch graphql api
  • ❌ server side(SSG) FAIL to fetch graphql api
  • ❌ postman FAIL to fetch graphql api

👉 Usage

Init

Follow ./env/example.env to define env variables. Make sure you have .env, developmnet.env and production.env files set up.

Also, mongo db have different URI format by version. Our .env is following the second one. See more on config.service.ts

# 1. mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
# 2. mongodb+srv://[username:password@]host[/[database][?options]]

Test w/ JWT auth guard

In GraphQL Playground add the http header as below, when testing protected GQL query / mutation, which is only accesible after authentication

{
	"Authorization" : "Bearer <encodedJWT>"
}

Note

Learning Materials

notion note
module
ㄴ Contorller handling incoming requests and returning responses
ㄴ Provider service you provide, called by controller
ㄴ Model as a class property
ㄴ ❓imports
❓Interceptors @injectable()

Coding strategy

  1. Write method in Controller (.controller.ts) 🡪 What's the req and res
  2. Write method in Provider (.service.ts) 🡪 How to impliment the logic like how to process datas from db and return them.

Decorator

  • Decorator Factory -- when use, pass in para @Logger('hi'), which return decorator categorized as below 4
    • Class decorator
    • Method decorator
    • Property decorator
    • Parameter decorator

keywords

  • Auth: JWT and base64
  • Auth: Session and Cookie and passport.js
  • DTO: Graphql and class-validator.js
  • Mongo: aggregate

npm script

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

About

Back-end for personal blog

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published