A progressive Node.js framework for building efficient and scalable server-side applications.
$ npm install# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prodnpm i @nestjs/typeorm typeorm pg @nestjs/configTypeOrmModule.forRoot({
type: 'postgres',
host: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT),
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_DB,
entities: [
User
],
synchronize: true,
})npm i bcryptnpm i -D @types/bcryptnpm install --save @nestjs/swagger swagger-ui-expressnpm i @nestjs/passport @nestjs/jwt passport passport-jwtnpm i -D @types/passport-jwt- Buka terminal atau command prompt
- Copy paste command yang ada dibawah ini untuk generate key dari library crypto
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"- Generate module
nest g mo auth- Generate service
nest g se auth- Generate controller
nest g c authnpm i -D @types/multernpm install winston- lalu buat file logger.ts pada root src
import * as winston from 'winston'
const logger = winston.createLogger({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new winston.transports.Console(),
new winston.transports.File({filename: 'logs/app.log'})
]
})
export default logger;- Import pada file controller lalu letakkan pada setiap controller
import Logger from './logger'# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov| HTTP Method | Endpoint | Description | Request Body/Params | Response |
|---|---|---|---|---|
| GET | / |
The root index main pages in nestjs apps | ||
| GET | /user |
The List of all users | ||
| GET | /user/{id} |
The user's information detail | ||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.