Skip to content

mastrodaro/node-server-app-nestjs

Repository files navigation

Nest Logo

Node server app REST API

Example of Tasks API created with NestJS. Utilizes:

  • typescript
  • express
  • eslint
  • prettier
  • jest

Features:

  • auth - jwt (passport)
  • tasks CRUD
  • app config (dev/prod) with schema validation (joi)
  • logging
  • transform interceptor - hide sensitive data

Description

CLI:

npm i -g @nestjs/cli

Bootstrapped with nest new node-server-app-nestjs.

MOTD Api (unprotected):

  • get motd
  • create motd
  • update motd
  • delete motd

Model:

class Motd {
  message: string;
}

Tasks API:

  • get all tasks
  • get task
  • create task
  • update task progress
  • delete task
  • search for task

Model:

class Task {
  id: string;
  name: string;
  description: string;
  status: TaskStatus;
}

Added dependencies:

npm install class-validator class-transformer

Changes to initial version

.prettierrc - removed singleQuote

.eslintrc.js - added rule for unused underscore param

"@typescript-eslint/no-unused-vars": [
  "error",
  {
    argsIgnorePattern: "^_",
    varsIgnorePattern: "^_",
    caughtErrorsIgnorePattern: "^_",
  },
],

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

License

Nest is MIT.

About

When you need server app with rest api with typescript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published