Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leonardo Nascimento - Challenge #12

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions place-api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=mongodb+srv://user:password@instance.yn1uq.mongodb.net/?retryWrites=true&w=majority
124 changes: 124 additions & 0 deletions place-api/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
env: { es6: true, node: true, jest: true }
parser: '@typescript-eslint/parser'
parserOptions:
project: tsconfig.json
sourceType: module
plugins:
- '@typescript-eslint'
- import
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
- plugin:import/errors
- plugin:import/warnings
- plugin:import/typescript
rules:
arrow-body-style: [error, as-needed]
arrow-parens: [error, as-needed]
class-methods-use-this: 'off'
complexity: [warn, { max: 10 }]
curly: error
default-case: error
dot-notation: error
guard-for-in: 'off'
linebreak-style: [error, unix]
max-classes-per-file: 'off'
max-lines: 'off'
new-parens: error
newline-per-chained-call: 'off'
no-bitwise: error
no-caller: error
no-console: 'off'
no-extra-bind: error
no-magic-numbers: 'off'
no-multiple-empty-lines: [error, { max: 1 }]
no-new-func: error
no-new-wrappers: error
no-plusplus: 'off'
no-return-await: error
no-sequences: error
no-template-curly-in-string: error
no-throw-literal: error
no-undef-init: error
no-var: error
object-shorthand: error
one-var: [error, never]
prefer-const: error
prefer-object-spread: error
prefer-template: error
quote-props: [error, consistent-as-needed]
radix: error
some-rule: 'off'
space-before-function-paren:
[error, { anonymous: always, named: never, asyncArrow: always }]
yoda: error
indent: [error, 4, { SwitchCase: 1, CallExpression: { arguments: first } }]
spaced-comment: error
capitalized-comments: [error, always, { ignoreInlineComments: true }]
no-unused-expressions: error
comma-style: [error, last]
comma-dangle: [off]
object-curly-spacing: [error, always]
function-call-argument-newline: [error, consistent]
function-paren-newline: [error, multiline-arguments]
no-duplicate-imports: error
block-spacing: error
func-call-spacing: error
key-spacing: error
no-whitespace-before-property: error
space-before-blocks: error
space-in-parens: error
space-infix-ops: error
space-unary-ops: [error, { words: true, nonwords: false }]
template-tag-spacing: error
template-curly-spacing: error
operator-linebreak: [error, before]
no-unneeded-ternary: error
no-useless-computed-key: error
no-lonely-if: error
no-nested-ternary: error
rest-spread-spacing: error
computed-property-spacing: error
array-bracket-spacing: error
array-bracket-newline: [error, consistent]
no-unused-vars: 'off'
require-atomic-updates: 'off'
no-case-declarations: 'off'
no-require-imports: 'off'

'@typescript-eslint/array-type': [error, { default: array-simple }]
'@typescript-eslint/member-delimiter-style':
[
error,
{ multiline: { delimiter: none }, singleline: { delimiter: comma } },
]
'@typescript-eslint/no-empty-interface': 'off'
'@typescript-eslint/no-explicit-any': 'off'
'@typescript-eslint/no-extraneous-class': 'off'
'@typescript-eslint/no-parameter-properties': 'off'
'@typescript-eslint/no-require-imports': error
'@typescript-eslint/no-unnecessary-qualifier': error
'@typescript-eslint/prefer-for-of': error
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/prefer-interface': 'off'
'@typescript-eslint/restrict-plus-operands': error
'@typescript-eslint/unified-signatures': error
'@typescript-eslint/no-floating-promises': error
'@typescript-eslint/no-unused-vars': [error, { argsIgnorePattern: ^_ }]
'@typescript-eslint/explicit-function-return-type': 'off'
'@typescript-eslint/no-misused-promises': 'off'
'@typescript-eslint/no-use-before-define':
[error, { functions: false, classes: false }]
'@typescript-eslint/ban-types': 'off'
'@typescript-eslint/restrict-template-expressions': 'off'
'@typescript-eslint/no-var-requires': 'off'
'@typescript-eslint/no-unsafe-member-access': 'off'
'@typescript-eslint/no-unsafe-call': 'off'
'@typescript-eslint/no-unsafe-return': 'off'
'@typescript-eslint/no-unsafe-assignment': 'off'
'@typescript-eslint/explicit-module-boundary-types': 'off'

import/no-named-as-default: 'off'
33 changes: 33 additions & 0 deletions place-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# local env files
.env
6 changes: 6 additions & 0 deletions place-api/.huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm run test:cov"
}
}
6 changes: 6 additions & 0 deletions place-api/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.ts": [
"eslint 'src/**'",
"npm run test:staged"
]
}
5 changes: 5 additions & 0 deletions place-api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"semi": false
}
24 changes: 24 additions & 0 deletions place-api/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Project",
"protocol": "inspector",
"args": [
"${workspaceRoot}/src/main.ts"
],
"cwd": "${workspaceRoot}",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"internalConsoleOptions": "openOnSessionStart",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
]
}
]
}
86 changes: 86 additions & 0 deletions place-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

# Project name
<h1 align="center">PlaceApi</h1>

## Project description
<p align="center">Places API</p>


## Framework

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

## Installation

```bash

# clone repository
$ git clone https://github.com/LeonardoNascimentoDev/backend-challenge.git

# access project folder
$ cd backend-challenge

# install project dependencies
$ npm install


```

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev
```
## Tecnologias
- Typescript
- NestJS
- MongoDB
- Swagger
- JestJS

## API endpoints

- Application Swagger: http://localhost:3000/api/


###### POST
- Register place
http://localhost:3000/api/v1/places/save

![image](https://user-images.githubusercontent.com/50468893/179626373-99a312c6-7ee6-4ada-983d-d3fb165543e0.png)

###### PUT
- Update place
http://localhost:3000/api/v1/places/62d5ddcbf0181e6c39542d4b

![image](https://user-images.githubusercontent.com/50468893/179627601-2b8735c7-731c-498c-b524-bb53b5329a92.png)

###### GET
- Get a place by id
http://localhost:3000/api/v1/places/62d5ddcbf0181e6c39542d4b

![image](https://user-images.githubusercontent.com/50468893/179627842-437c9fd1-de99-4b4d-abdf-bf848707b2ca.png)

###### GET
- Get all registered places
http://localhost:3000/api/v1/places

![image](https://user-images.githubusercontent.com/50468893/179628116-3ba260da-f5c1-4a29-97fd-8f51afa88905.png)

###### DELETE
- Remove place by id
http://localhost:3000/api/v1/places/62d5ddcbf0181e6c39542d4b

![image](https://user-images.githubusercontent.com/50468893/179628264-aea0caa4-f9ca-4e24-92ec-d32bec20b5ad.png)

## Stay in touch

- Author - Leonardo Nascimento

## License

Nest is [MIT licensed](LICENSE).
6 changes: 6 additions & 0 deletions place-api/doc/resources/CreatePlaceRequest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"country": "Portugal",
"place": "Sintra Castle",
"goal": "2022-7",
"urlFlag":"https://pt.wikipedia.org/wiki/Bandeira_de_Portugal#/media/Ficheiro:Flag_of_Portugal.svg"
}
10 changes: 10 additions & 0 deletions place-api/doc/resources/CreatePlaceResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"country": "Portugal",
"place": "Sintra Castle",
"goal": "2022-7",
"urlFlag": "https://pt.wikipedia.org/wiki/Bandeira_de_Portugal#/media/Ficheiro:Flag_of_Portugal.svg",
"registerDate": "2022-07-18T14:43:02.722Z",
"lastModifyDate": "2022-07-18T14:43:02.722Z",
"_id": "62d59ba6ef5d3d03ce1f6a5c",
"__v": 0
}
4 changes: 4 additions & 0 deletions place-api/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
Loading