Skip to content

Commit

Permalink
Merge pull request #6 from NivSv/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NivSv authored Mar 27, 2023
2 parents 0f20bc1 + dad5a38 commit 25c1a8d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 73 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Niv Shtibel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 10 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,10 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Installation

```bash
$ npm install
```

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Support

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](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](LICENSE).
## Table of contents
* [General info](#general-info)
* [Technologies](#technologies)

## General info
A simple users api.<br/>
part of the task was to not use ORM. so I used SQL queries and stored procedures.<br/>
[Link to swagger](https://users-api-iexe.onrender.com/api)
## Technologies
NodeJS, Zod, Typescript, pg , Turborepo
23 changes: 23 additions & 0 deletions apps/user-service/src/departments/departments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class DepartmentsService {
@Inject(PostgresService) private readonly postgres!: PostgresService
@Inject(UsersService) private readonly usersService!: UsersService

/**
* Gets a department by id
* @param id The id of the department
* @returns Promise department
*/
async Get(id: number): Promise<Department | null> {
try {
const res = await this.postgres.query<Department>(GET_DEPARTMENT, [
Expand All @@ -38,6 +43,11 @@ export class DepartmentsService {
}
}

/**
* Gets a department by name
* @param name The name of the department
* @returns Promise department
*/
async GetByName(name: string): Promise<Department | null> {
try {
const res = await this.postgres.query<Department>(
Expand All @@ -54,6 +64,10 @@ export class DepartmentsService {
}
}

/**
* Gets all departments
* @returns Promise array of departments
*/
async GetAll(): Promise<Array<Department>> {
try {
const res = await this.postgres.query(GET_ALL_DEPARTMENTS)
Expand All @@ -64,6 +78,11 @@ export class DepartmentsService {
}
}

/**
* Creates a department
* @param createDepartmentDto The department to create
* @returns Promise department
*/
async Create(
createDepartmentDto: CreateDepartmentDto
): Promise<Department> {
Expand All @@ -79,6 +98,10 @@ export class DepartmentsService {
}
}

/**
* Deletes a department
* @param department The department to delete
*/
async Delete(department: Department): Promise<void> {
try {
await this.postgres.query(DELETE_DEPARTMENT, [department.id])
Expand Down

0 comments on commit 25c1a8d

Please sign in to comment.