Skip to content

crrmacarse/api

Repository files navigation

Personal API Server

Using NestJS as framework.

Setup

# before proceeding, make sure to have .env file in the root folder(refer to given .env.example)
$ npm install

After succesfully starting up the application, A publicly available API documentation can be visited via /docs route

Development

# start development
$ npm run start:dev

# Or utilize hot reloading. This will result for faster develoopment build time(recommended)
$ npm run start:hot

It is highly recommended to run testing on background

# run testing on background
$ npm run test:watch

Lost?

# run our built-in documentation
$ npm run doc

Debugging

# Run the application in debug mode
npm run start:debug

TIP: You could manually set DEBUG=true in your .env file for a minimal version of debugger. Stack traces can be found on the error log files.

Logging

Log files can be found inside logs folder. File errors is created in a daily basis. You might need to do a clean-up once in a while.

Production

# build production files
$ npm run build

# production mode
$ npm run start:prod

Testing

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Known Issues

  • Becareful of importing module.ts instead of http-module.ts in resolving module dependency. You should be using the http version. There will be no errors for it, Only showing "running" but the server doesn't start.
  • Serialization response returns "support" columns first instead of PK. This is due to extending of BaseEntity. An issue was already raised about this here: typeorm/typeorm#541
  • From NestJS regarding Serialization: "Note that we must return an instance of the class. If you return a plain JavaScript object, for example, { user: new UserEntity() }, the object won't be properly serialized". To mitigate such issue, utilize plainToClass from class-transformer.
  • Added --forceExit in e2e tests run as it doesn't seem to end on its own(nestjs/nest#1538)
  • Adding select:false on column entity with a hook-based approach(Example: @BeforeInsert, @BeforeUpdate) won't be triggered.

Resources

Get in touch